Will appreciate help.
Code: Select all
[IntrabarOrderGeneration = True]
Var: IntrabarPersist Mp(0), IntrabarPersist MP_prev(0),IntrabarPersist TradesThisBar(0),IntrabarPersist FirstTickOfBar(False);
MP = MarketPosition;
If MP <> MP_prev then TradesThisBar = TradesThisBar + 1;
If FirstTickOfBar then TradesThisBar = 0;
if BarStatus(1)=2 then Value1=Random(10);
if TradesThisBar = 0 and Mp<>1 and Value1 > 5 then Buy next bar Open Limit;
if TradesThisBar = 0 and Mp<>-1 and Value1 < 5 then SellShort next bar Open Limit;
if TradesThisBar = 0 and Mp=1 and BarsSinceEntry > 1 then Sell next bar at Market;
if TradesThisBar = 0 and Mp=-1 and BarsSinceEntry > 1 then BuyToCover next bar at Market;
FirstTickOfBar = BarStatus(1) = 2;
MP_prev = MP;