對交易開拓者(TB)中的序列變量有點疑惑,於是寫了一個測試用例:
測試代碼如下:
Params
Vars
NumericSeries SeriesVal;
Begin
//init variables when first bar comes
If(BarStatus == 0){
SeriesVal=0;
SetGlobalVar(0,1);
}Else{
PlotNumeric("Close:",Close,Yellow);
SeriesVal=SeriesVal+1;
PlotNumeric("SeriesVal:",SeriesVal,Yellow);
PlotNumeric("CurrentBar",CurrentBar);
PlotNumeric("GlobalVal:",GetGlobalVar(0));
SetGlobalVar(0,GetGlobalVar(0)+1);
}
End
但是SeriesVal=SeriesVal+1;這個代碼似乎不是根據每次tick執行一次,而是根據每個bar執行一次;
這個很容易混淆,我第一眼的感覺是SeriesVal和GlobalVal會一樣,但是實際的結果是不一樣的