Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ETFVoyageur, Today, 02:10 AM
    0 responses
    8 views
    0 likes
    Last Post ETFVoyageur  
    Started by rayyyu12, Today, 12:47 AM
    0 responses
    8 views
    0 likes
    Last Post rayyyu12  
    Started by ETFVoyageur, 05-07-2024, 07:05 PM
    17 responses
    137 views
    0 likes
    Last Post ETFVoyageur  
    Started by ETFVoyageur, Yesterday, 10:13 PM
    1 response
    11 views
    0 likes
    Last Post ETFVoyageur  
    Started by somethingcomplex, Yesterday, 10:36 PM
    0 responses
    10 views
    0 likes
    Last Post somethingcomplex  
    Working...
    X