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

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
    Chris L.NinjaTrader Customer Service

    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
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Max238, Today, 01:28 AM
        2 responses
        26 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by Shansen, 08-30-2019, 10:18 PM
        25 responses
        949 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by JonesJoker, 04-22-2024, 12:23 PM
        8 responses
        41 views
        0 likes
        Last Post JonesJoker  
        Started by timko, Today, 06:45 AM
        0 responses
        4 views
        0 likes
        Last Post timko
        by timko
         
        Started by Waxavi, 04-19-2024, 02:10 AM
        2 responses
        39 views
        0 likes
        Last Post poeds
        by poeds
         
        Working...
        X