I have also been trying to do it with a strategy using OnPositionUpdate or OnOrderUpdate but both show that the current position is Flat. I also tried getting the ATM strategy and accessing the MarketPosition property but nothing. Your help is greatly appreciated.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
be notified when a position is open
Collapse
X
-
be notified when a position is open
Hi, I am trying to be notified when a position is opened (or closed) on an indicator.
I have also been trying to do it with a strategy using OnPositionUpdate or OnOrderUpdate but both show that the current position is Flat. I also tried getting the ATM strategy and accessing the MarketPosition property but nothing. Your help is greatly appreciated.Tags: None
-
the MarketPosition is always flat. here is my code
protected override void OnPositionUpdate(IPosition position)
{
if(position.MarketPosition != MarketPosition.Flat){*/
drawIndicator = true;
if(position.MarketPosition== MarketPosition.Long){
isLong = true;
}
else{
isLong = false;
}
}
else{
/*do something*/
}
}
Comment
-
aversano, just to double check, your strategy is actually taking trades right? If so, please try the bare minimums to make sure your installation is functioning correctly:
Code:protected override void OnPositionUpdate(IPosition position) { Print(position.ToString()); }AustinNinjaTrader Customer Service
Comment
-
aversano, strategies only know about what is going on with itself. Thus, it isn't possible for a strategy to know what is going on outside the strategy.
Any trades submitted by the super DOM or anything else like that will not be seen by strategies.
So, in short, what you're trying to do isn't possible.AustinNinjaTrader Customer Service
Comment
-
aversano, there are many ways to retrieve the position state but none would be easy or fast (or cheap) to code.
Since you mentioned Zen-Fire, you could go as far as obtaining the Zen-Fire API (completely different from NT) from the developers, creating your own application that utilizes said API, then this application could just sit and "listen" to changes on your account. All this would be separate from NT, of course. Then you'd have to integrate the results from your own program into your strategy via a bit of cross-application communication.
Another option would be to whip up a Python (or C#) script that continuously polls the ATI for order status. You'd have to create the proper methods and such that would create a "net position" from order fills (much harder than it sounds), but it sure is possible.AustinNinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
333 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment