is referencing -2 trade not the last trade
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
NT8 - last trade info
Collapse
X
-
Hello astef,
I've tested some code an have not observed what you are reporting.
Here is the code I tested with, please apply to your situation as a test.
Code:Print ("Number of trades: " +SystemPerformance.AllTrades.Count); for (int i = 0; i < SystemPerformance.AllTrades.Count; i++) { Trade firstTrade = SystemPerformance.AllTrades[i]; Print ("Trade: "+ i+" Value: "+ firstTrade.ProfitCurrency); } Trade last1Trade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count -1]; Print ("last1: "+last1Trade.ProfitCurrency); Trade last2Trade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count -2]; Print ("last2: "+last2Trade.ProfitCurrency);
Trade: 184 Value: 550
Trade: 185 Value: 30.0000000000068
Trade: 186 Value: -69.9999999999932
Trade: 187 Value: -160.000000000002
Trade: 188 Value: -210.000000000002
last1: -210.000000000002
last2: -160.000000000002Paul H.NinjaTrader Customer Service
Comment
-
Hi
Thank you very much.
The reference to
Trade last1Trade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count -1];
works well in OnOrderUpdate but for me does not wok in OnBarUpdate
in
OnBarupdate:
{...
if (Criteria)
EnterLong()
lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count -1]; - was not referencing last trade but a second last
Note - I am running with Tickr Replay on historical data
as the trade can be properly referenced in OnOrderUpdate, this is not an issue for me any more
Comment
-
Hello astef,
Thanks for your reply.
I am unable to replicate the issue.
I have tried with historical data with Tick Replay in the strategy analyzer. I have tried with historical data without tick replay.
In each case the [-1] points to the last trade and [-2] the trade before, etc.
If you can create a small working sample that demonstrates the issue, along with the steps to recreate, I would be glad to review.Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
3 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
1 view
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
6 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
||
Started by timmbbo, Today, 08:59 AM
|
2 responses
10 views
0 likes
|
Last Post
by bltdavid
Today, 04:10 PM
|
Comment