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

existing orders

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

    existing orders

    in my output window i keep getting repeat orders sent as conditions keep being met.

    as such i get Ignored PlaceOrder() method: ' Reason='There already is a matching order with same prices and quantity'

    is there a condition i can put in the code to check for existing order so that only unique orders presented in the output window

    #2
    Hello fiddy,

    Thank you for your inquiry.

    What you can do to prevent this message from continuously occurring in your output is by utilizing a boolean, for example, to prevent the order from being called again.

    As an example:
    Code:
    private bool alreadySubmitted = false;
    
    protected override void OnBarUpdate()
    {
         if (/*some entry condition*/ && alreadySubmitted == false)
         {
              EnterLongLimit(0, true, 1, 1000, "TheEntryOrder");
              alreadySubmitted = true;
         }
    }
    By setting the alreadySubmitted boolean to true, the if condition will not be true and EnterLongLimit(), with the same parameters, will not be called again.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      thanks Zachary, how would you suggest resetting it to false once the position has been exited so multiple trades can be done.
      i cannot use Position.MarketPosition == MarketPosition.Flat as if the order hasnt been filled yet i will start to get output again

      Comment


        #4
        Originally posted by fiddy View Post
        thanks Zachary, how would you suggest resetting it to false once the position has been exited so multiple trades can be done.
        i cannot use Position.MarketPosition == MarketPosition.Flat as if the order hasnt been filled yet i will start to get output again
        Use the OnPositionUpdate() handler, and reset the bool if Position.Quantity is zero.

        Comment


          #5
          Hello fiddy,

          koganam provides a great way to check if you are out of the position.

          More about OnPositionUpdate() can be found in the NinjaTrader help guide here: http://ninjatrader.com/support/helpG...tionupdate.htm

          Please, let us know if we may be of further assistance.
          Zachary G.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rajendrasubedi2023, Today, 09:50 AM
          2 responses
          14 views
          0 likes
          Last Post rajendrasubedi2023  
          Started by geddyisodin, Today, 05:20 AM
          4 responses
          29 views
          0 likes
          Last Post geddyisodin  
          Started by geotrades1, Today, 10:02 AM
          2 responses
          8 views
          0 likes
          Last Post geotrades1  
          Started by ender_wiggum, Today, 09:50 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by bmartz, Today, 09:30 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X