信号出错

hi,老师下午好,下面是TB官网的一个关于日内交易的视频,开盘30分钟后 上破开盘30m内的max开多,反之下破30m内的min开空,1m周期,我依葫芦画瓢,结果:1)为什么信号是在开盘后181根之后有信号才开仓 即使开盘后第31-180m之间是上破下破状态,打死也不开仓; 请问是这里的问题吗 if(truedate(0)<>truedate(1)) 如果是啥原因 怎么改? 注意: param中 length是30哈 不是1802) 我把 if(truedate(0)<>truedate(1)) 改成 if(time== 0.21) 或者 if(time()== 0.21) 报错 请问如果我用time 相当于夜盘21:00开 始有bar 如果我用time 不用truedate 怎样改 它才不报错 期待着您的回复!Params //此处添加参数 Numeric length(30); Numeric stoppoint(10); //止损10 minmove * pricescale表示跳 Numeric trade_limit(2); //多《=2次 空《=2次 Numeric end_time(0.1456); // 下午14:56 注意夜盘时间>0.1456 例如0.2100 所以下面要剔除夜盘时间去平仓 日内代码Vars Series<Numeric> bar_in_day; //也是计数器 Series<Numeric> highest_in_day; Series<Numeric> lowest_in_day; Series<Numeric> trade_count; // 计算数量状态变量 状态这种用序列变量Series 只要配合图标信号的条件中 都给写成序列变量Series 不要写成global(会出问题的)特别是做计数器Defs //此处添加公式函数 Events //此处实现事件函数 //初始化事件函数,策略运行期间,首先运行且只有一次 OnInit() { } //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组 OnBar(ArrayRef<Integer> indexs) { //策略:开盘30分钟内,找到最高价和最低价,构造为当天的轨道。 //按交易时间定统计开始时间 //if(truedate(0)<>truedate(1)) // if(time== 0.21)按照自定义时间开始统计 if(truedate(0)<>truedate(1)) // 怀疑问题点??? { bar_in_day = 0; //bar日期表示同一天 则开始是当天的第1根bar highest_in_day = high; lowest_in_day = Low; trade_count = 0; // 每天一开盘对交易次数trade_count重置为0 } bar_in_day = bar_in_day + 1; //计算器 Commentary("当天第几根bar:"+text(bar_in_day)); If(bar_in_day<=length) //length=30时 开盘前30m 最高最低 即使为30m后创新高新低 也不会更新 { highest_in_day = max(highest_in_day,high); //?如果当前high是开盘30m的最高的high 自己与自己比 还是取high 好像没啥问题 lowest_in_day = min(lowest_in_day,Low); } PlotNumeric("highest_in_day",highest_in_day); PlotNumeric("lowest_in_day",lowest_in_day); //突破上轨做到,突破下轨做空,交易次数不超过3次 //当不在多头仓位,且价格突破当天最高轨道,且当前bar数大于指定长度时开多仓 // 当处于多头仓位,且价格跌破上轨减去一定价差时平多仓 // 平仓写前面 开仓写后面 防止一根bar上又开又平 If(MarketPosition == 1 and low <= highest_in_day - stoppoint * minmove * pricescale) // stoppoint止损 10跳止损 { sell(1, min(open, highest_in_day - stoppoint * minmove * pricescale)); } // 当处于空头仓位,且价格涨破下轨加上一定价差时平空仓 If(MarketPosition == -1 and high >= lowest_in_day + stoppoint * minmove * pricescale) { buytocover(1, max(open, lowest_in_day + stoppoint * minmove * pricescale)); } If(MarketPosition <> 1 and high >= highest_in_day and bar_in_day > length and trade_count<=trade_limit and time<end_time) //开仓设置计数器 及开仓次数限制 ?老师这里没有等于=就是<2 //发单不能在平仓时间后 那种日内只开了1次或1次空 没超2次多开仓限制及2次空开仓限制 { buy(1, max(open, highest_in_day)); trade_count = trade_count + 1; } // 当不在空头仓位,且价格跌破当天最低轨道,且当前bar数大于指定长度时开空仓 If(MarketPosition <> -1 and low <= lowest_in_day and bar_in_day > length and trade_count<=trade_limit and time<end_time) //开仓设置计数器 及开仓次数限制 ?老师这里没有等于=就是<2 { sellshort(1, min(open, lowest_in_day)); trade_count = trade_count + 1; } Commentary("trade_count:"+text(trade_count)); Print("trade_count:"+text(trade_count)); // 这2个多空平仓写前面防止一根bar上又开仓 有平仓 //休市前 全部平仓 If(time>=end_time and time<0.15) { buytocover(0,open); sell(0,open); } }//------------------------------------------------------------------------// 编译版本 2025/04/14 2stoppoint459// 版权所有 tb282723// 更改声明 TradeBlazer Software保留对TradeBlazer平台// 每一版本的TradeBlazer公式修改和重写的权利//------------------------------------------------------------------------

如果你想发代码,上面这个代码模式点一下,把代码贴进去

回复:出现的问题,截图说明配合品种,周期设置等关键信息也说一下你这个里的 if(truedate(0)<>truedate(1))主要作用就是隔日后,重置一些变量,既然你是做日内,那么是合理