周期突破
我要的就是 1 分钟K线为基础,前面 30 秒的最高价,如果后 30 秒内突破前面最高价就确认下单【比如1分钟的34秒,前30秒最高价100,34秒刚好突破100.那么就直接下单】这个我是用1分钟周期还是TICK。但是我不管2个怎么写。都是错误的。还请大师解惑
我要的就是 1 分钟K线为基础,前面 30 秒的最高价,如果后 30 秒内突破前面最高价就确认下单【比如1分钟的34秒,前30秒最高价100,34秒刚好突破100.那么就直接下单】这个我是用1分钟周期还是TICK。但是我不管2个怎么写。都是错误的。还请大师解惑
Params Numeric qty(1); Vars Numeric firstHigh; // 前30秒最高价 Numeric barStartTime; // 当前1分钟bar的起始时间 Bool done; // 本根bar是否已下过单 Events OnBar(ArrayRef<Integer> indexes) { // 每根1分钟bar开始时重置 firstHigh = -999999; done = false; barStartTime = Time(); // 当前bar的起始时间 } OnTick() { Numeric sec = (Time() - barStartTime) * 100000; // 换算成秒,按实际时间格式调整 Numeric h = H(); // Tick时为当时的委卖价 if (sec <= 30) { // 前30秒:不断刷新最高价 if (h > firstHigh) firstHigh = h; } else { // 后30秒:突破前30秒最高价即下单 if (!done and firstHigh > -999999 and h > firstHigh) { Buy(qty, h); done = true; } } }试一试呢