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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    50 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X