I have a strategy with the following logic:
* Calculate Instrument 1 divided by Instrument 2 ("quotient")
* Calculate two SMAs based on this quotient ("SMA1", "SMA2")
* When SMA1 crosses SMA 2 buy or sell Instrument 2
The SMA calculation is based on a Series:
SMA1 = SMA(myDoubleSeries, SMADailyPeriod1);
SMA2 = SMA(myDoubleSeries, SMADailyPeriod2);
SMADailyPeriodx is the period in days for the respective SMA.
The values for myDoubleSeries are calculated as follows:
private Series<double> myDoubleSeries;
myDoubleSeries[0] = Closes[1][0]/Closes[2][0];
My problem is that the calculated SMAs - especially for short SMA periods like 5 or 10 days - differs significantly based on the time frame chosen.
An example: If I start the backtest in 2009 NT gives me the following values in the output window for 17th Mar 2021 (this is a random date - the problem occurs for the whole time period):
(SMA 1 = 10 days / SMA 2 = 50 days)
17.03.2021 22:00:00 SMA 1: 0,0170115111988172
17.03.2021 22:00:00 SMA 2: 0,0151562639356313
17.03.2021 22:00:00 Ratio: 0,016321433076826
The exact same strategy with an identical setup, but with start date 1st Jan 2021 comes up with these results:
17.03.2021 22:00:00 SMA 1: 0,016741616961223
17.03.2021 22:00:00 SMA 2: 0,0151022850881123
17.03.2021 22:00:00 Ratio: 0,016321433076826
The code for the output window is:
myDoubleSeries[0] = Closes[1][0]/Closes[2][0];
SMAOBV1value=myDoubleSeries[0];
print ("SMA 1: " + SMA1[0].ToString());
print ("SMA 2: " + SMA2[0].ToString());
print ("Ratio: " + SMAOBV1value);
As you can see, especially the SMA 1 differs quite significantly (the earlier the start of the backtest the higher the SMAs) and I have no idea why. The only difference between these two calculations is the start date - everything else (end date, market data, setup) is identical.
I calculated the SMAs by hand and I can reconcile the figures that NT calculates when I start the backtest in 2021 (0.0167416... for SMA 1). I have absolutely no idea why NT comes up with different SMAs depending on the start date of my backtest.
I am using back adjusted data from Kinetick.
Do you need any further information?
Can you help me, please?
Comment