Hi guys,
I need your help with the indicator. On some broker platforms it works fine, but on some gives different results. I don't know if it's because different time zone, or something else (I don't refer to difference with trading weekends for crypto). I will be very greatful if somebody could check what can cause issues. Another request is to add another (choosen by user) timeframe value of indicator
I need your help with the indicator. On some broker platforms it works fine, but on some gives different results. I don't know if it's because different time zone, or something else (I don't refer to difference with trading weekends for crypto). I will be very greatful if somebody could check what can cause issues. Another request is to add another (choosen by user) timeframe value of indicator
MQL4:
//---- indicator settings #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Silver #property indicator_width1 1 //---- indicator parameters extern double FastEMA=8.3896; extern double SlowEMA=17.5185; extern double SignalEMA=9.0503; //---- indicator buffers double Price[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_LINE,STYLE_DOT); SetIndexDrawBegin(0,FastEMA); //---- indicator buffers mapping SetIndexBuffer(0,Price); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalEMA+")"); SetIndexLabel(0,"MACP"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Moving Averages Convergence/Divergence | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars - counted_bars; //---- macd counted in the 1-st buffer for(int i=0; i<limit; i++) { Price[i]=(-1.0)*1.0/((FastEMA-SlowEMA)*2*(1.0-2.0/(SignalEMA+1.0)))*(FastEMA+1.0)*(SlowEMA+1.0)*( (2.0/(SignalEMA+1.0)-1.0)*(iMA(NULL,0,FastEMA,0,1,PRICE_CLOSE,i+1)*(1.0-2.0/(FastEMA+1.0))-iMA(NULL,0,SlowEMA,0,1,PRICE_CLOSE,i+1)*(1.0-2.0/(SlowEMA+1.0)))+iCustom(NULL,0,"DiNapoli MACD",FastEMA,SlowEMA,SignalEMA,false,1,i+1)*(1-2.0/(SignalEMA+1.0))); double predict=(-1.0)*1.0/((FastEMA -SlowEMA)*2*(1.0-2.0/(SignalEMA+1.0)))*(FastEMA+1.0)*(SlowEMA+1.0)*( (2.0/(SignalEMA+1.0)-1.0)*(iMA(NULL,0,FastEMA,0,1,PRICE_CLOSE,0)*(1.0-2.0/(FastEMA+1.0))-iMA(NULL,0,SlowEMA,0,1,PRICE_CLOSE,0)*(1.0-2.0/(SlowEMA+1.0)))+iCustom(NULL,0,"DiNapoli MACD",FastEMA,SlowEMA,SignalEMA,false,1,0)*(1-2.0/(SignalEMA+1.0))); datetime futureBarTime = Time[0]+Period()*60; datetime futureBarTime1 = Time[0]; ObjectCreate("signal1",OBJ_TREND,0,Time[0],Price[0],futureBarTime,predict); ObjectSet("signal1",OBJPROP_COLOR,Gold); ObjectSet("signal1",OBJPROP_RAY,false); ObjectSet("signal1",OBJPROP_STYLE,STYLE_DASH); double predict1=ObjectGet("signal1",OBJPROP_PRICE1); if(predict1<predict||predict1>predict) {ObjectDelete("signal1"); ObjectCreate("signal1",OBJ_TREND,0,Time[0],Price[0],futureBarTime,predict); ObjectSet("signal1",OBJPROP_COLOR,Gold); ObjectSet("signal1",OBJPROP_RAY,false); ObjectSet("signal1",OBJPROP_STYLE,STYLE_DASH); predict1=ObjectGet("signal1", OBJPROP_PRICE1 );} } return(0); } //+------------------------------------------------------------------+
Last edited by a moderator: