The logic is correct, but opening and releasing the handle inside fRSI() on every call is wasteful, worse on a multi-pair EA where this runs once per symbol per tick. iRSI() returns the same handle if one's already open for that symbol/timeframe/period, but calling IndicatorRelease() right after every read closes it immediately, so the next tick has to rebuild the indicator from scratch. Caching the handle instead avoids that:
int rsiHandles[]; // built once per symbol in OnInit, released once in OnDeinit double fRSI(int handle, int shift) { double buf[1]; if(CopyBuffer(handle, 0, shift, 1, buf) <= 0) return 0; return buf[0]; }
Open each handle once, store it, and only release it in OnDeinit().
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
List of Indicator : https://www.mql5.com/en/docs/indicators/irsi
For example, i made function for RSI. is this right way to use for multi-currency pair EA?