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

Pyramiding orders

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

    Pyramiding orders

    Hi,

    I've been trying for a couple days to enter a position, immediately set a stop loss and profit target, then if the position is up enough, add a second contract and modify the existing stop loss and profit target to account for my new average price and quantity. I can't seem to get it working correctly though. Usually my problem is that my stop and profit target quantities never update to reflect the fact that I am now holding two (or more) contracts. They always execute with a quantity of one.

    Can you point me towards some documentation or some code samples (preferable) that describe how to do this in NT8?

    If possible, I assuming using managed orders is preferable. Additionally, I'd like the orders to actually exist as Stop Market or Stop Limit OCO orders vs my code monitoring and just creating market orders on the fly as conditions dictate.

    #2
    Hello NickyD,

    Thanks for opening the thread.

    SetProfitTarget() and SetStopLoss() will create their own unique exits, so I may suggest to follow the Advanced Order Handling rules of the Managed Approach so you can use Order objects to track your orders, and then you can use OnExecutionUpdate() to update your bracketed Profit Target and Stop Loss orders. These orders would then have to be submitted from the Exit methods for easy assignment to an Order object.

    The Managed Approach does not offer OCO through its entry and exit conditions, but the logic can be programmed in OnOrderUpdate().

    If you want to utilize OCO, you can use the Unmanaged Approach.

    I'll include a link to a reference sample that demonstrates using Order objects, OnOrderUpdate() and OnExecutionUpdate(). I'll also include an Unmanaged example and some openly available documentation on the Advanced Order Handling rules to provide further direction managing your orders as you desire.

    SampleOnOrderUpdate (Please see documentation herein) - https://ninjatrader.com/support/foru...ead.php?t=7499

    Advanced Order Handling - https://ninjatrader.com/support/help...#TheOrderClass

    ChangeOrder() - https://ninjatrader.com/support/help...hangeorder.htm

    Unmanaged Approach - https://ninjatrader.com/support/help...d_approach.htm

    Please let me know if I may be of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      This got me to where I wanted to be, especially using the ChangeOrder().

      Thanks for the thorough response!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by chartchart, 05-19-2021, 04:14 PM
      3 responses
      577 views
      1 like
      Last Post NinjaTrader_Gaby  
      Started by bsbisme, Yesterday, 02:08 PM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by prdecast, Today, 06:07 AM
      0 responses
      3 views
      0 likes
      Last Post prdecast  
      Started by i019945nj, 12-14-2023, 06:41 AM
      3 responses
      60 views
      0 likes
      Last Post i019945nj  
      Started by TraderBCL, Today, 04:38 AM
      2 responses
      18 views
      0 likes
      Last Post TraderBCL  
      Working...
      X