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 argusthome, 03-08-2026, 10:06 AM
|
0 responses
58 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
39 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
19 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
21 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
51 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment