我想实现开启bar内30分钟周期天前一分钟满足条件开仓bar走完确认信号
源码如下:[code]
[IntrabarOrderGeneration=True] //开启BAR内下单
inputs: Price( Close ), FastLength( 3 ), SlowLength( 9 ) ;
var: recalcpersist time1(0), recalcpersist time0(0), recalcpersist flag(0), mp(0);
variables: var0( 0 ), var1( 0 ) ;
var0 = AverageFC( Price, FastLength ) ; //均线1
var1 = AverageFC( Price, SlowLength ) ;//均线2
condition1 = CurrentBar > 1 and var0 crosses over var1 ; //条件1,当前K线状态,同时慢均线上穿快均线
condition2 = CurrentBar > 1 and var0 crosses under var1 ; //条件2,当时K线状态,同时慢均线下穿快均线
time1=time0;
if getappinfo(aistrategyauto)=1 then //为开启BAR内委托
time0=q_time_s
else time0=time_s; //表示当前Bar的收盘时间
if condition1 then flag=1
else if condition2 then flag=-1;
value1=SecondsToTime_s(TimeToSeconds(symbol_time_s)-60);
if time1=value1 then begin
if flag=1 then
buy next bar at market
else if flag=-1 then
sellshort next bar at market;
flag=0;
end;
mp=marketposition;
if mp[1]<>1 and mp=1 and barstatus=2 and condition1=false then
sell next bar at market
else if mp[1]<>-1 and mp=-1 and barstatus=2 and condition2=false then
buytocover next bar at market;
once cleardebug;
print("currentbar=",currentbar,",time1=",time1,",time0=",time0,",symbol_time_s=",symbol_time_s,",mp[1]=",mp[1],",mp=",mp);
[/code] 今天有些感冒注释更新到此,休息一下、。{:63:} 第二、今天上午测试没有问题,测试输出结果如下:
[code]
currentbar= 7.00,time1=212858.00,time0=212858.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 0.00
currentbar= 7.00,time1=212858.00,time0=212859.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 0.00
currentbar= 7.00,time1=212859.00,time0=212859.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 0.00
currentbar= 7.00,time1=212859.00,time0=212900.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 0.00
currentbar= 7.00,time1=212900.00,time0=212900.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 1.00
currentbar= 7.00,time1=212900.00,time0=212901.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 1.00
currentbar= 7.00,time1=212901.00,time0=212901.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 1.00
currentbar= 7.00,time1=212901.00,time0=212902.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 1.00
currentbar= 7.00,time1=212902.00,time0=212902.00,symbol_time_s=213000.00,mp[1]= 0.00,mp= 1.00
第三、您可能再看一下上面的回复,是否按照上面的回复进行测试。
[/code] Alex老师按上述代码螺纹30分钟周期时间2018年1月19日到今回测没有信号
zdq8888 发布于2018-07-20 10:37
Alex老师如何回测有信号
zdq8888 发布于2018-07-20 13:58
在策略属性-回测中,勾选“使用精细资料”(逐笔1笔),勾选“在开启bar内交易模式的计算允许访问bar内时间”
Alex_Yang 发布于2018-07-23 17:20
页:
[1]