I use IsAdoptAccountPositionAware and AdoptAccountPosition. Imagine the strategy position is 8 and account position is 8. Now I place an order manually, so the strategy position is 8 and account position is 9. I can detect that by comparing PositionAccount and Position but I don't know how to force the strategy to adopt this new position without restarting it.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to re-adapot strategy position at run time
Collapse
X
-
How to re-adapot strategy position at run time
I need to re-adopt position my strategy to current AccountPosition without restarting the strategy.
I use IsAdoptAccountPositionAware and AdoptAccountPosition. Imagine the strategy position is 8 and account position is 8. Now I place an order manually, so the strategy position is 8 and account position is 9. I can detect that by comparing PositionAccount and Position but I don't know how to force the strategy to adopt this new position without restarting it.
Tags: None
-
Hello ManTrader,
Thank you for your post.
AdoptAccountPosition will only come into play when a strategy is started.
However, in NinjaTrader 8, you can use the AddOn Framework and create a NinjaScript that:- Loops through the Account.Orders collection for the account to find active orders
- Subscribes to Account OrderUpdate events to look for any newly opened orders.
- Tracks these Orders in the script so they can be changed or cancelled with Account.Change or Account.Cancel
AddOn Development: https://ninjatrader.com/support/help...t_overview.htm
Order object - https://ninjatrader.com/support/help...n-us/order.htm
Account.Orders - https://ninjatrader.com/support/help...rs_account.htm
Account.OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm
Account.Change - https://ninjatrader.com/support/help...-us/change.htm
Account.Cancel - https://ninjatrader.com/support/help...-us/cancel.htm
Please let me know if I can be of further assistance.
-
Hello ManTrader,
Thank you for your reply.
NinjaScript Strategies are not able to see trades that are placed manually or from another instance of a strategy - the above will only allow you to monitor and cancel externally placed but unfilled orders placed to the account, but you would not be able to close a filled order using ExitLong().
Strategies have their own internal position and are only able to see orders placed through the strategy.
I recommend you have the strategy add a button and when the button is pressed, submit the "manual" entry order from from the strategy itself.
Below is a publicly available link to an example.
You could also use the Addon approach to detect changes to the account and drop using a NinjaScript strategy at all.
Last, here is a link that details strategy position vs account position.
https://ninjatrader.com/support/foru...199#post517199
And publicly available links to the help guide on the Addon approach.
https://ninjatrader.com/support/help...ount_class.htm
https://ninjatrader.com/support/help...rderupdate.htm
https://ninjatrader.com/support/help...tionupdate.htm
https://ninjatrader.com/support/help...-us/submit.htm
Please let us know if we may be of further assistance to you.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
43 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
20 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
30 views
1 like
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
47 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
38 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment