求助:记录阶段高低点
2023-11-09 13:19

代码如下:

Vars

Series<Numeric> low_num;

Series<Numeric> high_num;

   OnBar(ArrayRef<Integer> indexs)

{

       if(low<low[1] and Low[-1]>=Low)

{

low_num=low;

PlotNumeric(low_high,low);

}

if(high>high[1] and high[-1]<=high)

{

high_num=high;

PlotNumeric(low_high,high);

}

Commentary(low_num[0]:+text(low_num[0]));

Commentary(low_num[1]:+text(low_num[1]));

Commentary(low_num[2]+text(low_num[2]));

Commentary(high_num[0]+text(high_num[0]));

Commentary(high_num[1]+text(high_num[1]));

Commentary(high_num[2]+text(high_num[2]));

}

序列变量加了条件判断,想把不是阶段最高低的位置去掉,现在查看下来每一根都有值,不赋值就给上一根。想在十字位置拿到第2个前高的值3821,但是拿到的是3834,该怎么拿到我箭头标记的第2根高点呢?


data-href=

评论区
c166****4159

我不想要每个bar一个值,但是又要保存数据,数组嫩根python一样用下标取值吗arr[-2:-1]

2023-11-09 16:21
c166****4159

1.我只跑回测,只用历史数据,可以往后拿数据,不然我没法判断当前的最高价是不是最高价,如果用前3根去比较,点只能画在当前k线上,我需要画在最高点k线上;

2.先high2 = high1,后high1=新的高点值确实可以,但是只能回溯2根,再回溯1根又要重新定义一个序列变量

2023-11-09 14:31
c166****4159

好像没有用,序列变量在每根k线都有一个副本值

2023-11-09 13:43
顶部