the IOrder variable is set to null after the order is filled. Can you tell me why? When and where is it necessary to set the IOrder variable to null?
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
Setting IOrder Variable to NULL
Collapse
X
-
Hello,
This is because the logic in OnBarUpdate is using this.
If we look at the example:
Code:private IOrder entryOrder = null; protected override void [B]OnBarUpdate[/B]() { [B]if (entryOrder == null [/B]&& Close[0] > Open[0]) entryOrder = [B]EnterLong[/B](); } protected override void OnOrderUpdate(IOrder order) { if (entryOrder != null && entryOrder == order) { Print(order.ToString()); if (order.OrderState == OrderState.Filled) [B]entryOrder = null;[/B] } }
If there is not a current order or if entryOrder equals null, it sends EnterLong, otherwise does nothing. This just makes only 1 order at a time for the entire life of the order.
This exact scenario may not apply to your script, this is intended to show how to store an IOrder and use it for logic in the entire script or between override methods and also how to check if the filled order was that stored order.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by 1001111, Today, 01:35 AM
|
0 responses
1 view
0 likes
|
Last Post
by 1001111
Today, 01:35 AM
|
||
Started by ETFVoyageur, Yesterday, 07:05 PM
|
1 response
15 views
0 likes
|
Last Post
by ETFVoyageur
Today, 01:33 AM
|
||
Started by MarianApalaghiei, Today, 12:35 AM
|
1 response
7 views
0 likes
|
Last Post Today, 01:17 AM | ||
Started by Rogers101, 05-05-2024, 11:30 AM
|
17 responses
56 views
0 likes
|
Last Post
by Rogers101
Today, 01:14 AM
|
||
Started by haas88, 03-21-2024, 02:22 AM
|
13 responses
154 views
0 likes
|
Last Post
by haas88
Today, 01:13 AM
|
Comment