Download MetaTrader 5

How take indicator value exactly at OrderSend moment, MT4

To add comments, please log in or register
Sinisa Zizic
122
Sinisa Zizic  

Please coders, help, Im not so experienced in MT4 coding.

I wont to take and show in EA, RSI value at moment of opening ticket, OrderSend.

My EA opens tickets in RSI range 30-70, but I need to know RSI value exactly in OrderSend moment and show that value in Chart for analysing and optimising.

Carl Schreiber
7362
Carl Schreiber  
use the mt4 function iRSI() and call this function and save the returned value at the moment right before you send the order and then show it using Comment().
iRSI - Technical Indicators - MQL4 Reference
iRSI - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iRSI - Technical Indicators - MQL4 Reference
Sinisa Zizic
122
Sinisa Zizic  
Carl Schreiber:
use the mt4 function iRSI() and call this function and save the returned value at the moment right before you send the order and then show it using Comment().


Thanks for fast answer but need some details.

Is it void funtion?  I tried with    void rsival(double=iRSI(Symbol(),0,14,PRICE_CLOSE,0));   not possible on global scope.

How to save?

Sinisa Zizic
122
Sinisa Zizic  

Now function is ok, no errors

 void Rsival()

 {double rsi=iRSI(Symbol(),PERIOD_M15,14,PRICE_CLOSE,0);}


How to save? I can not find any Save  function except FileSave

Marco vd Heijden
Moderator
5660
Marco vd Heijden  

You can print it to journal then it will be saved in the log file (with timestamp) or you can use globals then it will be saved for 4 weeks etc. https://www.mql5.com/en/docs/globals 

Many ways to do it you can also create double array [] to store it but it will be a bit more sensitive to be lost upon re-init and re-start's etc.

The write to file is actually a solid one because then it will be saved in stead of being held in memory only...

Documentation on MQL5: Global Variables of the Terminal
Documentation on MQL5: Global Variables of the Terminal
  • www.mql5.com
Global Variables of the Terminal - Reference on algorithmic/automated trading language for MetaTrader 5
To add comments, please log in or register