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
Order History for an Instrument in a Multi-Instrument Strategy
Collapse
X
-
Order History for an Instrument in a Multi-Instrument Strategy
I have a Multi Instrument Strategy. I am trying to retrieve if a instrument has traded today. If so was it a long or short. I have done little reading up on the TradeCollection. To get the Date I would need the Execution object. I am having a hard time coding this up. Is there code examples that I can look at?Tags: None
-
Hello [email protected], and thank you for your questions.
I am trying to retrieve if a instrument has traded today
If so was it a long or short
I have done little reading up on the TradeCollection. To get the Date I would need the Execution object.
Our checking function in this case (in a strategy instead of an indicator like I have attached) would look like
Code:foreach(Trade Trade in SystemPerformance.AllTrades) { if (Trade.Entry.Instrument.FullName == InstrumentToCheck) { return true; } } return false;
Attached FilesLast edited by NinjaTrader_JessicaP; 03-16-2017, 10:37 AM.Jessica P.NinjaTrader Customer Service
-
Thank your very much for your help. I still have the question on how to tell if the trade is one from today and if it is long or short trade.
IS this code anywhere close to what I would need?
bool LongTraded = false;
foreach(Trade Trade in SystemPerformance.AllTrades)
{
if (Trade.Entry.Instrument.FullName.CompareTo(BarsArray[BarsInProgress].Instrument)
&& Trade.Entry.Time.Date.CompareTo(ToDay)
&& Trade.Entry.Quantity > 0 )
{
LongTraded = true;
}
}
Comment
-
I want to reiterate that SystemPerformance.AllTrades only refers to trades your strategy has placed directly. With this in mind, you can see when a trade has been placed with Execution.Time. If you want to ensure a trade has been place today, you can use
Code:ToTime(Trade.Entry.Time) <= ToTime(Time[0]) && ToDay(Trade.Entry.Time) == ToDay(Time[0])
Jessica P.NinjaTrader Customer Service
Comment
-
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by WHICKED, Today, 02:02 PM
|
0 responses
1 view
0 likes
|
Last Post
by WHICKED
Today, 02:02 PM
|
||
Started by selu72, Today, 02:01 PM
|
0 responses
0 views
0 likes
|
Last Post
by selu72
Today, 02:01 PM
|
||
Started by f.saeidi, Today, 12:14 PM
|
8 responses
20 views
0 likes
|
Last Post
by f.saeidi
Today, 01:55 PM
|
||
Started by Mikey_, 03-23-2024, 05:59 PM
|
3 responses
49 views
0 likes
|
Last Post
by Sam2515
Today, 01:47 PM
|
||
Started by Russ Moreland, Today, 12:54 PM
|
1 response
7 views
0 likes
|
Last Post Today, 01:01 PM |
Comment