Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to place two orders with different stop loss & profit targets

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

    How to place two orders with different stop loss & profit targets

    Hi,

    I am developing a strategy which will place two separate orders given a set of entry conditions, the orders will be:
    • Order 1: Enter long with 1 contract, a 10 tick stop loss and a 20 tick profit target
    • Order 2: Enter long with 1 contract, a 30 tick stop loss and a 100 tick profit target

    I am coding this in NinjaScript but I am not able to get the code to execute two orders, the first is placed but the second is ignored.

    In OnStateChange() I have...
    Code:
    [INDENT]else if (State == State.Configure)[/INDENT][INDENT=2]{[/INDENT][INDENT=3]SetStopLoss(@"First", CalculationMode.Ticks, 10, false);[/INDENT][INDENT=3]SetProfitTarget(@"First", CalculationMode.Ticks, 20);[/INDENT][INDENT=3]SetStopLoss(@"Second", CalculationMode.Ticks, 30, false);[/INDENT][INDENT=3]SetProfitTarget(@"Second", CalculationMode.Ticks, 100);[/INDENT][INDENT=2]}[/INDENT]
    In OnBarUpdate() when my entry conditions are true I have...

    Code:
    [INDENT]if (entry conditions == true)[/INDENT][INDENT=2]{[/INDENT][INDENT=3]EnterLong(1, @"First");
    EnterLong(1, @"Second");[/INDENT][INDENT=2]}[/INDENT]
    Can you provide any guidance on why my second order isn't executing.

    Many thanks,

    Neil

    #2
    I have resolved this query...I changed the EntryHandling to EntryHandling.UniqueEntries and it works now.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    165 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    85 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    127 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    207 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    185 views
    0 likes
    Last Post CarlTrading  
    Working...
    X