based on link below
https://forum.amibroker.com/t/second-low-period-start-from-the-first-high/33238/8?u=needhelp
i change it to find the low
// consecutive_HHV.afl
n1 = 10;
n2 = 3;
n3 = 15;
bi = BarIndex();
// The concept is to search the HH position on a selection of the data.
// Fist step: from the end back to n1 bars
n1_data = IIf(bi >= BarCount - n1 , L , Null);
n1_LL_pos = BarCount - LastValue( LowestBars (n1_data)) -1 ; // CHANGE THE < AND >
n1_LL_val = L[n1_LL_pos];
// Second Step: from the last HH pos back to n2 bars
n2_data = IIf( bi > n1_LL_pos - n2 - 1 AND bi < n1_LL_pos, L , Null);
n2_LL_pos = BarCount - LastValue( LowestBars (n2_data)) ;
n2_LL_val = L[n2_LL_pos];
// Third step: again the same...
n3_data = IIf( bi > n2_LL_pos - n3 - 1 AND bi < n2_LL_pos, L , Null);
n3_LL_pos = BarCount - LastValue( LowestBars (n3_data)) ;
n3_LL_val = L[n3_LL_pos];
// plots
PlotOHLC(O, H, L, C, "", colorGrey40, styleBar);
SetChartOptions(0, chartShowDates);
PlotShapes(IIf( NOT IsNull(n1_data), shapeSmallCircle, shapeNone), colorGreen, 0, H, -15, 0);
PlotShapes(IIf( bi == n1_LL_pos, shapeUpTriangle, shapeNone), colorGreen, 0, H, -15, 0);
PlotText(NumToStr(n1_LL_val, 1.2, False), n1_LL_pos, n1_LL_val, colorWhite, colorGreen, 40);
PlotShapes(IIf( NOT IsNull(n2_data), shapeSmallCircle, shapeNone), colorRed, 0, H, 15, 0);
PlotShapes(IIf( bi == n2_LL_pos, shapeUpTriangle, shapeNone), colorRed, 0, H, -15, 0);
PlotText(NumToStr(n2_LL_val, 1.2, False), n2_LL_pos, n2_LL_val, colorWhite, colorRed, 40);
PlotShapes(IIf( NOT IsNull(n3_data), shapeSmallCircle, shapeNone), colorLightBlue, 0, H, -15, 0);
PlotShapes(IIf( bi == n3_LL_pos, shapeUpTriangle, shapeNone), colorLightBlue, 0, H, -15, 0);
PlotText(NumToStr(n3_LL_val, 1.2, False), n3_LL_pos, n3_LL_val, colorWhite, colorLightBlue, 90);
Filter = 1 ;
// Exploration
SetBarsRequired(sbrAll, sbrAll);
AddColumn(bi, "bar index", 1.0);
AddColumn(n1_LL_pos, "LL1's BI", 1.0);
AddColumn(L[n1_LL_pos], "LL1's value", 1.2);
AddColumn(n2_LL_pos, "LL2's BI", 1.0);
AddColumn(L[n2_LL_pos], "LL2's value", 1.2);
AddColumn(n3_LL_pos, "LL3's BI", 1.0);
AddColumn(L[n3_LL_pos], "LL3's value", 1.2);
thank you