- www.mql5.com
- Dominique Van: i am trying to find current tick value on the RSI
There is no such thing as a “current tick value on the RSI.” RSI is an indicator. There is only the current RSI value (current bar) and previous bar values. Previous ticks are irrelevant.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem -
RSiHandle = iRSI(_Symbol,PERIOD_M1,14,PRICE_CLOSE); CopyBuffer(RSiHandle,0,1,2,rsi);
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
How to call indicators in MQL5 - MQL5 Articles (2010)
Hi Guys can you please help i am trying to find current tick value on the RSI Here is my code so far:
I suppose you mean the current value of RSI, updated on last tick.
That value is the value of the open bar 0, so you need to use that bar index as starting value in your CopyBuffer statement, not 1.
-
There is no such thing as a “current tick value on the RSI.” RSI is an indicator. There is only the current RSI value (current bar) and previous bar values. Previous ticks are irrelevant
I suppose you mean the current value of RSI, updated on last tick.
That value is the value of the open bar 0, so you need to use that bar index as starting value in your CopyBuffer statement, not 1.
int handle_rsi; double rsi_array[3]; void OnInit(){ handle_rsi = iRSI (NULL, PERIOD_CURRENT, 14, PRICE_CLOSE); EventSetTimer(1);} int cunter=0; void OnTimer(){ cunter++; CopyBuffer(handle_rsi,0,0,3,rsi_array); Comment("rsi_array[0] = ",rsi_array[0],"\n",cunter," sec"); Print("rsi_array[0] = ",rsi_array[0]);}what am i doing wrong?? please read screenshot and remember im Copying Buffer and printing value every single second
it's M1 period btw
Here is the solution:
//+------------------------------------------------------------------+ //| IND_TEST_RP.mq5 | //+------------------------------------------------------------------+ #property version "1.00" #property indicator_chart_window #property indicator_buffers 0 #property indicator_plots 0 //+------------------------------------------------------------------+ //| Declaration of variables | //+------------------------------------------------------------------+ int i_COUNT, i_HANDLE, i_MA_PERIOD, i_START_POS; double db_ARRAY_RSI[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { i_MA_PERIOD = 14; i_HANDLE = iRSI(Symbol(), PERIOD_CURRENT, i_MA_PERIOD, PRICE_CLOSE); i_START_POS = 0; i_COUNT = 1; CopyBuffer(i_HANDLE, 0, i_START_POS, i_COUNT, db_ARRAY_RSI); Comment("db_ARRAY_RSI[0]: ", NormalizeDouble(db_ARRAY_RSI[0], 2)); return(rates_total); } //+------------------------------------------------------------------+
I recommend this article about the CopyBuffer function.
https://www.mql5.com/en/docs/series/copybuffer
If you want to have two values, the previous and the current one, then:
i_COUNT = 2;
Then:
db_ARRAY_RSI[0] // Previous value db_ARRAY_RSI[1] // Current value
- www.mql5.com
Here is the solution:
I recommend this article about the CopyBuffer function.
https://www.mql5.com/en/docs/series/copybuffer
If you want to have two values, the previous and the current one, then:
Then:
- 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 Guys can you please help i am trying to find current tick value on the RSI Here is my code so far: