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 junkone, 04-28-2024, 02:19 PM
          8 responses
          92 views
          1 like
          Last Post brucerobinson  
          Started by mkouitra, 10-23-2021, 04:40 PM
          17 responses
          1,962 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by Vietanhnguyen2hotmailcom, 05-03-2024, 10:29 AM
          4 responses
          29 views
          0 likes
          Last Post Vietanhnguyen2hotmailcom  
          Started by PhillT, 04-19-2024, 02:16 PM
          4 responses
          37 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          40 views
          0 likes
          Last Post ageeholdings  
          Working...
          X