Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Need to find difference in Indicator
Collapse
X
-
Hello samish18,
Because math is involved you would need to use a Print to see what values are used in each case, by doing that you can manually do the math for a bar to see why the calculation is different. Different equations will result in different answers. The code you commented out is doing additional math that you are not doing with the uncommented code.
//double FirstValue = (Closes[1][0] * Instruments[1].MasterInstrument.PointValue); <-- additional math
//double SecondValue = (Closes[2][0] * Instruments[2].MasterInstrument.PointValue); <-- additional math
//Spread[0] = (((FirstValue - SecondValue) / (FirstValue + SecondValue)) * 100); <-- additional math
Spread[0] = Closes[2][0]/Closes[1][0]; <-- only division between two numbers
-
I do not use the commented out code, just use the uncommented code. When using the exact same line (Spread[0] = Closes[2][0]/Closes[1][0]
in the strategy code itself, I get slightly different printed values and vastly different results in the strategy analyzer.
Comment
-
It is very odd. When I run the strategy live using the attached indicator, it yields the results when backtesting over the same period using the Closes[2][0]/Closes[1][0]. It seems that there is no difference in whether or not I'm using the indicator or calculating directly in the strategy for the live environment, but very different results when backtesting - any idea why this may be?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment