out of memory for custom indicator using iCustom

 

Hello, I would like to ask if has anyone encounter this problem and been able to fix this? 

I am trying to read signals from a custom indicator, however, it caused out of memory, I believe that there are bugs in my code but I still do not know how to fix this. The custom indicator I am using here is [redacted]

This is the simple code to reproduce problems

input double MaxSpread = 20;

input double LotSize = 0.1;                 // Initial lot size
input double PartialClosePercentage = 50;  // Percentage to close at TP1
input double DCA_LotMultiplier = 2;        // Lot multiplier for DCA
input int MaxDCAOrders = 5;                // Maximum DCA orders

// Indicator parameters
input string IndicatorName = "[redacted]";
input int IndicatorPeriod = PERIOD_CURRENT;             // Timeframe of the indicator

input int iPeriod = 10;                     // Period of the indicator
input double RangeFilter = 2.0;            // Range filter
input string StopLossMode = "Recent Swing"; // Stop loss mode
input double TakeProfitFactor = 2.0;       // Take profit factor
input int MaximumHistoryBars = 500;       // Maximum history bars

// Indicator buffer indices 
int BufferBuy = 0;
int BufferSell = 1;
int BufferTP1 = 6;
int BufferTP2 = 7;
int BufferSL = 8;
double SuccessRate = 28;
int shift = 1;

void OnTick()
  {
//---
   
   double current_spread = CalculateSpread(Ask, Bid);
   IsGreaterThanMaxSpread(current_spread, MaxSpread);
   
   static int lastSignalTime = 0;
   
   // Read indicator signals
   double buySignal  = iCustom(NULL, IndicatorPeriod, IndicatorName, 
                            iPeriod, RangeFilter, TakeProfitFactor, MaximumHistoryBars, 
                            BufferBuy, shift);

   double sellSignal = iCustom(NULL, IndicatorPeriod, IndicatorName, 
                               iPeriod, RangeFilter, TakeProfitFactor, MaximumHistoryBars, 
                               BufferSell, shift);
   
   double tp1Price   = iCustom(NULL, IndicatorPeriod, IndicatorName, 
                               iPeriod, RangeFilter, TakeProfitFactor, MaximumHistoryBars, 
                               BufferTP1, shift);

   
   if(buySignal > 0)
     {
      Print("Buy Signal: ", buySignal, ", Sell Signal: ", sellSignal, ", TP1: ", tp1Price);
     }

  }
 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

Please note that discussing specific products or signals is not allowed on the forum. Here in the forum, we can only discuss the general aspects, but for specifics you need to ask the seller for support, by writing in the "Comments" section of that specific product or signal or contact the author in private.