[软件疑问]MT4指標轉換成MT3指標
請問我平時在MT4裡有使用KDJ指標,現在想把它帶入MT3使用,要怎麼用呢? 編碼如下:
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 GreenYellow
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_level1 0
#property indicator_level2 20
#property indicator_level3 80
#property indicator_level4 100
//---- input parameters
extern int nPeriod=9;
extern double factor_1=0.6666666;
extern double factor_2=0.3333333;
//---- buffers
double percentK;
double percentD;
double percentJ;
double RSV;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,percentK);
SetIndexLabel(0, "%K");
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,percentD);
SetIndexLabel(1, "%D");
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,percentJ);
SetIndexLabel(2, "%J");
SetIndexBuffer(3,RSV);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int i, k, num;
double Ln, Hn, Cn;
//----
i = Bars - counted_bars - 1;
num = Bars - nPeriod;
while(i>=0)
{
Cn = iClose(NULL,0,i); Ln = iClose(NULL,0,i); Hn = iClose(NULL,0,i);
for(k=0; k iLow(NULL,0,i+k)) Ln = iLow(NULL,0,i+k);
if (Hn < iHigh(NULL,0,i+k)) Hn = iHigh(NULL,0,i+k);
}
if (Hn-Ln != 0) RSV = (Cn-Ln)/(Hn-Ln)*100; else RSV = 50;
if (i >= num) {
percentK = factor_1 * 50 + factor_2 * RSV;
percentD = factor_1 * 50 + factor_2 * percentK;
} else {
percentK = factor_1 * percentK[i+1] + factor_2 * RSV;
percentD = factor_1 * percentD[i+1] + factor_2 * percentK;
}
percentJ = 3 * percentD - 2 * percentK;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
打開MT3的語言編輯器,到Drawing Custom indicator program properties這部分時,不知道要如何選擇,麻煩指點。
之後是貼上代碼儲存即可吧?
謝謝!