Please don't post your whole code, just the relevant section.
double rsim30=iRSI(Symbol(),30,RSIperiod,PRICE_CLOSE,0); double rsim60=iRSI(Symbol(),60,RSIperiod,PRICE_CLOSE,0); double rsid1=iRSI(Symbol(),1440,RSIperiod,PRICE_CLOSE,0); //--- open position if(OpenSELL && OrderSell<1 && rsim30>=SellLevel && rsim60>=SellLevel && rsid1<50) OPSELL(); if(OpenBUY && OrderBuy<1 && rsim30<=BuyLevel && rsim60<=BuyLevel && rsid1>50) OPBUY();
You are using values from open bars so when you look back over a chart, the closing values will almost certainly be different. It looks like trades have been taken where they shouldn't have.
Please don't post your whole code, just the relevant section.
You are using values from open bars so when you look back over a chart, the closing values will almost certainly be different. It looks like trades have been taken where they shouldn't have.
Sorry about the whole code part, will take note next time. I would like my trading strategy to base on real-time RSI values as the live data would display. Do you mean that I should add a shift in the code for the RSI? Like:
double rsim30=iRSI(Symbol(),30,RSIperiod,PRICE_CLOSE,1); double rsim60=iRSI(Symbol(),60,RSIperiod,PRICE_CLOSE,1); double rsid1=iRSI(Symbol(),1440,RSIperiod,PRICE_CLOSE,1);
Or was it something else you are referring to, sir? Thanks!
Sorry about the whole code part, will take note next time. I would like my trading strategy to base on real-time RSI values as the live data would display. Do you mean that I should add a shift in the code for the RSI? Like:
Or was it something else you are referring to, sir? Thanks!
If you want to look back on the charts to check, then you can only use shift 1 as values will change before the bar is closed.
If you want to look back on the charts to check, then you can only use shift 1 as values will change before the bar is closed.
- 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, I am trying to generate a trading strategy based on RSIs across different timeframes, however, there seems to be some issues when I backtest it. The EA doesn't seem to interact properly with the RSIs from different timeframes. For example, when I select "H1" and "M30" in "Period" in Strategy Tester, it returns completely different backtest results (different numbers of trades, different pnl, etc) for the data during the same time period (e.g. from July 2018 to August 2018), and when I look at the historical records, the trades were placed not according to my trade logic. Can someone help me fix this issue? Thanks very much!
Below is the code, please let me know how I should revise it so that I can properly backtest it: