同样的代码为什么用polt画会错位

Params //此处添加参数 Numeric AccumDistLength(20); // 积累/分配区间长度Vars Series<Numeric> AvgVolume; // 平均成交量 Series<Numeric> PriceRange; // 价格范围(原Range变量) Series<Numeric> AvgRange; // 平均价格范围Defs //此处添加公式函数 Events //此处实现事件函数 //初始化事件函数,策略运行期间,首先运行且只有一次 OnInit() { } //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组 OnBar(ArrayRef<Integer> indexs) { PriceRange = High - Low; AvgRange = Average((h[1]-l[1]), AccumDistLength); PlotAuto("PriceRange",PriceRange,0,Rgb(155,150,150),Enum_Bar,Enum_Hollow); PlotNumeric("AvgRange",AvgRange); PlotNumeric("1.5bei",AvgRange*1.5); PlotNumeric("2bei",AvgRange*2); If( PriceRange>=1.5*AvgRange) { PlotAuto("PriceRange",PriceRange,0,Blue,Enum_Bar,Enum_Fill); } If( PriceRange>=2*AvgRange) { PlotAuto("PriceRange",PriceRange,0,Yellow,Enum_Bar,Enum_Fill); } } 下面是改到polt图Params //此处添加参数 Numeric Length1(12);//成交量平均周期 Numeric zhongliangbi(1.5);//中量比 Numeric dalingbi(2);//大量比 //幅度线参数---------- Numeric AccumDistLength(20); // 积累/分配区间长度Vars //此处添加变量 Series<Numeric> Avgcjl; Series<Numeric> shang1; //Series<Numeric> shang1; //幅度线参数---------- Series<Numeric> PriceRange; // 价格范围(原Range变量) Series<Numeric> AvgRange; // 平均价格范围 //画图参数--------------------- Plot parentPlt1;//主图 Plot parentPlt2;//主图 Plot childPlt;//附图 Array<Numeric> xData;//x轴数据集 Array<Numeric> yData;//y轴数据集Defs //此处添加公式函数 Events //此处实现事件函数 //初始化事件函数,策略运行期间,首先运行且只有一次 OnInit() { parentPlt1.figure(0); //独立画板 parentPlt2.figure(0); //独立画板 } //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组 OnBar(ArrayRef<Integer> indexs) { PriceRange = High - Low; // 使用PriceRange替代Range AvgRange = Average((h[1]-l[1]), AccumDistLength); // 使用PriceRange计算平均范围 parentPlt2.barv("PriceRange",PriceRange);//,0,Rgb(0,255,255),Enum_Bar,Enum_Fill); parentPlt2.setOption("PriceRange","color",Rgb(200,200,200)); parentPlt2.setOption("PriceRange","style",Enum_Hollow); parentPlt2.line("AvgRange",AvgRange); parentPlt2.line("1.5bei",AvgRange*1.5); parentPlt2.line("2bei",AvgRange*2); If( PriceRange>=1.5*AvgRange) { parentPlt2.barv("PriceRange",PriceRange);//,0,Blue,Enum_Bar,Enum_Fill); parentPlt2.setOption("PriceRange","color",Blue); parentPlt2.setOption("PriceRange","style",Enum_Fill); } If( PriceRange>=2*AvgRange) { parentPlt2.barv("PriceRange",PriceRange);//,0,Yellow,Enum_Bar,Enum_Fill); parentPlt2.setOption("PriceRange","color",Yellow); parentPlt2.setOption("PriceRange","style",Enum_Fill); }

常见毛病了把setoption写在了画图语句后面交换一下画图设置和画图语句

我看看

回复:你指哪个部分错位

回复:

回复:感谢🙏,setoption的位置换了也不行,视频里面也没找到,以前没用过这个 Plot 写法,

回复:我测过的 换了就可以了 你确定换了也不行?

回复:

回复:set全部放在画图前面程序是从上往下运行的

回复:

回复:调了位置后只是颜色变量,位置还是没变,

回复:一共就三句代码,上面下面都试了,就是差一个位置,放到括号外面也不行,第一句我感觉应该是画图,第二句标实体,第三句标颜色,要不然覆盖就就变成白色了,反正上下都试验了,就是差一个位置,是不是版本的问题一会我把软件更新一下

回复:代码改动后,记得编译一下