Real time trades different from backtested trades

Questions about MultiCharts and user contributed studies.
rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Real time trades different from backtested trades

Postby rkhan » 09 Jul 2014

I have a strategy which i use on a daily chart of ES
The strategy buy when the RSI is > 90,

The buy code is pretty simple, i have pasted it below, it simply buys at the close of the daily bar.

Now what i am finding is happening is that the strategy is placing orders, even when the RSI setup is not true (ie when RSI is NOT > 90), yet in all the backtesting, this worked fine.

Now what i THINK is happening is that during the day, maybe the RSI value does go above 90, and hence it places the strategy, but then by the end of the day, the RSI most likely moves back down below 90, so really the strategy should NOT have placed the trade

Anyway, is there a method where i can tell it to only test at the CLOSE of the bar?

Code: Select all

If ( RSISetup ) Then buy this bar at close;

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Real time trades different from backtested trades

Postby TJ » 09 Jul 2014

I have a strategy which i use on a daily chart of ES
The strategy buy when the RSI is > 90,

The buy code is pretty simple, i have pasted it below, it simply buys at the close of the daily bar.

Now what i am finding is happening is that the strategy is placing orders, even when the RSI setup is not true (ie when RSI is NOT > 90), yet in all the backtesting, this worked fine.

Now what i THINK is happening is that during the day, maybe the RSI value does go above 90, and hence it places the strategy, but then by the end of the day, the RSI most likely moves back down below 90, so really the strategy should NOT have placed the trade

Anyway, is there a method where i can tell it to only test at the CLOSE of the bar?

Code: Select all

If ( RSISetup ) Then buy this bar at close;
You should post the complete code if you need help debugging.

are you using IntraBarOrderGeneration?


re: buy this bar at close;
See post #7
viewtopic.php?f=16&t=10811

rkhan
Posts: 65
Joined: 16 Mar 2014
Has thanked: 1 time
Been thanked: 2 times

Re: Real time trades different from backtested trades

Postby rkhan » 09 Jul 2014

I used 1min magnification for backtesting
So yes this was the scenario

Thankyou for assisting, I have now turned off intra bar order generation

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Real time trades different from backtested trades

Postby MAtricks » 10 Jul 2014

You can't place an order at the "close" price of a daily bar. That's a settlement price... Use the open of the new bar if you want a valid price or use two data streams to calculate off daily, but execute on minute bars.


Return to “MultiCharts”