人工下單比較常參考趨勢線…所以寫了一隻小程式來作這樣的工作。任意的輸入二個日期、時間和價格,接著依照這二個日期、時間價格畫出一條趨勢線來…這條趨勢線會一直延伸下去。

兩個點之間是利用 TL_NEW 的方式畫出,而在第二個點之後,則是利用 plot 來畫。也就是說需要計算每根 k 棒的遞減或遞增值出來。

inputs: date1(0), date2(0), time1(0), time2(0), price1(high), price2(high);
vars: barCount(0), tmp_price1(0), tmp_price2(0), inc_price(0);

barCount = barCount + 1;

if date = date1 and time = time1 then begin
tmp_price1 = price1;
barCount = 0;
end;

if date = date2 and time = time2 then begin
tmp_price2 = price2;
inc_price = (tmp_price1 - tmp_price2) / barCount;
barCount = 0;
value1 = TL_NEW(date1, time1, tmp_price1, date2, time2, tmp_price2);
end;

if (date >= date2 and time >= time2) or date > date2 then begin
plot1(tmp_price2 - (inc_price * barCount), "TL");
end
else begin
noplot(1);
end;


需要輸入的有 date1, date2, time1, time2, price1, price2 六個數值。

分別代表了第一個點的日期、第二個點的日期、第一個點的時間、第二個點的時間、第一個點的價格(high, low, open or close)、第二個點的價格。

就可以將二個點之間的連線畫出來了。
arrow
arrow
    全站熱搜

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