Hi,
I’m trying to write exit conditions that either closes the position at close if it is profitable OR closes the positions after N days. How would that look in code?
Best Regards,
Sebastian
JSParticipant
Senior
Hi,
If LongOnMarket and (Close - TradePrice(1)) > X then
Sell at Market
EndIf
If ShortOnMarket and (TradePrice(1) – Close) > X then
ExitShort at Market
EndIf
If NOT OnMarket[1] and OnMarket then
xStartBar = BarIndex
EndIf
If BarIndex – xStartBar > X then
Sell at Market
ExitShort at Market
EndIf
Thanks for your assistance!
Best regards,
Sebastian