Continuing the previous topic, we can say that its systems do not work for western markets, but for Gazprom and futures on the RTS on H1 it is quite suitable. True, I have incomplete data on these tools. — absent for 2009 year, but it's also better — check on 2009 as out of sample :)
Yes, completely forgot — this system is called “Time Any”. Here is her code for WealthLab4:
——————————————–
was Bar, p: integer;
PlotSeries( HighestSeries( #High, 5 ), 0, #Red, #Thin );
PlotSeries( LowestSeries( #Low, 5 ), 0, #Blue, #Thin );
for Bar := 20 to BarCount – 1 do
begin
if LastPositionActive then
begin
p := LastPosition;
if PositionLong( p ) then
begin
if LastBar( Bar ) then
SellAtClose( Bar, p, ‘EOD’ )
else
SellAtStop( Bar + 1, Lowest( Bar, #Low, 5 ), p, ‘Stop’ );
end;
if PositionShort( p ) then
begin
if LastBar( Bar ) then
CoverAtClose( Bar, p, ‘EOD’ )
else
CoverAtStop( Bar + 1, Highest( Bar, #High, 5 ), p, ‘Stop’ );
end;
end
else
begin
if not LastPositionActive then
begin
if (PriceHigh(bar) – PriceLow(bar)) < ATR(bar, 10) then
BuyAtStop( Bar + 1, Highest( Bar, #High, 5 ), ” );
end;
if not LastPositionActive then
begin
if (PriceHigh(bar) – PriceLow(bar)) < ATR(bar, 10) then
ShortAtStop( Bar + 1, Lowest( Bar, #Low, 5 ), ” );
end;
end;
end;
—————————————————