Read the documentation and look at the example.
What you have posted will not even compile.
Read the documentation and look at the example.
What you have posted will not even compile.
Hi, Keith
Thank you.
This is a code.
void start() { int TIME_FRAME=1; double RSI=iRSI(NULL,TIME_FRAME,14,PRICE_CLOSE,1); Comment(RSI); }
When I use TIME FRAME=1 (M1),and backtest TF M5.
RSI value is alwasy zero.
Why?
I want to get M1 RSI data on the M5 chart.
First of all get out of the habit of using
void start()
This was superseded 7 years ago and by now nobody should be using it any more.
When you start a new project simply click "New" top left of the Editor and then whatever you are doing, ie Expert advisor.
Then the template is there and you use OnTick() for an EA. Certainly do NOT add void start() as well as OnTick() as this may be ignored by the compiler.
Also get used to using the enum
input ENUM_TIMEFRAMES TIME_FRAME=PERIOD_M1;
instead of an int for the time-frame. It makes the code simpler to read and also easier if you ever want to convert to MQL5.
This should work correctly.
//+------------------------------------------------------------------+ //| RSI Test.mq4 | //+------------------------------------------------------------------+ #property version "1.00" #property strict //--- input parameters input ENUM_TIMEFRAMES TIME_FRAME=PERIOD_M1; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double RSI=iRSI(NULL,TIME_FRAME,14,PRICE_CLOSE,1); Comment(RSI); //--- } //+------------------------------------------------------------------+
Thank you so much. I understand it.
I want to ask another topic.
If you have time please advice me.
https://www.mql5.com/en/forum/366758![How to avoid order modify error1? How to avoid order modify error1?](https://c.mql5.com/36/47/how-to-avoid-order-modify-error1.jpg)
- 2021.04.08
- www.mql5.com
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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, it is very strange.
I want to read MACD signal of TF M1 on TFM5.
I mean I used below code to read MACD of TFM1 and when I attach EA on TFM5, I can not read MACD signal of M1 from M5 chart.
On real chart, it shows the value, but when I do backtest it always shows zero. DO you know why?