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 CarlTrading, 03-31-2026, 09:41 PM
|
1 response
47 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
23 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
33 views
1 like
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
51 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
42 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment