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

Multiple entries with unique TP/SL

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

    Multiple entries with unique TP/SL

    Hello,

    Is possible in a strategy to enter in a trade multiple times (if condition is true) with different TP/SL generated by ATR?

    I mean, each time formation is formed, enter a trade, regardless number of current opened positions. TP and SL would be generated by ATR(4), TP - ATR4 and SL - ATR4, Each new trade would have different TP/SL.

    Currently in my strategy i use iorders but i dont really know how to program multiple entries and have several opened positions with each unique TP/SL generated by ATR.


    Code:
    EntriesPerDirection = 1000;
    EntryHandling = EntryHandling.AllEntries;
    
    if (High[1] > High[2] && High[1] > High[3] && High[1] > Hi}gh[4] && High[0] > High[1])
    
                
                && High[1] > upperValue_BB    
            ) 
        
                {
                    DrawArrowUp(CurrentBar.ToString(), false, 0, Low[0], Color.Lime); 
                   
                    entryOrderLong = EnterLongStop(0, false, 1, High[0] + 1 * TickSize,     "enter");
                }
    
      protected override void OnOrderUpdate(IOrder order)
            {
             
            if (entryOrderLong != null && entryOrderLong == order)
            {
                if (order.OrderState == OrderState.Filled)
                {
           
                    exitLimitLong = ExitLongLimit(0, true, 1, entryOrderLong.AvgFillPrice + ATR(value)[0], "TP", "enter");
                    exitStopLong = ExitLongStop(0, true, 1, entryOrderLong.AvgFillPrice - ATR(value)[0], "SL", "enter");    
    
                   
                }
            }
    Can i somehow program a code in OnOrderUpdate that would be called each time my condition is true and set TP/SL values according to current ATR?

    I would not like to program multiple blocks of code in OnOrderUpdate to set limit/stop orders.

    Thank you

    #2
    Hello Filip88,


    You could program a code in OnOrderUpdate that would be called each time my condition is true and create your TP/SL values according to current ATR.


    If you are relying on the OnOrderUpdate() method to trigger actions such as the submission of a stop loss order when your entry order is filled ALWAYS reference the properties on the IOrder object passed into the OnOrderUpdate() method.


    Please note, if you want to drive your strategy logic based on order fills you must use OnExecution() instead of OnOrderUpdate(). OnExecution() is always triggered after OnOrderUpdate(). There is internal strategy logic that is triggered after OnOrderUpdate() is called but before OnExecution() that can adversely affect your strategy if you are relying on tracking fills within OnOrderUpdate().
    Shawn B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ghoul, Today, 06:02 PM
    3 responses
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    44 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    20 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    180 views
    0 likes
    Last Post jeronymite  
    Started by DanielSanMartin, Yesterday, 02:37 PM
    2 responses
    13 views
    0 likes
    Last Post DanielSanMartin  
    Working...
    X