Reputation: 1
I created a strategy, entries work, SL, TP work. All is fine, but I wanted to also add Exit on EMA cross.
For some reason it does not work. Maybe someone can help?
I have added inputs for ema's I have plotted the ema's - they are visible, all works fine so far,
so I have added this to have one more exit condition and this does nothing:
closelong = ta.crossover(ema1, ema2)
closeshort = ta.crossunder(ema1, ema2)
if closelong
strategy.close("Close long", alert_message = message_closelong)
if closeshort
strategy.close("Close short", alert_message = message_closeshort)
Upvotes: 0
Views: 375
Reputation: 3
How do you launch the long and short entry?
strategy.entry(id, direction, qty, limit, stop, oca_name, oca_type, comment, alert_message, disable_alert) → void
Note that the ID must match when you invoke the strategy.close(""...)
:
if long_condition
strategy.entry("Long",...)
if close_condition
strategy.close("Long",...)
Upvotes: 0
Reputation: 1
"Close long" and "Close short" must match the strategy entry, which was buy and sell
Upvotes: 0