Indicator Running Very Slow

M M
26
M M  
I'm attempting to convert this WAE (Waddah Attar Explosion) to MT5. I ran it through the fxdreema converter and it looks run and paint new candles, but it isn't painting previous candles and it runs extremely slow. Am I missing something obvious? I'm new to mql5.
William Roeder
24607
William Roeder  
      Trend1=(iMACD(NULL, Minutes, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, y) -
                iMACD(NULL, Minutes, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, y + 1

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

M M
26
M M  
William Roeder:

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

Thanks for the reply I really appreciate it. Seems as though the code you posted is from the mql4 but left out the closing parenthese and multiplying of the result. The full code is this for everyone wondering:

Trend1=(iMACD(NULL, Minutes, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, y) -
                iMACD(NULL, Minutes, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, y + 1))*Sensetive;

But what you said is a good idea. A handle to the correct place in the indicator buffer is better than redoing the math in OnTick. I'll be sure to use that information in the future. In any case, it seems as though this mql5 version performs identical to this one. I had downloaded it before and it looked off, but I just needed to change the indicator settings. God bless.

Waddah Attar Explosion
Waddah Attar Explosion
  • www.mql5.com
The indicator shows the moments of the market acceleration. Besides, it indicates appropriate time for buying, selling and market exit.
William Roeder
24607
William Roeder  
M M: The full code is this for everyone wondering:
Trend1=(iMACD(NULL, Minutes, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, y) -
                iMACD(NULL, Minutes, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, y + 1))*Sensetive;

That is MQL5 babel. It is not doing what you think it is. [Likely (10-11)*Sensetive.] Read the manual you must.

M M
26
M M  
William Roeder:

That is MQL5 babel. It is not doing what you think it is. [Likely (10-11)*Sensetive.] Read the manual you must.

Not sure what you mean by MQL5 babel. That is the code from the mq4 file. In any case, Waddah Attar wrote the mql4 version. I don't plan on changing it. I'm aware iMACD returns an int. But the output buffer gives correct values. I don't know why he is multiplying what seems to be an index by sensetive either. Seems to write to an indicator buffer using Trend1 as well.


      if(Trend1>=0)
         ind_buffer1[i]=Trend1;
      if(Trend1 < 0)
         ind_buffer2[i]=(-1*Trend1);
Files:
WAE2.PNG  26 kb
lippmaje
1658
lippmaje  

Of course it's running slow. This creates the indicator handle anew on every tick:

double  iCustMACD( 
        string             symbol,
        ENUM_TIMEFRAMES    timeframe,
        int                fast_ema_period,
        int                slow_ema_period,
        int                signal_period,
        ENUM_APPLIED_PRICE applied_price,
        int                mode,
        int                shift
)
{
        applied_price++; // Fix, because all ENUM_APPLIED_PRICE in MQL5 are +1
        int handle = iMACD(symbol, timeframe, fast_ema_period, slow_ema_period, signal_period, applied_price);

        return fxd_Indicator(handle, mode, shift);
}

Crap conversion. They could have done better here.

Better learn MQL5 and do it yourself or make it a job.