怎么判断当前K线是当前交易日的最后一根K线?
If(TradingCloseDateTime(Symbol,MakeDateTime(date,time)) == TradingEndDatetime)
{
Commentary(\"这个bar就是收盘前最后一个bar\");
}
这个对,厉害,点赞
写一个计数器,计算出现过的日内根数最大值。只要bar数到达这个最大值那就是最后一根了
在节假日时,没有夜盘,计数就不准了
//想到这个方式,但也有问题,就是在五一、国庆节假日时,突然出现一天没有夜盘的情况,就不准了,有没有什么办法可以解决?
Events
OnBar(ArrayRef<Integer> indexs)
{
Numeric barCount1 = BarsSinceToday() + 1;
if(barCount1 == DayBarsNumI(0, 1))
{
Commentary(\"当天最后一根K线\");
}
Commentary(\"barCount1:\"+text(barCount1));
Commentary(\"DayBarsNumI:\" + Text(DayBarsNumI(0, 1)));
}