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 rocketman7, Today, 01:00 AM
|
0 responses
1 view
0 likes
|
Last Post
by rocketman7
Today, 01:00 AM
|
||
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
74 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
Comment