Code: Select all
//5 min data1, 60 min data2
Inputs: pip(0.00002), MinStop(.001);
Vars: MP(0), Flag(false), Trig(0), R(0), size(0), StartEquity(25000);
[intrabarordergeneration = True];
MP = MarketPosition;
//Check for setup at end of bar
If BarStatus(2) = 2 and MP <= 0 then begin
//Check for inside bar and calculate trigger, Risk and trade size
If (H data2 < H[1] data2 and L data2 > L[1] data2) then Flag = True Else Flag = False; //else is redundant?
If Flag then begin
Trig = High data2 + pip;
R = Iff(((High data2 - Low data2) + (pip * 2)) > MinStop, ((High data2 - Low data2) + (pip * 2)), MinStop);
end;
{Size = calculate position size based on account size and R}
size = (((StartEquity + NetProfit)*.001)/R);
end;
If MarketPosition_at_Broker = 0 and Flag then begin //Flag should be false at end of bar when condition isn't met and order canceled
Buy("Long") size shares next bar at Trig Stop;
end;
If MP = 1 then Flag = false;
If MP = 1 then begin
If BarsSinceEntry >= 3 then sell next bar at market;
end;