Problem with this is that orders stay open only one bar, in my case 1min. There is also commented part which I wanted to use to move stop loss, but I didn't get there yet.
Radek
Variable:
OpenTime(1000), //Time when Orders are made
DayATR (0),
MP( 0 ), TT( 0 ),
TodayOpen(0),PreviousDayOpen(0),//Opens at OpenTime
OrderRange(0), SLRange(0), DayRange(0)
;
//data1 = 1 minute
//data2 = 1 hour
//data3 = 1 day
if (Time = OpenTime) then
begin
//calculate data
DayATR = AvgTrueRange(10) of data3;
MP = MarketPosition ;
TT = TotalTrades ;
TodayOpen = Open of data2;
PreviousDayOpen = Open[23] of data2;
DayRange = DayATR * PriceScale;
OrderRange = DayRange * .8;
SLRange = DayRange * .3;
{ //if I have long position - move SL
if MP = 1 then
sell on next bar at TodayOpen + (SLRange * 1/PriceScale) stop ;
//if I have short position - move SL
if MP = -1 then
buytocover on next bar at TodayOpen - (SLRange * 1/PriceScale) stop ;
}
//open new order
if TodayOpen < PreviousDayOpen then
begin //long order + SL
buy on next bar at TodayOpen + (OrderRange * 1/PriceScale) stop;
sell on next bar at TodayOpen + (SLRange * 1/PriceScale) stop ;
end
else
begin //short order + SL
sellshort on next bar at TodayOpen - (OrderRange * 1/PriceScale) stop;
buytocover on next bar at TodayOpen - (SLRange * 1/PriceScale) stop ;
end;
end;