if exit_trade == "exit_CE"
strategy.exit("CE-Ex", from_entry = "CE", limit = open)
plotshape(exit_trade == "exit_CE", title="Exit CE", location=location.top, color=color.orange, style=shape.triangledown, text="Exit CE")
I am using the above code in my strategy and have applied the same condition for strategy.exit
and for plotshape
functions.
The plotshape function showing signal on correct candle but strategy.exit function shifting signal one or two candles right to the actual candle.
Why is this happening and how do I solve it?
Your profit limit
is open, but only when exit_trade == "exit_CE"
Separate your exit rule from your profit, and use comments to debug.
if strategy.position_size > 0
strategy.exit(
id = "CE-Ex",
from_entry = "CE",
limit = open,
comment_profit = 'TP')
if exit_trade == "exit_CE"
strategy.close(
'Long',
comment = 'exit_CE')