Hi everyone,
I'm using MQL5 for a quiet of time. I'm encountering a problem in which the iteration of Oncalculate block itself never ends!
I call a custom indicator with 5 buffers then use the buffer to suggest if its good to open a trade position or not (on my market watch),
prior to the utilization of IndicatorRelease metatrader wasused to used huge amount of RAM, so I tried IndicatorRelease. and this is the code
can any one help on this?
Try moving these lines to global scope:
int indcdef1=0[]; int indcdef2=0[];
Move these lines to OnInit():
ArrayResize(indcdef1, ArraySize(marketWatchSymbolsList)); ArrayResize(indcdef2, ArraySize(marketWatchSymbolsList)); for(int i=0;i<100;i++) { indcdef1[i] = iCustom (marketWatchSymbolsList[i],_Period,"bks\\bks-efficiency","",Mi,risk,0,"no",PRICE_CLOSE); indcdef2[i] = iCustom (marketWatchSymbolsList[i],_Period,"bks\\bks-efficiency","",2*Mi,risk,0,"no",PRICE_CLOSE); }
CopyBuffer(indcdef1[i],0,0,1,rsi1); CopyBuffer(indcdef1[i],1,0,1,rsi2); CopyBuffer(indcdef1[i],2,0,1,rsi3); CopyBuffer(indcdef1[i],3,0,1,rsi4); CopyBuffer(indcdef1[i],4,0,5,rsi5); CopyBuffer(indcdef2[i],2,0,3,rsi31); CopyBuffer(indcdef2[i],3,0,3,rsi41);
(highlighted parts are new additions)
And remove IndicatorRelease(). Lastly, note that you're computing every tick. .. that wastes time - check out https://www.mql5.com/en/articles/159 as an example on how to do things every bar, rather than tick, if possible.
Speed should improve, but check whether your memory consumption is acceptable.
See what happens to your memory consumption.
- www.mql5.com
Try moving these lines to global scope:
Move these lines to OnInit():
(highlighted parts are new additions)
And remove IndicatorRelease(). Lastly, note that you're computing every tick. .. that wastes time - check out https://www.mql5.com/en/articles/159 as an example on how to do things every bar, rather than tick, if possible.
Speed should improve, but check whether your memory consumption is acceptable.
See what happens to your memory consumption.
WOW!
that is a good design, thanks,
It's not clear for me why your method solve the iteration of Oncalculate block!
by the way, the Memory issue is still there and i had to use IndicatorRelease() which really helps to reduce memory usage,
Regards from Iran.
WOW!
that is a good design, thanks,
It's not clear for me why your method solve the iteration of Oncalculate block!
by the way, the Memory issue is still there and i had to use IndicatorRelease() which really helps to reduce memory usage,
Regards from Iran.
When you have iCustom() and ReleaseIndicator() within OnCalculate(), the indicators are being created and released repeatedly every tick, which consumes time. That likely "blocked" your OnCalculate().
IndicatorRelease() should not be used for the sole purpose of reducing memory usage unless you don't need the indicator in all future ticks (which is not your case). So if memory is really an issue, try reducing [Tools->Options->Max bars in chart] instead, or check that your custom indicator is not wasting memory unnecessarily.
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I'm using MQL5 for a quiet of time. I'm encountering a problem in which the iteration of Oncalculate block itself never ends!
I call a custom indicator with 5 buffers then use the buffer to suggest if its good to open a trade position or not (on my market watch),
prior to the utilization of IndicatorRelease metatrader wasused to used huge amount of RAM, so I tried IndicatorRelease. and this is the code
can any one help on this?