Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Edit Rollover Date via code depending on historical volume of each contract

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

    Edit Rollover Date via code depending on historical volume of each contract

    Hi!

    I have 2 questions:
    1. How can I access data of the same day for 2 contract months via code?
      • I want to compare the Volume of one contract month to the Volume another contract month for the same day. I want to do this for all contract months of a specific instrument. So AddDataSeries is not an option here because I would have to have an AddDataSeries for each month. So I would have hundres of BarSeries, which I am not even sure is possible.
    2. How can I edit the Rollover Dates via code in a strategy for historical data?
      • I want to set the Rollover Dates depending on the Volume of each contract month.

    The result should be something like something like:
    If Volume[0] of contract month x+1 > Volume[0] of contract month x then set Time[0].Date as Rollover Date.

    It is very burdensome to go through each contract, compare the volumes and than change it in the Instruments settings manually.

    Thanks in advance!

    Kirk

    #2
    Hi Kirk, thanks for writing in. You would need to use AddDataSeries or do a BarsRequest to get another data series added in the script, there's no other way to access historical and real-time data through a script unless you use a REST API to access the data from another source. You can call AddDataSeries as many times as your computer CPU/memory will allow. Use this overload to minimize the performance impact:
    Code:
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, [B]int barsToLoad[/B], string tradingHoursName, bool? isResetOnNewTradingDay) We will want to minimize barsToLoad for maximum performance.
    Kind regards,
    -ChrisL

    Comment


      #3
      Thank you for the quick response. Is there a solution to my 2. quesiton (edit rollover date via code - see above)?

      Comment


        #4
        Hi Kirk, sorry I missed that question. You can use the C# function SendKeys() and use the feature where when input from the keyboard is ditected the intrument selector is activated:

        https://docs.microsoft.com/en-us/dot...owsdesktop-6.0 (publicly available)

        You can not re-call AddDataSeries with new parameters once a script has started, so you would need to do it in a new BarsRequest as another alternative.

        Kind regards,
        -ChrisL

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        595 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        554 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X