How do I code for if the last trade was a win or loss and can I get a count of the no of trades in a row that are wins/losses in a similar way?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
How to code for if last trade was a win/ loss w count
Collapse
X
-
How to code for if last trade was a win/ loss w count
Hi nt8 support,
How do I code for if the last trade was a win or loss and can I get a count of the no of trades in a row that are wins/losses in a similar way?Tags: None
-
Hello Austiner87,
Thanks for opening the thread.
You can get the last trade from SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1]
The trade before that would be SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 2]
From here you can reference Trade.ProfitCurrency to see if that trade was a win or loss. If the last three trade's ProfitCurrency are positive then the last three trades are winners.
SystemPerformance - https://ninjatrader.com/support/help...erformance.htm
TradeCollections - https://ninjatrader.com/support/help...collection.htm
Trade objects - https://ninjatrader.com/support/help.../nt8/trade.htm
One of our examples demonstrates halting a strategy after consecutive losses which may be useful for what you are trying to accomplish. I have linked it below.
We look forward to assisting.
JimNinjaTrader Customer Service
-
Hello omermirza,
Live trades that are made from the strategy are recorded in the NinjaTrader database and can be reviewed in a Trade Performance window.
Using Trade Performance - https://ninjatrader.com/support/help...erformance.htm
Historical trades that are calculated when the strategy processes historical data can be reviewed from a historical strategy performance report. Programmatically, these historically calculated trades can be read from the SystemPerformance.AllTrades collection.
Please let us know if you have any additional questions.JimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by frslvr, 04-11-2024, 07:26 AM
|
6 responses
105 views
1 like
|
Last Post Today, 07:21 AM | ||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
6 responses
26 views
0 likes
|
Last Post Today, 07:18 AM | ||
Started by arvidvanstaey, Yesterday, 02:19 PM
|
5 responses
14 views
0 likes
|
Last Post Today, 07:16 AM | ||
Started by Rapine Heihei, Yesterday, 08:25 PM
|
1 response
12 views
0 likes
|
Last Post Today, 07:16 AM | ||
Started by Mongo, Yesterday, 11:05 AM
|
6 responses
27 views
0 likes
|
Last Post
by Mongo
Today, 07:12 AM
|
Comment