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

Multiple OCO order in NinjaScript

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

    Multiple OCO order in NinjaScript

    I have a "Zone" Strat built, but it is only taking the last (most current) order, and I need to keep orders on the chart until hit or removed.
    Let's say there's a Long condition. A Buy Stop is placed above the market price. If that level gets breached, a Long is place and a Target and Stop are also place as an OCO order. This works perfectly. But let's say another Long condition shows up. It is removing the previous Buy Stop and placing a new order at the most recent condition. How do I keep both orders on until hit?

    I also have working a Buy Stop and a Sell Stop at the same time. If the Buy Stop is hit, it removes the Sell Stop until the Long position is completed, then adds the Sell Stop back on. This works perfectly.

    However, as you can see on the chart attached, there are times when I need to have the orders stacked up as they will routinely be executed all at the same time. This is where I am having trouble.
    In short, I need to have Buy Stop OCO and Sell Stop OCO added to the chart, AND STAY THERE, until hit or canceled manually.

    Green is Long entry
    Red is Short entry
    Yellow is target
    Blue shows the candles that passed through multiple zones at the same time.
    Attached Files

    #2
    Hi Robert, thanks for posting. You must set EntriesPerDirection = 2 in State.SetDefaults to allow more than 1 entry in the same direction. If you are using SetStopLoss and SetProfitTarget, you must also have unique signal name for each order e.g.

    SetStopLoss("Enter1", CalculationMode.Ticks, 10, false);
    EnterLong("Enter1");

    SetStopLoss("Enter2", CalculationMode.Ticks, 10, false);
    EnterLong("Enter2");
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by frslvr, 04-11-2024, 07:26 AM
    9 responses
    123 views
    1 like
    Last Post caryc123  
    Started by rocketman7, Today, 09:41 AM
    4 responses
    15 views
    0 likes
    Last Post rocketman7  
    Started by selu72, Today, 02:01 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by WHICKED, Today, 02:02 PM
    2 responses
    16 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by f.saeidi, Today, 12:14 PM
    8 responses
    21 views
    0 likes
    Last Post f.saeidi  
    Working...
    X