MACD_Cross_Alert.mq4
下記、MACDのプログラム、私としてはMACDライン、シグナルラインともにEMAを使いたいのですが、プログラムのどこがおかしいのか、EMAのMACD(Alertなし)と比べると全然表示が違います。どなたか詳しい方、変更の仕方を教えてください。(プログラムがわからないのでどこがおかしいのか・・・)
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_width1 2
#property indicator_color2 Red
#property indicator_width2 2
#property indicator_level1 0
#property indicator_levelcolor White
//---- input parameters
extern int fast_Period = 12;
extern int slow_Period = 26;
extern int signal_Period = 9;
extern string AlertSound = "alert.wav";
//---- buffers
double Buffer1[];
double Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{ //---- indicators
SetIndexStyle(0,DRAW_LINE,1,2);
SetIndexBuffer(0,Buffer1);
SetIndexLabel(0,"Main");
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Buffer2);
SetIndexLabel(1,"Signal");
//----
return(0);}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{int counted_bars = IndicatorCounted();
int limit = Bars - counted_bars;
for(int i=0; i < limit; i++)
{Buffer1[i] = iMACD(NULL, 0, fast_Period, slow_Period,signal_Period, PRICE_CLOSE,MODE_MAIN , i);
Buffer2[i] = iMACD(NULL, 0, fast_Period, slow_Period,signal_Period, PRICE_CLOSE,MODE_SIGNAL , i); }
if(Buffer1[1] < Buffer2[1] && Buffer1[0] > Buffer2[0])
{ PlaySound(AlertSound); ObjectDelete("BuySignal");
ObjectCreate("BuySignal",OBJ_ARROW,0 ,Time[0] ,Low[0]-10*Point);
ObjectSet("BuySignal",OBJPROP_ARROWCODE, 217);
ObjectSet("BuySignal",OBJPROP_COLOR, Blue); }
else if(Buffer1[1] > Buffer2[1] && Buffer1[0] < Buffer2[0])
{PlaySound(AlertSound); ObjectDelete("SellSignal");
ObjectCreate("SellSignal",OBJ_ARROW,0 ,Time[0] ,High[0]+10*Point);
ObjectSet("SellSignal",OBJPROP_ARROWCODE, 218);
ObjectSet("SellSignal",OBJPROP_COLOR, Red); }
//Comment ("MAIN: ",Buffer1[0]," / SIGNAL: ",Buffer2[0]);
return(0);}
//+------------------------------------------------------------------+