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

How To Count Current Open Orders ?

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

    How To Count Current Open Orders ?

    Hello Guys,

    Sometimes it can happen the case to enter a long position at around 1000 contracts on a "Market Price", so when the order reaches the broker, it can gets partially filled twice on different Entry Price Levels, let's say "200 contracts" and "800 contracts".

    In this case, I'll have 2 orders with 2 different TP and SL levels, because I'm setting the TP and SL immediately fixed at "5 Ticks", so basically I have (1 Position) but split into (2 Orders), now I want to get the count of how many orders are open, 1, 2 or 3 ....

    I found this : Positions.Length

    but this returns 1 all the time, because since I'm trading the same market, I'll all the time have 1 position, but what I need is to know how many ORDERS are open on each BarUpdate()

    Thank you very much

    #2
    Hello MohammedAmine,

    Thank you for your note.

    What I would suggest is to monitor in OnOrderUpdate or OnExecutionUpdate for a partial fill and increment a counter for the number of times the position sees a partial fill and finally fully fills. I'd advise taking a look at our example on this page of our help guide:



    This example demonstrates monitoring for the orders to update in OnOrderUpdate, and ensures the stops and targets are set for the correct amount overall via tracking when there are partial fills. You could adapt this logic to count the number of fills for a particular order which will tell you the number of stop/target pairs that are submitted.

    For example, when an entry order is submitted, set the counter to 0, and then each time there is a partial fill, increment the counter. You can then use that information however you wish in the strategy.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate W.

      Thnx for the quick reply, I'm not a good developer, I thought it would be a ready function to call, I mean everybody would need such a feature,

      I would really appreciate if you can draft for me how the code should be like, I understood nothing from the page you sent to me

      sorry for asking that and I really appreciate your help and support

      Thnx

      Comment


        #4
        Hello MohammedAmine,

        Thank you for your reply.

        In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients as well as our vendors. The samples we provide are intended to give you further direction to move forward, and are not intended to be used for copy and paste purposes.

        If you are interested in services in having the code written for you, I can have a representative of our EcoSystem reach out with more information on NinjaScript consultants who will be happy to do so.

        However, the basic logic necessary would be included in that example, so I'd advise studying that particular example and the pages it links closely to understand what's going on in the script as this will help you tremendously in designing your own strategy logic. Basically, you'd want to follow similar logic to how it sums up the partial fills, only instead of adding the order quantity, increment a counter variable by 1 each time you get a fill/partial fill.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Sparkyboy, Today, 10:57 AM
        0 responses
        3 views
        0 likes
        Last Post Sparkyboy  
        Started by TheMarlin801, 10-13-2020, 01:40 AM
        21 responses
        3,917 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by timmbbo, 07-05-2023, 10:21 PM
        3 responses
        152 views
        0 likes
        Last Post grayfrog  
        Started by Lumbeezl, 01-11-2022, 06:50 PM
        30 responses
        811 views
        1 like
        Last Post grayfrog  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X