I am using my script with 3commas. I am trying to set alerts to when it flips from one direction to another like in the picture. What is the best way to write that in code? It seems that I cant send a close alert for previous trade to 3c when this situation happens. Please Help :)
entry code:
//entry & exit
strategy.entry('LONG', direction=strategy.long, comment='LONG', when=Long_signal, alert_message = entry_long_alert)
strategy.entry('SHORT', direction=strategy.short, comment='SHORT', when=Short_signal, alert_message = entry_short_alert)
exit code:
// exit long
if strategy.position_size > 0
if (Short_signal)
strategy.close('LONG', alert_message = close_long_alert)
else
strategy.exit(id = "Close", stop = longstoppercent, limit = longtakeprofit, alert_message = close_long_alert)
// exit short
if strategy.position_size < 0
if (Long_signal)
strategy.close('SHORT', alert_message = close_short_alert)
else
strategy.exit(id = "Close", stop = shortstoppercent, limit = shorttakeprofit, alert_message = close_short_alert)