变色MA趋势交易与MACD震荡交易利器源码
admin
2023-07-19 07:24:31
0
功能:利用MACD震荡交易,提示金叉与死叉交易点;同时,利用MA进行趋势交易。趋势与震荡两不误。


安装方法:解压后,复制到:MQL4/技术指标使用方面:解压后,复制到:MQL4/技术指标使用方面:1.MACD:MACD幅图2.MA-main:MA主图3.MACD-Cross:MACD金叉,死叉显示与提示例子:

例子:1.MACD:
#property copyright   "Copyright 2017-2019, Nvjan Inc."#property link        "http://www.nvjan.com"#property version     "2.00"#property description "M-Color MACD Indicators "#property strict#property indicator_buffers 6#property indicator_separate_window#property indicator_level1 0#property indicator_color1 White#property indicator_color2 Red#property indicator_color3 Red#property indicator_color4 Lime#property indicator_color5 Yellow#property indicator_color6 Blue//---- buffersdouble Buffer1[];double Buffer2[];double Buffer3[];double Buffer4[];double UP[];double DO[];extern int Fast = 12;extern int Slow = 26;extern int Signal = 9;extern bool Alert_Switch=true;static double SX;//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()  {//---- indicators   //IndicatorBuffers(3);   SetIndexStyle(0,DRAW_LINE,0,1);   SetIndexStyle(1,DRAW_LINE,0,1);   SetIndexStyle(2,DRAW_HISTOGRAM,0,2);   SetIndexStyle(3,DRAW_HISTOGRAM,0,2);   SetIndexStyle(4,DRAW_ARROW);   SetIndexStyle(5,DRAW_ARROW);   SetIndexArrow(4,233);   SetIndexArrow(5,234);   SetIndexBuffer(0,Buffer1);   SetIndexBuffer(1,Buffer2);   SetIndexBuffer(2,Buffer3);    SetIndexBuffer(3,Buffer4);    SetIndexBuffer(4,UP);   SetIndexBuffer(5,DO);   IndicatorShortName("MACD("+Fast+","+Slow+","+Signal+")");   SetIndexLabel(0,"MACD_MAIN");   SetIndexLabel(1,"MACD_SIGNAL");   SetIndexLabel(2,"MAIN-SIGNAL");   SetIndexLabel(3,"MAIN-SIGNAL");   SetIndexLabel(4,"BUY_SIGNAL");   SetIndexLabel(5,"SELL-SIGNAL");   IndicatorDigits(Digits+2);//----   return(0);  }//+------------------------------------------------------------------+//| Custor indicator deinitialization function                       |//+------------------------------------------------------------------+int deinit(){return(0);}//+------------------------------------------------------------------+//| Custom indicator iteration function                              |//+------------------------------------------------------------------+int start()  {   int limit,counted_bars=IndicatorCounted();//---- check for possible errors   if(counted_bars<0) return(-1);//---- last counted bar will be recounted   if(counted_bars>0) counted_bars--;   limit=Bars-counted_bars;   double B_Temp;  //---- main loop   for(int i=0; i=0)      {        Buffer3[i]=B_Temp;        Buffer4[i]=EMPTY_VALUE;      }      else      {        Buffer4[i]=B_Temp;        Buffer3[i]=EMPTY_VALUE;      }     }   for(i=0; iBuffer2[i]  &&  Buffer1[i+1]Buffer2[i+1])       DO[i]=Buffer2[i];      if (Buffer1[i]>Buffer2[i]  &&  Buffer1[i+1]==Buffer2[i+1]  &&  Buffer1[i+2]Buffer2[i+2])       DO[i]=Buffer2[i];     }   if (Alert_Switch==true && Buffer1[0]>Buffer2[0]  &&  Buffer1[1]Buffer2[1] && SX!=Time[0])    {     SX=Time[0];     Alert(Symbol(),"  ",Period(),":","MACD死叉");   }   if (Alert_Switch==true && Buffer1[0]>Buffer2[0]  &&  Buffer1[1]==Buffer2[1]  &&  Buffer1[2]Buffer2[2] && SX!=Time[0])    {     SX=Time[0];     Alert(Symbol(),"  ",Period(),":","MACD死叉");   }//----   return(0);  }//+------------------------------------------------------------------+ 

相关内容