Hello
Is it possible to create an instructions that states “if trade has not completed within X bars close at breakeven if seen before target or loss.
so effectively I can limit the time the code is running before breakeven is triggered into place regardless of the percentage of target achieved.
This is for code that should work quickly hence the request to put a timer on it before reducing risk.
Any help or direction would be appreciated.
Kind regards
Hi
Sorry should have said breakeven instruction is already written into code based on percentage of target achieved. With a “breakevenstart” instruction and breakevenLevel.
Something like this perhaps:
daysallowed = 10
if onmarket and barindex - tradeindex >= daysallowed then
if longonmarket then
if close > positionprice then
sell at positionprice stop
endif
if close < positionprice then
sell at positionprice limit
endif
endif
if shortonmarket then
if close < positionprice then
exitshort at positionprice stop
endif
if close > positionprice then
exitshort at positionprice limit
endif
endif
endif