if(date<>date[1]) then // first bar of the day begin
canBuy = false;
canSell = false;
buysToday = 0;
sellsToday = 0;
end;
if marketPosition = 1 then buysToday = 1; // if we already bot then no more buys
if marketPosition =-1 then sellsToday = 1;
stb = openD(0) + offSetAmt * atrAmt;
sts = openD(0) - offSetAmt * atrAmt;
if(closeD(1)>=closeD(2) and smallRange) then canBuy = true;
if(closeD(1)<closeD(2) and smallRange) then canSell = true;
if(canBuy and buysToday = 0 and time < endTradeTime) then buy(“SFOBuy”) 2 contracts next bar stb stop;
if(canSell and sellsToday = 0 and time < endTradeTime ) then sellShort(“SFOSell”) 2 contracts next bar sts stop;
if currentContracts = 2 and marketPosition = 1 and highD(0) > entryPrice + profitObj1 then sell(“LongProf1”) 1 contract next bar at highD(0) - 5 stop;
if currentContracts = 2 and marketPosition =-1 and lowD(0) < entryPrice - profitObj1 then buyToCover(“ShrtProf1”) 1 contract next bar at lowD(0) + 5 stop;
if currentContracts = 1 then sell(“L-BreakEven”) next bar at entryPrice stop;
if currentContracts = 1 then buyToCover(“S-BreakEven”) next bar at entryPrice stop;
if marketPosition = 1 then sell(“MM-L-Out”) next bar at entryPrice - stopAmtPoints stop;
if marketPosition =-1 then buyToCover(“MM-S-Out”) next bar at entryPrice + stopAmtPoints stop; setExitOnClose;