Limit bars used for an indicator?
Limit bars used for an indicator?
Loading saved threads...
Owen · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Owen
Original post: https://stackoverflow.com/questions/67383097
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/67390290
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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));
//---
}
Quote
Report
Post Reply
Checking account access…