Aurex Lions:
Hi, newbie here. I'm trying to synchronize indicator values (for example: RSI) with EA.
Here's the code
When I tested it with the Strategy Tester, the RSI value on the Print shows differently from what is on the Data Window.
It prints (the last one is at the bottom):
On the Data Window accordingly:
What is the reason of this mistake and maybe anyone can fix this. It would be great if anyone can help. Thank you!
Try the following :
input int RSIPeriod = 9; int rsiHandle; double prevRsi=0.0; int OnInit() { prevRsi=0.0; rsiHandle = iRSI(_Symbol, PERIOD_H1, RSIPeriod, PRICE_CLOSE); return(INIT_SUCCEEDED); } void OnTick() { double rsiArray[]; if (CopyBuffer(rsiHandle, 0, 0, 2, rsiArray) <= 0) return; double rsi = NormalizeDouble(rsiArray[1], 2); if(rsi!=prevRsi){ Print("RSI "+rsi); prevRsi=rsi; } }
It just solved. It turns out that the values on:
So to get exact same values, the Print() needs to be in a function that detect a closing bar.
Print("RSI "+rsi);are printed on every tick. The RSI values on the data value made after a bar closed.
So to get exact same values, the Print() needs to be in a function that detect a closing bar.
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
Hi, newbie here. I'm trying to synchronize indicator values (for example: RSI) with EA.
Here's the code
When I tested it with the Strategy Tester, the RSI value on the Print shows differently from what is on the Data Window.
It prints (the last one is at the bottom):
On the Data Window accordingly:
What is the reason of this mistake and maybe anyone can fix this. It would be great if anyone can help. Thank you!