Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LimitOrders and StopLoss/ProfitTargets

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

    LimitOrders and StopLoss/ProfitTargets

    It may be a rookie question so apologies but here it is.

    Starting from a vrey simple strategy :
    Code:
    protected override void Initialize(){
         CalculateOnBarClose=true;
         EntryHandling=EntryHandling.AllEntries;
         EntriesPerDirection=10;
         SetStopLoss(CalculationMode.Ticks,stpTicks);
         SetProfitTarget(CalculationMode.Ticks,ptTicks);
    }
    
    protected override void OnBarUpdate(){
         if (way[0] == 1) EnterLong();
         else if (way[0] == -1) EnterShort();
         SetProfitTarget(CalculationMode.Ticks,ptTicks);
    }
    Everything works, stoploss,profits targets and positions in both directions.

    However, if I work with limit orders
    Code:
    protected override void OnBarUpdate(){
         if (way[0] == 1) EnterLongLimit(Close[0]-ticksAway*TickSize);
         else if (way[0] == -1) EnterShort(Close[0]+ticksAway*TickSize);
         SetProfitTarget(CalculationMode.Ticks,ptTicks);
    }
    Then only one position works (the first of the day, then only entries in that same direction) - stoploss and profit targets fine for that direction.

    All positions/trades from opposite direction are then disregarded, like there's some interference somewhere. How's that ?

    #2
    Hello,

    When using Limit/Stop orders for Entry, there are some order handling rules you'll need to be aware of.

    You can add TraceOrders = true to your Initialize() method and you can then view output which will tell you exactly why the order was ignored through Tools > Output window - TraceOrders

    The Internal Order Handling Rules are listed on the following link:

    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    637 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    572 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X