想請問一下
我想要利用 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,"交叉")
2 評論