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

Avoid multiple orders

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

    Avoid multiple orders

    Hello,

    I just found the function EnterLongLimit here in the forum and in the helpGuides.

    To better understand the mechanism, how can I avoid that on each bar my Strategy fires a new order to the order execution network and how can I double-check which orders are already in place before I enter a new order or replace the current order that has been already sent to the system by the Strategy one or more bars before?

    Best regards
    Gerik


    #2
    Hello Gerik ,

    Thank you for the post .

    To know which orders are already in place generally requires that you track that yourself. You can observe the current position information or also store order information to track where you script is currently at.

    EnterLongLimit is actually made so that it should be called for each bar where it should stay active. It would not make a new order unless you provided a new unique signal name each time it is called.

    By default with the managed order handling a limit type order will be cancelled after 1 bar if you don't call this method again. Alternatively in manual coding you can use IsLiveUntilCancelled with these methods to keep them active and only call the method once to submit it.

    You can see the different ways this method can be called in the help guide:


    Code:
    EnterLongLimit(double limitPrice)
    EnterLongLimit(double limitPrice, string signalName)
    EnterLongLimit(int quantity, double limitPrice)
    EnterLongLimit(int quantity, double limitPrice, string signalName)
    The following method variation is for experienced programmers who fully understand Advanced Order Handling concepts:
    EnterLongLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName)
    And you can see all of the order handling methods here:




    You can find a sample of working with order objects in the following link:




    Storing your orders to variables allows you to keep track of what orders your script has open and what states they are in. This sample provides some explanation of how to "catch" orders in the OnOrderUpdate/OnExecutionUpdate overrides and then track or use them later on. The same would happen for entry orders you use, you could "catch" the order after its submitted to further control your logic or know it is active.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sightcareclickhere, Today, 01:55 PM
    0 responses
    1 view
    0 likes
    Last Post sightcareclickhere  
    Started by Mindset, 05-06-2023, 09:03 PM
    9 responses
    258 views
    0 likes
    Last Post ender_wiggum  
    Started by Mizzouman1, Today, 07:35 AM
    4 responses
    18 views
    0 likes
    Last Post Mizzouman1  
    Started by philmg, Today, 01:17 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by cre8able, Today, 01:01 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X