Use CopyClose or CopyRates. Even better you can use the stardard library's higher lever abstractions to avoid creating bugs and drastically reduce development time.
#include <indicators/indicators.mqh> CIndicators g_indicators; CiRSI *g_rsi; CiClose *g_close; int OnInit() { g_close = new CiClose(); g_rsi = new CiRSI(); bool setup = ( g_close.Create(_Symbol, PERIOD_CURRENT) && g_rsi.Create(_Symbol, PERIOD_CURRENT, 21, PRICE_CLOSE) && g_indicators.Add(g_close) && g_indicators.Add(g_rsi) ); if (!setup) return INIT_FAILED; return INIT_SUCCEEDED; } void OnTick() { g_indicators.Refresh(); if (g_close.GetData(0) > g_close.GetData(1) && g_rsi.Main(0) > g_rsi.Main(1)) { Comment("Direction up"); } else if (g_close.GetData(0) < g_close.GetData(1) && g_rsi.Main(0) < g_rsi.Main(1)) { Comment("Direction down"); } else { Comment("Direction unknown"); } }
nicholi shen:
This is exactly what I was looking for, thank you!!!
Use CopyClose or CopyRates. Even better you can use the stardard library's higher lever abstractions to avoid creating bugs and drastically reduce development time.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hello, I have been trying to get the price in an array like I have managed to do with the RSI. I can only seem to get the current price, but I would like to call it with price[i]. Is this possible?