No, there’s no instruction to detect a crossover with lines.
You have to compute the price level on which the line is sitting candle by candle.
Firstly, compute the price difference between the leftmost and the rightmost candle:
StartBar = barindex[20]
EndBar = barindex
Bars = EndBar -StartBar
EndPrice = Close
Difference = (EndPrice - Close[20]) / Bars
then add that difference each candle to know the current price level where the line is plotted. Next candle compute the new price level where the line is supposed to sit:
EndPrice = EndPrice + Difference
Now you can compare the current price vs the supposed price to detect any crossover:
If close crosses over EndPrice then
// do whatever you want when a crossover is detected
Endif
if the difference is negative the direction continues downwards, otherwise it will continue upwards.
Repeat the last process each bar.
When you need to draw a new line elsewhere, repeat the whole process from start.
Thanks a lot for your answer Roberto.
That’s what i though… The aim of this is to look for third of fourth contact on RSI divergences.
To keep in an array the RSI Divergences and test other occurences, and delete divergences from the array as sson as there is a cross over…
In this case, there is 2 bearish divergences with 3 points
That’s fine, you can replace CLOSE with anything else, be it HIGH, LOW, RSI or MACD etc…