Download MetaTrader 5

buffers slowing down indicator?

To add comments, please log in or register
Stephen Reynolds
6750
Stephen Reynolds  


Hi, in the full code attached and segment below I don't understand why it takes a long time to load when placed onto the 5m and 1m chart but is okay on the larger charts? 

Reference says that it might be something to do with too many physical memory locations? But I'm not sure?

   for(int i=limit; i>=1; i--)
   {
      //+------------------------------------------------------------------+
      // DMI
      //+------------------------------------------------------------------+  
      double adx1 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_MAIN,i);
      double minusdi1 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_MINUSDI,i);
      double plusdi1 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_PLUSDI,i);
      double adx2 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_MAIN,i+1);
      double minusdi2 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_MINUSDI,i+1);
      double plusdi2 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_PLUSDI,i+1);
        
      AvgADX[i] = adx1;    // WHY WHEN I PLACE ON 1HR ITS OKAY BUT 5M IT TAKES ITS TIME
                              // might be something to do with too many physical memory locations
                                    
      double AVGADX = iMAOnArray(AvgADX,0,MaADXPeriod,0,MaADXMethod,i); // calculates the ma of data stored in array
      double AVGADXNorm = NormalizeDouble(AVGADX,1);
      
      AvgADXLine[i]=AVGADXNorm;
   }
Files:
Carl Schreiber
7301
Carl Schreiber  
It may depend on the avalable bars. Check Bars and then check with reduced limit:

for(int i=limit/2; i>=1; i--) ...
whroeder1
15934
whroeder1  
  1.    for(int i=limit; i>=1; i--)
    Why didn't you show how limit is calculated? See How to do your lookbacks correctly, which includes how to update the indicator in groups.
  2.       double minusdi1 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_MINUSDI,i);
          double plusdi1 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_PLUSDI,i);
          double adx2 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_MAIN,i+1);
          double minusdi2 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_MINUSDI,i+1);
          double plusdi2 = iADX(_Symbol,_Period,ADXPeriod,DMIPrice,MODE_PLUSDI,i+1);
    Why are you getting those values when you don't use them?
  3.       double AVGADXNorm = NormalizeDouble(AVGADX,1);
    Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
    In this case IndicatorDigits - Custom Indicators - MQL4 Reference



To add comments, please log in or register