龙听期货论坛's Archiver

龙听 发表于 2023-8-25 17:12

multicharts基础编程 第005节 量化基础bar的介绍之bar的编号与回溯(总结篇)

[mp4]http://mp4.qhlt.club/mcode/005.mp4[/mp4]

龙听 发表于 2023-8-25 17:16

bar的绝对编号:[code]
Value1=Text_New(Date,Time,low-5 point,NumToStr(symbol_currentbar,0));
[/code]bar的相对编号:[code]
Value2=Text_New(Date,Time,high + 5 point,NumToStr(currentbar,0));
[/code]【currentbar】与【BarNumber】异同[code]
Value3=Text_New(Date,Time,high+5 point,NumToStr(BarNumber,0));
[/code]最大bar数量(maxbarsback)【强制预留bar数量】

龙听 发表于 2023-8-25 17:32

输出前5个bar的绝对编号与价格[code]

switch symbol_currentbar begin

case 5 : begin

print("BarNumber=",symbol_currentbar,",time[0]=",time[0],",close[0]=",close[0]);

print("BarNumber=",symbol_currentbar-1,"time[1]=",time[1],",close[1]=",close[1]);
      
print("BarNumber=",symbol_currentbar-2,"time[2]=",time[2],",close[2]=",close[2]);
      
print("BarNumber=",symbol_currentbar-3,"time[3]=",time[3],",close[3]=",close[3]);
      
print("BarNumber=",symbol_currentbar-4,"time[4]=",time[4],",close[4]=",close[4]);

end;
end;

[/code]输出前5个bar的相对编号及价格[code]
switch BarNumber begin

case 5 : begin

print("BarNumber=",BarNumber,",time[0]=",time[0],",close[0]=",close[0]);

print("BarNumber=",BarNumber[1],"time[1]=",time[1],",close[1]=",close[1]);
      
print("BarNumber=",BarNumber[2],"time[2]=",time[2],",close[2]=",close[2]);
      
print("BarNumber=",BarNumber[3],"time[3]=",time[3],",close[3]=",close[3]);
      
print("BarNumber=",BarNumber[4],"time[4]=",time[4],",close[4]=",close[4]);

end;
end;
[/code]输出前5个bar的相对编号及价格[code]
switch currentbar begin

case 5 : begin

print("BarNumber=",currentbar,",time[0]=",time[0],",close[0]=",close[0]);

print("BarNumber=",currentbar-1,"time[1]=",time[1],",close[1]=",close[1]);
      
print("BarNumber=",currentbar-2,"time[2]=",time[2],",close[2]=",close[2]);
      
print("BarNumber=",currentbar-3,"time[3]=",time[3],",close[3]=",close[3]);
      
print("BarNumber=",currentbar-4,"time[4]=",time[4],",close[4]=",close[4]);

end;
end;
[/code]

龙听 发表于 2023-8-25 21:59

最大bar数量(maxbarsback)【强制预留bar数量】对指标无效。大家可以测试一下,在信号上面是有效的,当策略的回溯周期大于强制预留的maxbarsback时会报错。

龙听 发表于 2023-8-27 13:07

[img]http://p.algo2.net/2023/0827/6a4ae21be35d6.png[/img]

龙听 发表于 2023-9-1 10:20

multicharts量化课程网课PPT下载:[url]http://www.qhlt.cn/thread-143956-1-1.html[/url]

页: [1]