Difference between backtest and real trading  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
svopex
Posts: 72
Joined: 16 Oct 2013
Has thanked: 7 times
Been thanked: 5 times
Contact:

Difference between backtest and real trading

Postby svopex » 14 Dec 2016

Hello,

I have this example calculation:

Inputs:
double nas(0.6),
AdditionalStrategyName("");

vars:
Value(0),
Half(1),
RealTimeCalc(0),
StrOut("");

Half = (0.5 * (HighD(0) - LowD(0)));
Value = Close[1] + (nas * Half);

RealTimeCalc = GetAppInfo(aiRealTimeCalc);

StrOut =
"ComputerTime=" + NumToStr(CurrentTime_s, 0) + ","
+ SvpDateString3(date, time) + ","
+ "BarStatus=" + NumToStr(BarStatus(), 0) + ","
+ "Value=" + NumToStr(Value, 6) + ","
+ "RealTime=" + NumtoStr(RealTimeCalc, 0)
+ NewLine;

FileAppend("C:\Log\Strategy_Vars_" + GetStrategyName + "_" + GetSymbolName + "_" + AdditionalStrategyName + ".csv", StrOut);

And I have this results.

1. Realtrading:
ComputerTime=161506,12/12/2016 16:15:00,BarStatus=2,Value=1380.230200,RealTime=1
ComputerTime=94458,12/13/2016 9:45:00,BarStatus=2,Value=1375.620200,RealTime=1
ComputerTime=100000,12/13/2016 10:00:00,BarStatus=2,Value=1388.206300,RealTime=1
ComputerTime=101459,12/13/2016 10:15:00,BarStatus=2,Value=1382.573900,RealTime=1
ComputerTime=102959,12/13/2016 10:30:00,BarStatus=2,Value=1381.819100,RealTime=1
ComputerTime=104500,12/13/2016 10:45:00,BarStatus=2,Value=1380.009400,RealTime=1
ComputerTime=105959,12/13/2016 11:00:00,BarStatus=2,Value=1374.147700,RealTime=1
ComputerTime=111459,12/13/2016 11:15:00,BarStatus=2,Value=1379.776700,RealTime=1
ComputerTime=112958,12/13/2016 11:30:00,BarStatus=2,Value=1379.652700,RealTime=1
ComputerTime=114459,12/13/2016 11:45:00,BarStatus=2,Value=1380.052700,RealTime=1
ComputerTime=115959,12/13/2016 12:00:00,BarStatus=2,Value=1375.949700,RealTime=1
ComputerTime=121459,12/13/2016 12:15:00,BarStatus=2,Value=1377.800700,RealTime=1
ComputerTime=122959,12/13/2016 12:30:00,BarStatus=2,Value=1381.003700,RealTime=1
ComputerTime=124459,12/13/2016 12:45:00,BarStatus=2,Value=1381.153700,RealTime=1
ComputerTime=125958,12/13/2016 13:00:00,BarStatus=2,Value=1382.455700,RealTime=1
ComputerTime=131507,12/13/2016 13:15:00,BarStatus=2,Value=1384.156700,RealTime=1
ComputerTime=133000,12/13/2016 13:30:00,BarStatus=2,Value=1384.456700,RealTime=1
ComputerTime=134458,12/13/2016 13:45:00,BarStatus=2,Value=1383.330700,RealTime=1
ComputerTime=140001,12/13/2016 14:00:00,BarStatus=2,Value=1382.404700,RealTime=1
ComputerTime=141459,12/13/2016 14:15:00,BarStatus=2,Value=1382.954700,RealTime=1
ComputerTime=142959,12/13/2016 14:30:00,BarStatus=2,Value=1379.574700,RealTime=1
ComputerTime=144459,12/13/2016 14:45:00,BarStatus=2,Value=1377.798700,RealTime=1
ComputerTime=145959,12/13/2016 15:00:00,BarStatus=2,Value=1379.200700,RealTime=1
ComputerTime=151459,12/13/2016 15:15:00,BarStatus=2,Value=1379.774700,RealTime=1
ComputerTime=152958,12/13/2016 15:30:00,BarStatus=2,Value=1379.048700,RealTime=1
ComputerTime=154458,12/13/2016 15:45:00,BarStatus=2,Value=1379.899700,RealTime=1
ComputerTime=155959,12/13/2016 16:00:00,BarStatus=2,Value=1380.400700,RealTime=1
ComputerTime=161458,12/13/2016 16:15:00,BarStatus=2,Value=1380.000700,RealTime=1
ComputerTime=94500,12/14/2016 9:45:00,BarStatus=2,Value=1378.893400,RealTime=1
ComputerTime=95959,12/14/2016 10:00:00,BarStatus=2,Value=1375.091800,RealTime=1
ComputerTime=101501,12/14/2016 10:15:00,BarStatus=2,Value=1373.412800,RealTime=1
ComputerTime=102959,12/14/2016 10:30:00,BarStatus=2,Value=1370.589100,RealTime=1

2. Backtest (I did "recalculate strategy"):
ComputerTime=115246,12/12/2016 16:15:00,BarStatus=2,Value=1380.230200,RealTime=0
ComputerTime=115246,12/13/2016 9:45:00,BarStatus=2,Value=1375.620200,RealTime=0
ComputerTime=115246,12/13/2016 10:00:00,BarStatus=2,Value=1388.213800,RealTime=0
ComputerTime=115246,12/13/2016 10:15:00,BarStatus=2,Value=1382.573900,RealTime=0
ComputerTime=115246,12/13/2016 10:30:00,BarStatus=2,Value=1381.819100,RealTime=0
ComputerTime=115246,12/13/2016 10:45:00,BarStatus=2,Value=1380.009400,RealTime=0
ComputerTime=115246,12/13/2016 11:00:00,BarStatus=2,Value=1374.147700,RealTime=0
ComputerTime=115246,12/13/2016 11:15:00,BarStatus=2,Value=1379.776700,RealTime=0
ComputerTime=115246,12/13/2016 11:30:00,BarStatus=2,Value=1379.652700,RealTime=0
ComputerTime=115246,12/13/2016 11:45:00,BarStatus=2,Value=1380.052700,RealTime=0
ComputerTime=115246,12/13/2016 12:00:00,BarStatus=2,Value=1375.949700,RealTime=0
ComputerTime=115246,12/13/2016 12:15:00,BarStatus=2,Value=1377.800700,RealTime=0
ComputerTime=115246,12/13/2016 12:30:00,BarStatus=2,Value=1381.003700,RealTime=0
ComputerTime=115246,12/13/2016 12:45:00,BarStatus=2,Value=1381.153700,RealTime=0
ComputerTime=115246,12/13/2016 13:00:00,BarStatus=2,Value=1382.455700,RealTime=0
ComputerTime=115246,12/13/2016 13:15:00,BarStatus=2,Value=1384.156700,RealTime=0
ComputerTime=115246,12/13/2016 13:30:00,BarStatus=2,Value=1384.456700,RealTime=0
ComputerTime=115246,12/13/2016 13:45:00,BarStatus=2,Value=1383.330700,RealTime=0
ComputerTime=115246,12/13/2016 14:00:00,BarStatus=2,Value=1382.404700,RealTime=0
ComputerTime=115246,12/13/2016 14:15:00,BarStatus=2,Value=1382.954700,RealTime=0
ComputerTime=115246,12/13/2016 14:30:00,BarStatus=2,Value=1379.574700,RealTime=0
ComputerTime=115246,12/13/2016 14:45:00,BarStatus=2,Value=1377.798700,RealTime=0
ComputerTime=115246,12/13/2016 15:00:00,BarStatus=2,Value=1379.200700,RealTime=0
ComputerTime=115246,12/13/2016 15:15:00,BarStatus=2,Value=1379.774700,RealTime=0
ComputerTime=115246,12/13/2016 15:30:00,BarStatus=2,Value=1379.048700,RealTime=0
ComputerTime=115246,12/13/2016 15:45:00,BarStatus=2,Value=1379.899700,RealTime=0
ComputerTime=115246,12/13/2016 16:00:00,BarStatus=2,Value=1380.400700,RealTime=0
ComputerTime=115246,12/13/2016 16:15:00,BarStatus=2,Value=1380.000700,RealTime=0
ComputerTime=115246,12/14/2016 9:45:00,BarStatus=2,Value=1378.907200,RealTime=0
ComputerTime=115246,12/14/2016 10:00:00,BarStatus=2,Value=1375.091800,RealTime=0
ComputerTime=115246,12/14/2016 10:15:00,BarStatus=2,Value=1373.420300,RealTime=0
ComputerTime=115246,12/14/2016 10:30:00,BarStatus=2,Value=1370.589100,RealTime=0

Bold text highlight difference values.

It's problem for me, because strategy real execution is different from backtest calculation.

I use Oanda broker, session 9:30 - 16:15 EST, 15 minutes timeframe, local time (in windows i have EST timezone), real account.
Last edited by svopex on 27 Dec 2016, edited 1 time in total.

User avatar
TJ
Posts: 6974
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 984 times
Been thanked: 1995 times

Re: Difference between backtest and real trading

Postby TJ » 14 Dec 2016

You need to write a bit more.
Can you identify and describe the salient points of the "differences"?

I see a bunch of printouts.

Without your analysis, these posts do not call for any action from anybody.

AlexKendo
Posts: 19
Joined: 12 Sep 2012

Re: Difference between backtest and real trading

Postby AlexKendo » 14 Dec 2016

The problem I have. The problem is that when the real-time strategy and enabled IOG signals are not correct. If you select in the menu "Recalculate" strategy, the strategy change signals! For example, the price was 10 and showed the strategy "Buy." A few minutes later, the price has dropped to 9.5. Click on the menu "Recalculate" strategy and the strategy will change the purchase price from 10 to 9.5. Bektest wrong initially, because the wings signals at low prices.

User avatar
svopex
Posts: 72
Joined: 16 Oct 2013
Has thanked: 7 times
Been thanked: 5 times
Contact:

Re: Difference between backtest and real trading

Postby svopex » 14 Dec 2016

@TJ:
I don't understand.
Here is strategy, settings and results. Everyone can test it.
Or you mean that I should log HighD(0), LowD(0) and Close[1] and show this situation in graph?

@AlexKendo:
I have disabled IOG.
Realtime signals is different from the backtest.
I create this simple test for solving this feature.

User avatar
svopex
Posts: 72
Joined: 16 Oct 2013
Has thanked: 7 times
Been thanked: 5 times
Contact:

Re: Difference between backtest and real trading

Postby svopex » 16 Dec 2016

Hello, I create detailed test.

Backtest (after strategy recalculation):
...
ComputerTime=122132,12/16/2016 9:45:00,BarStatus=2,Value=1371.747200,RealTime=0,HighD(0)=1372.491000,LowD(0)=1368.337000,Close[1]=1370.501000
ComputerTime=122132,12/16/2016 10:00:00,BarStatus=2,Value=1372.899300,RealTime=0,HighD(0)=1374.368000,LowD(0)=1368.337000,Close[1]=1371.090000
ComputerTime=122132,12/16/2016 10:15:00,BarStatus=2,Value=1376.017600,RealTime=0,HighD(0)=1375.419000,LowD(0)=1368.337000,Close[1]=1373.893000
...

Realtime:
...
ComputerTime=94458,12/16/2016 9:45:00,BarStatus=2,Value=1371.747200,RealTime=1,HighD(0)=1372.491000,LowD(0)=1368.337000,Close[1]=1370.501000
ComputerTime=95959,12/16/2016 10:00:00,BarStatus=2,Value=1372.891500,RealTime=1,HighD(0)=1374.342000,LowD(0)=1368.337000,Close[1]=1371.090000
ComputerTime=101500,12/16/2016 10:15:00,BarStatus=2,Value=1376.017600,RealTime=1,HighD(0)=1375.419000,LowD(0)=1368.337000,Close[1]=1373.893000
...

Candle 12/16/2016 10:00, highD(0) is different.
In graph is 1374.342, realtime is 1374.342, backtest (after recalculation strategy) is 1374.368.
After reload graph data value in graph is 1374.368.

Realtime graph:
download/file.php?mode=view&id=10114

Graph after reload:
download/file.php?mode=view&id=10115

I use Oanda broker, session 9:30 - 16:15 EST, 15 minutes timeframe, local time (in windows i have EST timezone), real account.

Code:

Code: Select all

Inputs:
double   Nas(0.6),
AdditionalStrategyName("");
 
vars:
Value(0),
Half(1),
RealTimeCalc(0),
StrOut("");

Half = (0.5 * (HighD(0) - LowD(0)));
Value = Close[1] + (Nas * Half);

RealTimeCalc = GetAppInfo(aiRealTimeCalc);

StrOut =
   "ComputerTime=" + NumToStr(CurrentTime_s, 0) + ","
   + SvpDateString3(date, time) + ","
   + "BarStatus=" + NumToStr(BarStatus(), 0) + ","
   + "Value=" + NumToStr(Value, 6) + ","
   + "RealTime=" + NumtoStr(RealTimeCalc, 0) + ","
   + "HighD(0)=" + NumToStr(HighD(0), 6) + ","
   + "LowD(0)=" + NumToStr(LowD(0), 6) + ","
   + "Close[1]=" + NumToStr(Close[1], 6)
   + NewLine;
FileAppend("C:\Log\Strategy_Vars_" + GetStrategyName + "_" + GetSymbolName + "_" + AdditionalStrategyName + ".csv", StrOut);
Attachments
2016-12-16_1244.png
After reload graph data
2016-12-16_1244.png (49.94 KiB) Viewed 869 times
2016-12-16_1230.png
Realtime graph
2016-12-16_1230.png (43.56 KiB) Viewed 869 times

User avatar
Henry MultiСharts
Posts: 8839
Joined: 25 Aug 2011
Has thanked: 1228 times
Been thanked: 2845 times

Re: Difference between backtest and real trading  [SOLVED]

Postby Henry MultiСharts » 22 Dec 2016

Hello Svopex,

Historical data loaded from the data provider can be different from the realtime data, that is expected and natural for most of the data vendors.

User avatar
svopex
Posts: 72
Joined: 16 Oct 2013
Has thanked: 7 times
Been thanked: 5 times
Contact:

Re: Difference between backtest and real trading

Postby svopex » 22 Nov 2017

I asked in Oanda:
Hello,
I have next problem: viewtopic.php?f=1&t=50353
Backtest data is different from real trading data.
Henry from multicharts send me this answer:
Historical data loaded from the data provider can be different from the realtime data, that is expected and natural for most of the data vendors.
Why?
Thanks Petr


And here is answer from Oanda:
Backtesting is not accurate compared to multicharts because it is tick by tick data.


Return to “MultiCharts”