關於TB的序列變量的一個測試用例

對交易開拓者(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


 我用的數據回測功能,代碼裏每次tick來的時候全局變量都會加1,這個很容易理解;
但是SeriesVal=SeriesVal+1;這個代碼似乎不是根據每次tick執行一次,而是根據每個bar執行一次;
這個很容易混淆,我第一眼的感覺是SeriesVal和GlobalVal會一樣,但是實際的結果是不一樣的

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章