English

## capturing latest high/low in ZigZag

 56 Dannoo007 2014.02.28 15:36   Hello Boys I am trying to extract the latest high and latest low painted on the chart by the ZigZag indicator at any moment. Unlike other indicators, the problem with this fellow is that... the number of bars to be counted back is not fixed, it can also skip to Bar0 and start moving again within Bar0 if previous high/low is crossed. is iCustom the way to do it? ```double ZigLatestHigh =iCustom(symbol,timeframe,"ZigZag",???,???); double ZigLatestLow =iCustom(symbol,timeframe,"ZigZag",???,???); ``` Any tips much appreciated. D.
 13130 WHRoeder 2014.02.28 18:44 #   ```double ZigLatestHigh =iCustom(symbol,timeframe,"ZigZag",???,???); double ZigLatestLow =iCustom(symbol,timeframe,"ZigZag",???,???); ``` Are you actually looking at other "symbol,timeframe"s? Simplify, trade the current chart (otherwise you can't use Bars, High[], etc.) ZigZag has only 1 buffer to read. ```for(int iBar = 1; iBar < Bars; iBar++) if(    iCustom(NULL,0, "ZigZag", 0, iBar) != 0) break; int iZig1 = iBar; for(iBar--; iBar < Bars; iBar++) if(    iCustom(NULL,0, "ZigZag", 0, iBar) != 0) break; int iZig2 = iBar; double h1 = High[iZig1],        h2 = High[iZig2]; double ZigLatestHigh = (h1 > h2) ? h1 : h2,        ZigLatestLow  = (h1 > h2) ? Low[iZig2] : Low[iZig1]; ```
 Moderator3523 GumRai 2014.03.01 09:23 #   WHRoeder: Are you actually looking at other "symbol,timeframe"s? Simplify, trade the current chart (otherwise you can't use Bars, High[], etc.) ZigZag has only 1 buffer to read. ```for(int iBar = 1; iBar < Bars; iBar++) if(    iCustom(NULL,0, "ZigZag", 0, iBar) != 0) break; int iZig1 = iBar; for(iBar--; iBar < Bars; iBar++) if(    iCustom(NULL,0, "ZigZag", 0, iBar) != 0) break; int iZig2 = iBar; double h1 = High[iZig1],        h2 = High[iZig2]; double ZigLatestHigh = (h1 > h2) ? h1 : h2,        ZigLatestLow  = (h1 > h2) ? Low[iZig2] : Low[iZig1];``` Should iBar-- be iBar++ ?