0
votes

Trying to find a way to limit the amount of bars the EA is looking at for the indicator Ichimoku Kinko Hyo, its looking at a silly amount of bars and erroring as not enough memory.

I have tried going into options and setting the max bars on chart and in history to 5000 but its not working.

Is there a way I can code this into the script to only use the last x amount of bars for the indicator?

2021.05.04 11:29:03.007 Not enough memory for 7994468 bars for indicator Ichimoku Kinko Hyo (USDJPY,M1)

the code is just pulling out the value for the senkou A and B lines;

SenkouA   =   NormalizeDouble(iIchimoku(Symbol(),PERIOD_CURRENT,9,26,52,MODE_SENKOUSPANA,0),_Digits);  //value of senkouspanA at current candle

and same again but for span B

2
Can you share your full code. The line of code you have shared would not produce the error you mention.PaulB

2 Answers

0
votes

Yeah sure, just starting off really, trying too get it to store the value of the top and bottom of the sumo cloud before I move onto the next bits.

It works fine on strategy tester, but when I put it on a live chart it comes up with the error above, I assumed its because on strategy tester it only has the last bars that have been played, but on a live chart it has all the brokers history right? :

double SenkouA;     
double SenkouB;
double Kumo_top;
double Kumo_btm;

void OnTick()
  {

SenkouA   =   NormalizeDouble(iIchimoku(Symbol(),PERIOD_CURRENT,9,26,52,MODE_SENKOUSPANA,0),_Digits);  //value of senkouspanA at current candle
SenkouB   =   NormalizeDouble(iIchimoku(Symbol(),PERIOD_CURRENT,9,26,52,MODE_SENKOUSPANB,0),_Digits);  //value of senkouspanB at current candle

Kumo_top  =   MathMax(SenkouA,SenkouB);
Kumo_btm  =   MathMin(SenkouA,SenkouB);



Comment ("SenkouA = "         + SenkouA          + "\n" +
         "SenkouB = "         + SenkouB)

}
0
votes

Try the following code (note this is an EA and should be in the Experts folder).

//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
//---
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
//---
   double SenkouA=iIchimoku(NULL,0,9,26,52,MODE_SENKOUSPANA,0);
   double SenkouB=iIchimoku(NULL,0,9,26,52,MODE_SENKOUSPANB,0);
   double Kumo_top=MathMax(SenkouA,SenkouB);
   double Kumo_btm=MathMin(SenkouA,SenkouB);
   Comment ("SenkouA = "+DoubleToStr(SenkouA,Digits)+"\n"+"SenkouB = "+DoubleToStr(SenkouB,Digits));
//---
}