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

How to determine when contract has rolled over

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

    How to determine when contract has rolled over

    I'm using following chart:
    * Intraday chart (e.g., Renko)
    * Instrument of EMD 12-10 with default session template (which is CME US Futures RTH I believe)
    * Merge policy is set for MergeBackAdjusted

    I'm trying to determine the boolean logic to detect when we've rolled over to new contract within a continuous contract intraday chart that auto-merges many contracts per the merge policy setting. I want to detect this historically via the indicator if possible so I can see the precise first bar in my chart for a newly rolled over contract (e.g., in March, June, Sept, Dec for index type futures).

    I've tried a couple of ideas - like Bars.TotalTicks or Bars.TickCount for the variable to check against but still no luck, for example:

    Code:
    if (Bars.TotalTicks > 1)   //<---- Not sure of if expression here to detect rolled over contract
        //Found first bar of new contract that we've rolled over/merged into on this chart
        Print(String.Format("Rolled Over Contract Detected with {0} on TickCount {1}, Bar {2},  [{3}]", 
                Instrument.FullName, Bars.TickCount, CurrentBar, Time[0]));
    Maybe the problem I have is using RTH session template instead of ETH. If anyone has other ideas on how to accomplish rollover detection in the past within a continuous contract which uses merging, I'd be grateful in hearing your solution

    JD

    #2
    JD, unfortunately you could not programmatically access the rollover dates defined. You can perhaps add the dates yourself to the script for example as StringSeries and then check off against this.
    BertrandNinjaTrader 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