Announcement

Collapse
No announcement yet.

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");

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    54 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    71 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X