|
迴圈解析
Counter = 0
Value1 = Counter*StepGap = 0 * 100 = 0
RangeHigh[Counter] = Highest(High,LookBack)[Value1] --> RangeHigh[0] = Highest(High,100)[0] {最近 100根}
Counter = 1
Value1 = Counter*StepGap = 1 * 100 = 100
RangeHigh[Counter] = Highest(High,LookBack)[Value1] --> RangeHigh[1] = Highest(High,100)[100] {往前100根K棒位置的最近 100根內最高價}
Counter = 2
Value1 = Counter*StepGap = 2 * 100 = 200
RangeHigh[Counter] = Highest(High,LookBack)[Value1] --> RangeHigh[1] = Highest(High,100)[200] {往前200根K棒位置的最近 100根內最高價}
同理 .....
Counter = 9
Value1 = Counter*StepGap = 9 * 100 = 900
RangeHigh[Counter] = Highest(High,LookBack)[Value1] --> RangeHigh[1] = Highest(High,100)[900] {往前900根K棒位置的最近 100根內最高價}
這樣就取得從目前位置開始 ,每間隔 100根位置 ,區間100根K棒的最高價 ,然後BarNumber每次變動 ,就會重新再計算一次
如果在特定時間K棒記錄後 ,就固定下來 ,不要再隨著 BarNumber移動而變動 Ex 30分K , 2016/3/1 , 11:45 當根作基準
if date = 1160301 and time = 1145 then begin
For Counter = 0 to 9 Begin
Value1 = Counter*StepGap;
RangeHigh[Counter] = Highest(High,LookBack)[Value1] ;
end ;
end ;
那麼 2016/3/1 11:45 以後的K棒 ,都可以從陣列中取得相同的區間最高價
|
|