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.

--------------------------------------------------------------------------------

返回酒吧的數量目前正在評估。

圖表(每欄上的最大數量的酒吧所引用的一項研究顯示,被稱為MaxBarsBack條規定的數量後)被分配了一個數加1,這是每一個連續的酒吧。例如,如果您的MaxBarsBack被設置為10,第 11 欄,第 12 欄CurrentBar數字1 是CurrentBar編號2,並等。
備註
CurrentBar只能用於返回當前柱的數量,例如,您不能使用:

CurrentBar [N]

... 獲得的酒吧Ň酒吧前的條數。但是,您可以得到的酒吧Ň酒吧前的數量(例如,5)使用:

CurrentBar - 5

此外,CurrentBar保留字是相同的的用戶功能BarNumber。,唯一的不同的是,,可以使用BarNumber功能,參考過去的酒吧:

BarNumber [5]

實例
您可以使用CurrentBar以決定多久以前,有一個特殊的情況發生:

如果 條件一 則
值1 = CurrentBar
如果 CurrentBar > 值1 然後
值2 = CurrentBar - 值1 ;

值2將持有的條數發生前條件1。
--------------------------------------------------------------------------------

arrow
arrow
    全站熱搜

    David 發表在 痞客邦 留言(0) 人氣()