iRSI

 

hi

my code is flowwing...

double d;
//+----------------------------------
int OnInit()
  {
//---
   d=iRSI(Symbol(),Period(),14,PRICE_CLOSE);
   Comment(d);
//---
   return(INIT_SUCCEEDED);
  }
/* result= 10.0 */

in the code above, iRSI function returned 10, but rsi indicator on indicator window is 56.8!!!

in fact; in the code above, every time, iRSI function returned 10, so always d=10.0

what is worng?

i want my code returned yesterday  rsi value or the day befor yesterday value

tanx

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
troojansafir: in fact; in the code above, every time, iRSI function returned 10, so always d=10.0

Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (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.03.08
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

 
William Roeder:

Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (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.03.08
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

tnx so much.

i use it in OnInit, becuse i want use it, once.

i try saved indicator value at all time in array variable for once, and compare them. i wan't update it.

i want in OnInit:

array[0]= indicator value today

array[1]= indicator value yesterday

array[2]= indicator value the day before yesterday

.

.

.

does have anyway?