Amibroker 6.30.5 vs 6.00.2 backtest results

I came across a strange behavior when I ran the same piece of code on two different machines having different version of amibroker ( 6.30.5 vs 6.00.2). I am getting very different backtest results. The below code is extracted only to reproduce the issue, please do not look at the logic of it. ( on both machines I ran the backtest on qqq , 5 min chart from a given from and to date ( 01/01/2021 to 01/03/2022). Datasource is iqfeed. Database/Analysis settings are the same on both instances

X1 = HHVBars( C, 15 ); 

X2 = IIF( Ref( LinRegSlope( C, X1 ), -1 ) < 0 , X1 + 1, 100 );

Buy = LinRegSlope(C,X2) > .2 AND TimeNum() < 154500;
Sell = DateNum() != Ref(DateNum(),2);

Interestingly, if I set X1 = 20 (i.e not an array) in the first line, am getting the same results on both instances

Could anyone please let me know what could be the issue?
Thanks in advance

I would suggest using an Exploration to see your X1 and X2 values. Assuming the two environments don't produce the same results, dig into the data to figure out why. Is the underlying data from iqfeed identical? Are the timestamps the same? Other questions will surely arise as you investigate further.

1 Like

Thanks for the reply @mradtke . Data are same for the backtested period- although one has a longer history in the database.
It is very interesting if I set
X1 = 20 ;

instead of
X1 = HHVBars( C, 15 );

in the first line, am getting the same results on both instances. So I guess that rules out any data discrepency

I tried the exploration showing close, x1 and x2. Result is that close price and x1 are having same values across the two backtests but x2 values are differing. Very strange indeed


I did an exploration for LinRegSlope( C, X1 ) and above picture shows the difference in result of the export csv outputs.
Essentially the difference is
QQQ,19/03/2021 11:54:59,313.88,-1.#J
QQQ,19/03/2021 11:54:59,313.88,-nan(ind)

So may be it is due to the difference in the machines? ( one is a windows laptop and the other is aws t3.large windows server)
what is the difference between interpretation of "-1.#J" and "*-nan(ind)" ?

There is no difference.
-1.#j is "not a number" exactly what -nan(ind) means. It is just formatting. You are probably using 32-bit version and 64-bit version and runtime library for those versions formats NaNs differently, but regardless of formatting, NaN is the same thing. Getting "Not a number" means that there is an error in YOUR formula.

You are passing zeros or negative numbers to LinRegSlope range and that is causing problems in first place. Range for Linear Regression should by definition be >= 2. HHVBars can go down to zero. As such it must not be directly passed as range to LR.

Fix your code so it does NOT pass forbidden values to functions.

To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?

The only difference between versions is that later versions do more checks for common mistakes that people make and display more error messages to make people aware that they are making mistakes in their formulas. AmIBroker originally was written for my own use and it assumed that "user knows what he/she is doing" but as user base has grown this over time has proved to be false assumption.

1 Like

thanks for the reply @Tomasz. Indeed the comparison of the nan/ -1.#J with 0
X2 = IIF( Ref( LinRegSlope( C, X1 ), -1 ) < 0 , X1 + 1, 100 );
caused undefined behaviour across the two machines.
Appreciate the quick response!

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.