Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

SubmitOrderUnmanaged alternative for un-managed trades

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    Originally posted by set2win View Post
    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.
    Hmm, sounds like a valid technique.

    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.

    Comment


      #3
      Hint:

      The event handler for your close strategy position button
      probably has code like this,

      Code:
      if (!myCloseButtonPressed)
      {
          if (Position.MarketPosition != MarketPosition.Flat)
          {
              ... submit exit order ....
              myCloseButtonPressed = true;
          }
      }
      You should be resetting myCloseButtonPressed back to false
      only after the position is flat, which can be detected from two
      places, OnPositionUpdate and OnOrderUpdate.

      Comment


        #4
        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 using
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jonafare, 12-06-2012, 03:48 PM
        5 responses
        3,986 views
        0 likes
        Last Post rene69851  
        Started by Fitspressorest, Today, 01:38 PM
        0 responses
        2 views
        0 likes
        Last Post Fitspressorest  
        Started by Jonker, Today, 01:19 PM
        0 responses
        2 views
        0 likes
        Last Post Jonker
        by Jonker
         
        Started by futtrader, Today, 01:16 PM
        0 responses
        8 views
        0 likes
        Last Post futtrader  
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,792 views
        0 likes
        Last Post aligator  
        Working...
        X