Search code examples
plotoffsetpine-script

Offset plot price crossing plot price in Pine Script


Let's say I want to make a new label/signal when Price and -Offset Price are crossing each other

abc = plot(close, color=color.aqua)
xyz = plot(close, offset=-25, color=color.lime)

condA = crossover(abc, xyz)
condB = crossunder(abc, xyz)

Since you can't get cross function work if using plot as x and y and also offset function value can't be a negative

It's from Ichimoku Cloud, I want to get add a condition when Lagging Span and Price value are crossing each other

What is the right command to get this work?


Solution

  • The lagging span is just the current close offset into the past. So you can just compare close values that take into account the offset.

    condA = crossover(close, close[offset])