MACDPredicter - Indicator mod - help needed

kris82wt

Trader
Nov 28, 2020
26
2
19
42
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

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:

Enivid

Administrator
Staff member
Nov 30, 2008
18,595
1,366
144
Odesa
www.earnforex.com
Is it really a script? Looks like an indicator. Also, it uses another custom indicator in its code - "DiNapoli MACD".
One possible reason for the differences could also be the use of EMAs - exponential moving averages retain "memory" of even the first bar they have been applied to. So, if on one broker, your data starts at 2020.01.01 and another one it starts on 2019.01.01, you might get different values in two same-period EMAs for yesterday.
 

kris82wt

Trader
Nov 28, 2020
26
2
19
42
Is it really a script? Looks like an indicator. Also, it uses another custom indicator in its code - "DiNapoli MACD".
One possible reason for the differences could also be the use of EMAs - exponential moving averages retain "memory" of even the first bar they have been applied to. So, if on one broker, your data starts at 2020.01.01 and another one it starts on 2019.01.01, you might get different values in two same-period EMAs for yesterday.
Yes, it's based on MACD. I don't mean small discrepancies, but huge one. MACD should give similar buy/sell signals since it's averaging from many values. From broker to broker you will get similar signals, not opposite which is here problem. I believe it's some coding issue.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,595
1,366
144
Odesa
www.earnforex.com
It is rather difficult to come up with a code that will produce dramatically different results on the same pairs of different brokers with only minor discrepancies in the charts.

By the way, how is this indicator called?