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 andrewtrades, Today, 04:57 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    6 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    7 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X