I use plot()
to draw the price movement of the selected asset (bars and shadows are visually disabled). The two colors for the short position are dark red when there are no short positions and light red when the short position is open. For example, the position of the short is open from 04:12 to 05:13, then this period of time will be light red using plot()
, and the rest of the time the color will be dark red. my problem is that plot()
stops coloring the line color one bar before exiting the position. Let’s look at the picture. I marked one bar with lines where the strategy left the position, the line is not colored light red. how can I fix this?
Problem with long and short positions
enter image description here
enter image description here
strategy("hello :)", overlay = true, process_orders_on_close = true, calc_on_every_tick = true)
cl = bc
pl = ce > on ? hh : lw
if ra
if strategy.position_size > 0
cl:= gt
else if strategy.position_size < 0
cl:= rt
else if c1 > o1
cl:= gc
else if c1 < o1
cl:= rc
plot(pl, color = cl, linewidth = 2, editable = false)
Denis19911903 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.