I have a strategy button to close the trade that submits this order. So the problem is really 2 fold. The button is cycling, because I added a print statement "Button Pressed" and it could print multiple times from one button press, which in turn seems to be activating repeated submits , It has been happening particularly with Rithmic account not the Sim but the actually trading account. Rithmic is sending repeated orders which ends with me being in another trade that was not requested. It has created quite a difficulty in trying to use this technique so I end up using the Close button on Chart trader which of course ends the trade but also ends the strategy. My questions are: Is there an alternative to closing out the position without ending the strategy? and Second question: is related to the button press, How to prevent the cycling? To the button press i do have a boolean that is checked prior to running code that gets set once it is pressed: button=false, but it still cycles. If you need code to see more I can try to show some of it.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
SubmitOrderUnmanaged alternative for un-managed trades
Collapse
X
-
SubmitOrderUnmanaged alternative for un-managed trades
Having a problem with closing a trade using the SubmitOrderUnmanaged(1,OrderAction.Sell,OrderType. Market,Position.Quantity,0,0,"","ClosePosition");
I have a strategy button to close the trade that submits this order. So the problem is really 2 fold. The button is cycling, because I added a print statement "Button Pressed" and it could print multiple times from one button press, which in turn seems to be activating repeated submits , It has been happening particularly with Rithmic account not the Sim but the actually trading account. Rithmic is sending repeated orders which ends with me being in another trade that was not requested. It has created quite a difficulty in trying to use this technique so I end up using the Close button on Chart trader which of course ends the trade but also ends the strategy. My questions are: Is there an alternative to closing out the position without ending the strategy? and Second question: is related to the button press, How to prevent the cycling? To the button press i do have a boolean that is checked prior to running code that gets set once it is pressed: button=false, but it still cycles. If you need code to see more I can try to show some of it.Tags: None
-
Hmm, sounds like a valid technique.Originally posted by set2win View PostHaving a problem with closing a trade using the SubmitOrderUnmanaged(1,OrderAction.Sell,OrderType. Market,Position.Quantity,0,0,"","ClosePosition");
I have a strategy button to close the trade that submits this order. So the problem is really 2 fold. The button is cycling, because I added a print statement "Button Pressed" and it could print multiple times from one button press, which in turn seems to be activating repeated submits , It has been happening particularly with Rithmic account not the Sim but the actually trading account. Rithmic is sending repeated orders which ends with me being in another trade that was not requested. It has created quite a difficulty in trying to use this technique so I end up using the Close button on Chart trader which of course ends the trade but also ends the strategy. My questions are: Is there an alternative to closing out the position without ending the strategy? and Second question: is related to the button press, How to prevent the cycling? To the button press i do have a boolean that is checked prior to running code that gets set once it is pressed: button=false, but it still cycles. If you need code to see more I can try to show some of it.
The code you're using to guard against the 'cycling' probably needs
some tweaking.
I mean, if your logic was correct, it would not still be 'cycling', right?
Once it is set, when & where does your boolean flag get reset?
Yes, please post your code.
-
Hint:
The event handler for your close strategy position button
probably has code like this,
You should be resetting myCloseButtonPressed back to falseCode:if (!myCloseButtonPressed) { if (Position.MarketPosition != MarketPosition.Flat) { ... submit exit order .... myCloseButtonPressed = true; } }
only after the position is flat, which can be detected from two
places, OnPositionUpdate and OnOrderUpdate.
Comment
-
Hello set2win,
I have an example of submitting orders from button clicks you may find helpful.
I need some guidance. I need to create a script that has 3 plots that are public and they plot either a 1 or 0. But I need to create another indicator that has 3 chart buttons that sets these variables. The first indicator needs to get those values from the second indicator depending on the button clicks. Because of usingChelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
55 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
132 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
73 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|
Comment