Login Page - Create Account

Support Board


Date/Time: Sat, 23 Nov 2024 23:04:03 +0000



Post From: sc.IsSwingLow not working in Replay Backtest

[2024-07-27 07:50:04]
User431178 - Posts: 541
yes have tried the IndexToEvaluate method in Studies6.cpp.
If you did, and it still does not work, then something is wrong in your study somewhere.

Trying to understand the at current bar method
It cannot work correctly at the current bar that is all there is to it.
Nor can this work correctly, as it automatically passes the current bar as the index parameter to 3 parameter function.


int IsSwingLow(SCFloatArrayRef FloatArrayIn, int Length); Auto-looping only.

In the Replay backtest, after the initial calculation, sc.IsSwingLow just remains at 0. This makes results of the Bar(which works) vs Replay backtests significantly divergent.
Yes, because at the initial calculation all the bars exist, so when you start from the beginning of the chart there are bars before and after every bar, until you get to the last.
When you run a replay there are no bars after, it is as simple as that.

As I said before both functions look backwards and forwards by the specified length, checking for lower low / higher high.

What happens when you are at the last bar in the chart (when running a replay for example) and you check the value of the bar at index + 1?
It returns zero, which explains why:
sc.IsSwingHigh works - 0 is generally going to be lower than the value of the previous high.
but
sc.IsSwingLow does not - 0 is not generally going to be higher than the value of the previous low.