之字转向 单图层分开记录高点和低点
//------------------------------------------------------------------------
// 简称: ZigZag
// 名称: 之字转向
// 类别: 策略应用
// 类型: 内建应用
//------------------------------------------------------------------------
Params
    Numeric RetracePct(2);
Vars
    Series<Numeric> SwingPrice;
    Numeric SwingHighPrice;
    Numeric SwingLowPrice;
    Series<Numeric> PreBar(0);
    Series<Numeric> UpDn(0);
    Bool SaveSwing(False);
    Bool NewTL(False);
    Bool UpdateTL(False);
    global array<numeric> price_record_high;
    global array<numeric> price_record_low;
    series<Numeric> i;
    series<Numeric> j;
Events
    OnBar(ArrayRef<Integer> indexs)
    {
    
        If(CurrentBar == 0)
        {
            SwingPrice = Close;
            i = 0;
            j = 0;
        }
    
        SwingHighPrice = SwingHigh( 1, Close, 1, 2);
        SwingLowPrice = SwingLow( 1, Close, 1, 2 );
    
        If (SwingHighPrice <> -1)
        {
            If(UpDn <= 0 && SwingHighPrice >= SwingPrice * (1 + RetracePct * 0.01))
            {
                UpDn = 1;
                NewTL = True;
                SaveSwing = True;
                price_record_low[j] = SwingPrice;
                j = j + 1;
            }
            Else If(UpDn == 1 && SwingHighPrice >= SwingPrice)
            {
                UpdateTL = True;
                SaveSwing = True;
            }
    
            If(SaveSwing)
            {
                SwingPrice = SwingHighPrice;
                PreBar = CurrentBar;
            }
        }
        Else If(SwingLowPrice <> -1)
        {
            If(UpDn >= 0 && SwingLowPrice <= SwingPrice * (1 - RetracePct * 0.01))
            {
                UpDn = -1;
                NewTL = True;
                SaveSwing = True;
                price_record_high[i] = SwingPrice;
                i = i + 1;
            }
            Else If(UpDn == -1 && SwingLowPrice <= SwingPrice)
            {
                UpdateTL = True;
                SaveSwing = True;
            }
    
            If(SaveSwing )
            {
                SwingPrice = SwingLowPrice;
                PreBar = CurrentBar;
            }
        }
    
        If( NewTL)
        {
            PlotAuto("ZigZag", SwingPrice, 0, Color2(), -1, -1, Enum_3Pix, 1);
        }
        Else If(UpdateTL)
        {
            If (UpDn == UpDn[1])
            {
                Unplot("ZigZag", PreBar - PreBar[1] + 1);
                PlotAuto("ZigZag", SwingPrice, 0, Color2(), -1, -1, Enum_3Pix, 1);
            }
            Else
            {
                PlotAuto("ZigZag", SwingPrice, 0, Color2(), -1, -1, Enum_3Pix, 1);
            }
        }
    
        If(BarStatus == 2)
        {
            print("高点");
            print(TextArray(price_record_high));
            print("低点");
            print(TextArray(price_record_low));
        }
    }
//------------------------------------------------------------------------
// 编译版本    GS2010.12.08
// 版权所有    TradeBlazer Software 2003-2025
// 更改声明    TradeBlazer Software保留对TradeBlazer平
//            台每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------


请问指标公式中的之字转向(ZigZag)在波峰波谷之间为何会有取值?
请教:当收盘价小于转向高点10%的时候,取转向高点的值,怎么写?
记录个临时低点
如何引用内建应用:ZigZag之字转向,在自己建的公式应用中
求助:记录阶段高低点
如何找到最近的3个最高点和最低点
如何求13-15点时间段的最高点,最低点
满足条件后,当前bar的低点
【量化源码共学】之基于平移的高低点均值通道与K线中值突破
画线

刘老师👍