//Get more accurate entry price once on market in case there was a gap
if onmarket and not onmarket[1] then
if countofposition = 2 then
entryprice = tradeprice
endif
if countofposition = 1 then
entryprice = tradeprice[2]
endif
endif
//Pending orders for two positions open
if onmarket and countofposition = 2 then
sell at entryprice + 20 limit
sell 1 contract at entryprice - 10 stop
sell 1 contract at entryprice - 20 stop
endif
//Pending orders for one position open
if onmarket and countofposition = 1 then
sell at entryprice + 20 limit
sell 1 contract at entryprice - 20 stop
endif
//Enter market and place pending orders for two positions
if not onmarket and (your entry conditions) then
buy 2 contracts at market
sell at close + 20 limit
sell 1 contract at close - 10 stop
sell 1 contract at close - 20 stop
endif