無法顯示進場訊號

  •   528 
  • 最後發表   帥哥元  2016 六月 08
帥哥元 發文於   2016/06/07

請問,編譯沒問題,為何主圖疊圖上,沒辦法顯示出進場訊號

是不是有哪邊沒注意到

input: FastLength(12), SlowLength(26), MACDLength(9);  //定義MACD指標變數

input: BBandLength(20), UpperBand(2), LowerBand(2);  //定義布林通道

input: KDLength(9), RSVt(3), Kt(3);  //定義KD指標

variable: price(0);

variable: rsv(0), k(0), _d(0);  //定義KD變數

variable: intrabarpersist position(0); // 目前位置

variable: intrabarpersist entry_price(0); // 最後一次進場的價格

 

SetInputName(1, "DIF短天數");

SetInputName(2, "DIF長天數");

SetInputName(3, "MACD天數");

SetInputName(4, "布林天數");

SetInputName(5, "上軌倍數");

SetInputName(6, "下軌倍數");

SetInputName(7, "KD天數");

SetInputName(8, "RSVt權數");

SetInputName(9, "Kt權數");

 

price = WeightedClose();

 

 

Value1 = XAverage(price, FastLength) - XAverage(price, SlowLength);  //DIF線

Value2 = XAverage(Value1, MACDLength) ;  //MACD線

Value3 = Value1 - Value2 ;  //Osc柱狀體

 

 

if CurrentBar <= SlowLength then

begin

Value1 = 0;

Value2 = 0; 

Value3 = 0;

end;

 

//計算布林上下通道的帶寬大小,帶寬小於20的不考慮

Value4 = bollingerband(Close, BBandLength, UpperBand) - bollingerband(Close, BBandLength, LowerBand);

 

//計算KD

Stochastic(KDLength, RSVt, Kt, rsv, k, _d);

 

condition1 = Value3 > 0 and Value3[1] < 0; //MACD出現第一根紅兵

condition2 = k > k[1]; //K線持續向上

 

if position = 0 then

begin

  if condition1 and condition2 and Value4 > 20 then  //進場邏輯,MACD出現第一根紅兵,K線持續向上,布林上下通道帶寬>20

     begin

       position = 1;

       entry_price = close;

       print("(ENTRY) Date:", Date, " EntryPrice:", entry_price); 

  plot1(low * 0.98, "entry"); 

     end; 

end;

XQ小編 發文於   2016/06/08

您好:

請您進行繪圖樣式設定,將線圖改以點的樣式,秀出買進訊號,如圖

可參考 如何繪製進出場訊號 此網頁有操作說明,供您參考

 

由於您的程式碼,只有寫進場訊號,

所以只會進場一次,圖要捲到最前面,才會看的到買進訊號唷!

 

此外,小編看了您的程式碼,建議您修改一下程式碼,才能順利將指標圖秀出來唷!

請您將您文章的第2行程式碼

input: BBandLength(20), UpperBand(2), LowerBand(2);  //定義布林通道

修改為

input: BBandLength(20), UpperBand(2), LowerBand(-2);  //定義布林通道

原因是,第三個參數,輸入正值時為計算上通道,輸入負值時為計算下通道,

因此改為 LowerBand(-2)。

 

另外,小編發現您的程式碼 bband寬20 與 plot1*0.98 此兩部分參數,

都需要非常針對商品去做調整,不然指標圖可能會無法秀出來。

建議您此部分,將參數使用 input語法 去宣告 ,超連結為該語法說明網頁,

比較好針對商品做參數調整。

 

最後,小編在此提供一個小小的建議,

在進行測試指標腳本有無錯誤時,建議您的繪圖設定樣式,

選擇柱圖的樣式,標示在副圖中,會比較容易查看與偵錯唷!

發表回覆
Close