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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    68 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    61 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X