CloseStrategy(string) actually closing positions and cancelling pending orders, I have checked the help guide and also tried it. Can you please advise what syntax I should use to only disable the strategy without closing open positions and without canceling any pending order. Thanks in advance.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Closing strategy without closing pending orders or open position
Collapse
X
-
Closing strategy without closing pending orders or open position
Hi,
CloseStrategy(string) actually closing positions and cancelling pending orders, I have checked the help guide and also tried it. Can you please advise what syntax I should use to only disable the strategy without closing open positions and without canceling any pending order. Thanks in advance.Tags: None
-
Hello asmmbillah,
You can use SetState(State.Terminated) to disable the strategy without the CloseStrategy actions which will "Cancels all working orders, closes any existing positions, and finally disables the strategy".
https://ninjatrader.com/support/help...8/setstate.htm
https://ninjatrader.com/support/help...sestrategy.htmChelsea B.NinjaTrader Customer Service
Comment
-
-
Hi CheseaB,
The problem I face now is, I have open position, pending orders on the account. When I enable the strategy, it cancels all the pending orders keeping the position open. Is there anyway I can enable the strategy without cancelling any pending order?Last edited by asmmbillah; 01-25-2021, 06:47 AM.
Comment
-
Hello asmmbillah,
This would only be possible if in the historical data the orders match with the previously submitted real-time orders and the Immediately Submit start behavior is used. A match means the order type, signal name, submission and fill time, and quantity must match. Otherwise the strategy would not match the order and automatically cancel it.
https://ninjatrader.com/support/foru...182#post783182Chelsea B.NinjaTrader Customer Service
Comment
-
Thanks, I have tried immediate submit and immediate submit synch account position options according to your post link and contents there. Nothings works. In both the occassions, it cancels the pending orders when I re-enable the strategy. Please advise.
Comment
-
It places orders on BarsInProgress == 0; Do you want me to add AddDataSeries() for 1 tick and execute pending orders on BarsInProgress == 1?
Comment
-
Hello asmmbillah,
That would depend on the type of orders and if the position is the same at the same time and if the orders are being submitted at the same price and time.
If the orders do not match, they cannot be resumed.
If the time or price is different, the orders will be automatically cancelled.
You can use TraceOrders and Print() to print the order object in OnOrderUpdate() and verify the order prices and times are the same from the real-time, and then with the historical after being reloaded.Chelsea B.NinjaTrader Customer Service
Comment
-
Thanks for your reply. Pending entry orders are generated with click of custom button, but SL and PT pending orders are generated with entry order onexecutionupdate. In that case, it will not match as the start of the process is started with click of a button. What is your advised in this case so that I can re-enable and keep the pending orders?
Comment
-
Hello asmmbillah,
Orders that are generated from button clicks will not be submitted in historical data, will not be matched, and will automatically be cancelled.
Perhaps you would prefer to use an addon or indicator with the addon approach to send orders instead of an automated strategy?
You could try writing the order information to a text file, reading this from text file in historical data, and submitting the order historically at the same time and price.
https://ninjatrader.com/support/help...o_write_to.htm
https://ninjatrader.com/support/help...o_read_fro.htmChelsea B.NinjaTrader Customer Service
Comment
-
Thanks. I think read write may be suitable. But question is, if the strategy is disabled, I want to write the pending orders. Should I write in state=state.terminated ? and how I can access pending order within orders to write them in file?
Comment
-
Hello asmmbillah,
State.Terminated would be correct.
You can add the orders to an array or list and loop through them.
Check the OrderStates of the orders.
https://ninjatrader.com/support/help.../nt8/order.htmChelsea B.NinjaTrader Customer Service
Comment
-
Thanks and will it be true even for live account where normally working and accepted orders resides within broker's server? are those also get cancelled similar which we discussed in post #11?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by NtFan, 03-05-2021, 04:12 PM
|
2 responses
12 views
0 likes
|
Last Post
|
||
Started by sushilake, Today, 12:21 PM
|
2 responses
11 views
0 likes
|
Last Post
![]()
by sushilake
Today, 03:57 PM
|
||
Started by Gerik, Today, 02:31 PM
|
6 responses
17 views
0 likes
|
Last Post
![]()
by hedgeplay
Today, 03:58 PM
|
||
Started by EB Worx, Today, 02:09 PM
|
0 responses
4 views
0 likes
|
Last Post
![]()
by EB Worx
Today, 02:09 PM
|
||
Started by Revazi123, Today, 01:01 PM
|
0 responses
10 views
0 likes
|
Last Post
![]()
by Revazi123
Today, 01:01 PM
|
Comment