一款非常适合做趋势交易的指标源码分享
这是一个 144EMA + 改良 HA 平均 K 线 + 趋势反转提醒 的稳定趋势指标,优点是信号干净、不骗线、自动提醒、简单易用。
它的核心优点:
趋势判断非常清晰,不反复骗线,用 144 大周期均线做基础,过滤了小波动噪音,只显示大方向趋势,不会频繁多空切换,红绿柱子一眼看多空,新手也能看懂,这个指标用均线合成 HA,趋势延续性更强,自带趋势反转提醒,不用盯盘,可开启手机推送通知!
源码分享:
#property copyright "浪人ea"#property indicator_chart_window#property indicator_buffers 4#property indicator_color1 DarkOrange#property indicator_color2 Turquoise#property indicator_color3 Magenta#property indicator_color4 Lime//---- parametersextern ENUM_MA_METHOD Ma_Method=MODE_EMA;extern int Ma_Period=144;extern int Ma_Shift=0;extern bool PushNotification=true;extern bool PushAlert=true;//---- buffersdouble ExtMapBuffer1[];double ExtMapBuffer2[];double ExtMapBuffer3[];double ExtMapBuffer4[];//----int ExtCountedBars=0;//+------------------------------------------------------------------+//| Custom indicator initialization function |//|------------------------------------------------------------------|intinit(){//---- indicatorsSetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, DarkOrange);SetIndexBuffer(0, ExtMapBuffer1);SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, Turquoise);SetIndexBuffer(1, ExtMapBuffer2);SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, Magenta);SetIndexBuffer(2, ExtMapBuffer3);SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, Lime);SetIndexBuffer(3, ExtMapBuffer4);//----//SetIndexDrawBegin(0,5);//---- indicator buffers mappingSetIndexBuffer(0,ExtMapBuffer1);SetIndexBuffer(1,ExtMapBuffer2);SetIndexBuffer(2,ExtMapBuffer3);SetIndexBuffer(3,ExtMapBuffer4);//---- initialization donereturn(0);}//+------------------------------------------------------------------+//| Custor indicator deinitialization function |//+------------------------------------------------------------------+intdeinit(){//---- TODO: add your code here//----return(0);}//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intstart(){double maOpen, maClose, maLow, maHigh;double haOpen, haHigh, haLow, haClose;if(Bars<=10) return(0);ExtCountedBars=IndicatorCounted();//---- check for possible errorsif (ExtCountedBars<0) return(-1);//---- last counted bar will be recountedif (ExtCountedBars>0) ExtCountedBars--;int pos=Bars-ExtCountedBars-1;while(pos>=0){maOpen=iMA(NULL,0,Ma_Period,Ma_Shift,(int)Ma_Method,(int)MODE_OPEN,pos);maClose=iMA(NULL,0,Ma_Period,Ma_Shift,(int)Ma_Method,(int)MODE_CLOSE,pos);maLow=iMA(NULL,0,Ma_Period,Ma_Shift,(int)Ma_Method,(int)MODE_LOW,pos);maHigh=iMA(NULL,0,Ma_Period,Ma_Shift,(int)Ma_Method,(int)MODE_HIGH,pos);//----haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;haClose=(maOpen+maHigh+maLow+maClose)/4;haHigh=MathMax(0, MathMax(haOpen, haClose));haLow=MathMin(150000, MathMin(haOpen, haClose));if (haOpen<haClose){ExtMapBuffer1[pos]=haLow;ExtMapBuffer2[pos]=haHigh;if (pos==0 && ExtMapBuffer3[pos+1]>ExtMapBuffer4[pos+1])alert_sig("Color change to Green");}else{ExtMapBuffer1[pos]=haHigh;ExtMapBuffer2[pos]=haLow;if (pos==0 && ExtMapBuffer3[pos+1]<ExtMapBuffer4[pos+1])alert_sig("Color change to Red");}ExtMapBuffer3[pos]=haOpen;ExtMapBuffer4[pos]=haClose;pos--;}//----return(0);}//+------------------------------------------------------------------+voidalert_sig(string comstr){//----static datetime lastDt=0;if (lastDt!=Time[1]){string body="["+Symbol()+"_"+IntegerToString(Period())+"]"+comstr+"!!!";if (PushAlert) Alert(body);if (PushNotification) SendNotification(body);}lastDt=Time[1];}
夜雨聆风