Plotshape signal error

Hello, I am trying to generate input signals based on a series of conditions but I am encountering problems when displaying them.
For example, one of the conditions is the "Inercia Alcista" signal that gives a buy signal if in period "n" it is greater than 810 and in period n-1 it is less than 810.
As can be seen in the table, buy signals are generated without the conditions being met.
Being the formulas in the two panes the same, can someone tell me where the error is?
Thanks-

Code

//Calculo la inercia alcista

N=26;
M=42;

ROC26=ROC(C,26)*0.4;
ROC42=ROC(C,42)*0.2;

F1=ROC26+ROC42;

J=61;
ATR61=ATR(J);

F2=(ATR61/MA(C,J))*0.4;

InerciaAlcista=F1/F2;

PlotShapes( IIf(InerciaAlcista>810 AND Ref(InerciaAlcista,-1)<810,shapeUpArrow,shapeNone),colorBlue,0,null,-30);

Grafico
image

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.