利用plot 劃出符號

  •   195 
  • 最後發表   Alex嘉  2023 四月 08
Alex嘉 發文於   2023/04/06

想請問一下

我想要利用 plot 來畫出 達成我的兩個條件的點位 劃出一個符號,

比如說 J>K 且也 J>D 的地方,請問是要怎樣寫呢?

出現錯誤左右兩邊型態不同,是因為J已經被拿去計算了嗎?

 

 

// XQ: KDJ指標

//

input: Length(9), RSVt(3), Kt(3), JType(0);

variable: rsv(0), k(0), _d(0), j(0),Z(0);

 

SetInputName(1, "天數");

SetInputName(2, "RSVt權數");

SetInputName(3, "Kt權數");

 

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

 

 

if JType = 0 then

j = 3 * k - 2 * _d

else

j = 3 * _d - 2 * k;

 

 

 

 

 

// XQ: MACD指標

//

input: FastLength(12), SlowLength(26), MACDLength(9);

variable: price(0);

 

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

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

SetInputName(3, "MACD天數");

 

price = WeightedClose();

 

Value1 = XAverage(price, FastLength) - XAverage(price, SlowLength);

Value2 = XAverage(Value1, MACDLength) ;

Value3 = Value1 - Value2 ;

 

// 前面區段資料變動較大, 先不繪出

//

if CurrentBar <= SlowLength then

begin

Value1 = 0;

Value2 = 0;

Value3 = 0;

end;

 

value10= j >_d ;

 

Plot1(Value1, "DIF");

Plot2(Value2, "MACD");

Plot3(Value3, "Osc");

Plot4(j, "J(%)");

 

plot5 ( value10,"交叉")

排序方式: 標準 | 最新
GammaCEO 發文於   2023/04/06

你應該寫成

if j>_d then
plot5(j,"交叉")
else
noPlot(5);

 

Alex嘉 發文於   2023/04/08

謝謝!謝謝大神!

 

發表回覆
Close