Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
When exactly does (Position.MarketPosition == MarketPosition.Long) become true?
Collapse
X
-
When exactly does (Position.MarketPosition == MarketPosition.Long) become true?
Is it when the order.Orderstate is Initialized? Submitted? Accepted? Working? Or Filled? My money's on Filled but I'm seeking reassurance.Tags: None
-
Last edited by markdshark; 04-16-2023, 09:55 AM.
Comment
-
You can't know the order these events will be called. They may happen in a particular order during BACKTESTING or on SIM ACCOUNTS but with live brokers the order can vary.
Generally speaking, you should process things in OnBarUpdate if what you're doing is about trade price information, and use OnMarketData if you're processing L1 information such as bid or ask changes, but there are other special cases, so you just have to think about what you are doing and whether it needs to be in OnMarketData.
Bear in mind that if you use the OnMarketData approach you will have to do a tick replay or market replay to backtest.
Comment
-
Hello markdshark,
Thanks for your post.
QuantKey_Bruce is correct. Position.MarketPosition will be equal to market position long anytime an entry order you place becomes filled or partially filled and you were in a flat position before.
Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm
Order State Definitions: https://ninjatrader.com/support/help...efinitions.htm
Further, you should typically process logic in OnBarUpdate() because as QuantKey_Bruce stated, the order of events that process could be different from the events you see when backtesting or from the Sim101 account and is dependent on your broker.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Hi Brandon,
Why does " you were in a flat position before " matter here to determine Position.MarketPosition == Long?
Suppose my account have 1 contract of short position now, then I submitted 2 contract of long order. Once this short order filled, isn't the Position.MarketPosition = Long ?
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
66 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
141 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
76 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
46 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
51 views
0 likes
|
Last Post
|

Comment