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

SetStopLoss, MTF, and the first Bars context of that instrument

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

    SetStopLoss, MTF, and the first Bars context of that instrument

    I am looking at language in the example ProfitChaseStopTrailSetMethodsExample found at the following page:

    https://ninjatrader.com/support/foru...s-cs-expecting

    Code:
    [URL="https://ninjatrader.com/support/forum/forum/ninjatrader-8/platform-technical-support-aa/97419-priceos-cs-expecting"]protected override void OnStateChange()
    {
                else if (State == State.Configure)
                {
                    AddDataSeries(BarsPeriodType.Tick, 1);
                 }
    
    
    }  
    
    
    if (BarsInProgress == 1 && Position.MarketPosition == MarketPosition.Long)
                {
    
                    if (UseStopLoss && TrailStopLoss && Close[0] > currentSlPrice + StopLossDistance * TickSize)
                    {
                        currentSlPrice = Close[0] - StopLossDistance * TickSize;
                        SetStopLoss(CalculationMode.Price, currentSlPrice);
                    }
                }[/URL]
    The SetStopLoss documentation states the following:
    • Should you have multiple Bars objects of the same instrument while using SetStopLoss() in your strategy, you should only submit orders for this instrument to the first Bars context of that instrument. This is to ensure your order logic is processed correctly and any necessary order amendments are done properly.
    In the above example, the second Bars object is called for SetStopLoss. Can you please clearly define "first Bars context of that instrument"? Does that mean the most granular resolution or does that mean the primary Bars?

    Thanks
    Last edited by Epistemophilic; 06-17-2020, 04:59 PM.

    #2
    Hello Epistemophilic,

    Thanks for your post.

    Just to let you know we are looking into this and will be updating this thread later.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Epistemophilic,

      Thanks for your patience.

      Set methods will use the primary data series to fill orders and the next bar in that series is used to determine how the order will fill. If we adjust the stop loss on a secondary series, this will then affect how the stop loss gets processed. The approach mentioned here will work fine in realtime and while backtesting for most cases, but you may see some discrepancies with how the stop loss gets placed and filled when backtesting before the trailing behavior starts.

      For consistency with backtesting and realtime trading, Exit orders specifying the BarsInProgress for the single tick data series can be used to consistently have orders filled with intrabar granularity.

      Further details can be found here - https://ninjatrader.com/support/help...ionInformation

      We look forward to assisting.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      3 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      6 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Working...
      X