Hi all,
Ive encountered a problem for which I cannot find a solution in the manual or in previous forum posts. If I have a strategy that can only open a maximum of 2 trades per day. How would you stop the 2nd position from being opened if the 1st trade was a winner? I.e. I only want to open the 2nd trade if the 1st attempt was unsuccessful.
I have tried using the
POSITIONPERF(1)
function but I don’t think that works because what happens to the very 1st trade of the strategy – i.e. when there is no previous trade to reference?
Thanks
Roj
Compare STRATEGYPROFIT to STRATEGYPROFIT from the bar before and if it is more then set a flag to not trade. At the end of the day reset the flag.
Something like this:
if time = 000000 then
inprofit = 0
tradecount = 0
endif
if strategyprofit > strategyprofit[1] then
inprofit = 1
endif
if (your entry conditions) and not inprofit and tradecount < 2 then
buy 1 contract at market
tradecount = tradecount + 1
endif
Thank you Vonsai. That works a treat. Very smart solution!