Highest函数嵌套High[变量]时系统识别是不是会出问题?

本来想做一个判断w底的小程序,但是死在Highest(high[变量],周期)上面了原代码如下:Params Numeric MA5(5); //周期5日Vars NumericSeries bottom1; //回滚周期10根bar的前5根底部价 NumericSeries bottom2; //回滚周期10根bar的后5根底部价 NumericSeries checking1; //回滚周期10根bar的第5根最低价 NumericSeries checking2; //回滚周期10根bar的第10根最低价 NumericSeries checking3; //bottom2所在bar的最高价 NumericSeries spike; //bottom1和bottom2之间众bar的颈线值Begin checking1=Low[5]; checking2=low; PlotNumeric(\"checking1\",checking1); //返回值,方便界定头五根位置 PlotNumeric(\"checking2\",checking2); //返回值,方便界定后五根位置 bottom1=LowestBar(checking1,5); bottom2=LowestBar(checking2,5); PlotNumeric(\"bottom1\", bottom1); //返回值,确定前底位置 PlotNumeric(\"bottom2\", bottom2); //返回值,确定后底位置 checking3=High[bottom2]; spike=Highest(High[bottom2],bottom1+5-bottom2+1); PlotNumeric(\"checking3\",checking3); //返回值,确定bottom2位置 PlotNumeric(\"spike\", spike); //返回值,确定bottom1和bottom2之间众bar的顶部价 End——————————————————————————编译是可以编译成功,但实际回测时,‘spike=Highest(High[bottom2],bottom1+5-bottom2+1); ‘这段代码输出值有问题,以标的品种sa2305为例,频率切到日线,2022年8月10日的spike值是2208(实际正确值应当为2256),排查后发现是High[bottom2]中的bottom2有问题,当日的bottom2值为3,如果把出错代码手动改写成‘spike=Highest(High[3],bottom1+5-bottom2+1); ‘,spike值就是正确的2256,但用原版代码死活就是2208,求问各位前辈有无办法解决这个问题?

肯定是不行的....你可以自己打开highest的算法看看如果非要用变量,恐怕你得自己写一个新得highest函数

回复:如果是系统内建的highest函数代码,打开一看更奇怪了Params NumericSeries Price(0); Numeric Length(5); Vars Numeric HighestValue; Numeric i;Begin HighestValue = Price; for i=1 to Length - 1 { If(Price[i] > HighestValue) HighestValue = Price[i]; } Return HighestValue;End这上面的length是遍历5根,但是我们平时用highest的时候周期位置根本不会受制于5根啊,难不成这个系统函数只是一个演示范例,highest计算时的底层逻辑另有一套?我这样问的原因,是我想验证下[]这个用来回溯的符号里套进变量而不是纯数字会不会出问题

回复:5只是一个默认参数 highest具体使用的时候是根据你调用highest时输入的参数确定计算的套进变量大部分函数都是有问题的,都要自己写函数运行

回复:那么for语句的起点用变量行不行?因为我用for语句曲线救国的时候,发现滚动运算的时候还是会出错(我的起点按理说只是以Currentbar为锚点倒推前面的特定条件变量而已)