AFL pivot points stop loss

#1
I am writing a code to trail stop by pivot points... but facing problem in variable getting reset to 0 again and again.

Example:

PivotLo =0; //initialize

Pivot= some conditions to identify pivot;


PivotLo = iif(Pivot, LLV(Low,3), Ref(pivot,-1)); //if it is a Pivot, set PivotLo to recent low, else use pviotlo value from previous bar.

In this case the pivotlo gets reset to 0 for everybar if it is not a pivot.

I tried using static variables but it does not work. Any help will be much appreciated. Thanks.
 

Similar threads