CurrentBar

有關於TS使用、泛Easy Language策略撰寫、績效評估等疑難雜症,都可在此討論。

CurrentBar

文章89578251 發表於 2010年 7月 24日, 09:42

What does it mean by writing CurrentBar=1? Can anyone introduce the reserved word CurrentBar? I can't find the information on it in the documentation.
89578251
 
文章: 5
註冊時間: 2010年 6月 2日, 07:19

Re: CurrentBar

文章varing_cloud 發表於 2010年 7月 24日, 18:51

Returns the number of the bar currently being evaluated.

Each bar on a chart (after the number of bars specified by the Maximum number of bars referenced by a study, known as MaxBarsBack) is assigned a number, which is incremented by 1 with each successive bar. For example, if your MaxBarsBack is set to 10, the 11th bar is CurrentBar number 1, the 12th bar is CurrentBar number 2, and so on.

Remarks
CurrentBar can only be used to return the number of the current bar, for example, you cannot use:

CurrentBar[n]

... to obtain the bar number of the bar n bars ago. However, you can obtain the number of the bar n bars ago (for example, 5) by using:

CurrentBar - 5

Also, the CurrentBar reserved word is the same as the user function BarNumber. The only difference is that you can use the BarNumber function to reference past bars:

BarNumber[5]

Examples
You can use CurrentBar to determine how long ago a particular condition occurred:

If Condition1 then
Value1 = CurrentBar;
If CurrentBar > Value1 then
Value2 = CurrentBar - Value1;

Value2 would hold the number of bars ago Condition1 occurred.
varing_cloud
 
文章: 248
註冊時間: 2009年 10月 12日, 08:23
來自: Taiwan

Re: CurrentBar

文章89578251 發表於 2010年 7月 24日, 19:54

varing_cloud,

Thanks very much. I appreciate your explanation, which is very clear to me.
89578251
 
文章: 5
註冊時間: 2010年 6月 2日, 07:19

Re: CurrentBar

文章varing_cloud 發表於 2010年 7月 24日, 20:57

you are welcome.
varing_cloud
 
文章: 248
註冊時間: 2009年 10月 12日, 08:23
來自: Taiwan


回到 Tradestation與Multi-Chart交易平台

誰在線上

正在瀏覽這個版面的使用者:Google [Bot], Yahoo [Bot] 和 0 位訪客