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

Load data in multi-time frame indicator

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

    Load data in multi-time frame indicator

    Hello,
    I am using a multi-time frame indicator in a 1 min chart. so my main time frame is 1 min.
    To allow for relative quick update I use load data based on 5 days
    For my second time frame I want to use daily data for a period longer than 5 days.
    What I would like to have is for the 1 min data to be based on 5 days and the daily data to be based on 20 days.
    Is this possible ?
    if yes, can you point me in the direction ?
    Thanks


    #2
    Hello Leope,

    You may be able to use the following overload for AddDataSeries to achieve that:

    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)

    This includes a BarsToLoad parameter to specify a number of bars to load. For a daily series that would likely work fairly well because it is a whole number that matches the bar 1 day = 1 bar.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi,
      Thanks for your answer.
      What I did was , in the (State == State.Configure) :
      AddDataSeries(BarsPeriodType.Day, 20,"None",false);

      I get error messages:
      - The best overloaded method match for ... has some invalid arguments
      - Argument1: cannot convert from 'NinjaTrader.Data.BarsPeriodType' to string
      - Argument2: cannot convert from int 'NinjaTrader.Data.BarsPeriod

      What is wrong here ? do I need to add 'instrumentName', I tried it but still get compile errors.
      Thanks for your help!

      Comment


        #4
        Hello Leope,

        Yes the values you have used don't match what the overload wants, you are missing the BarsPeriod so the remainder of the parameters are in the wrong location. There are some different samples located on the AddDataSeries page, one of the tips provides an example of a BarsPeriod.



        new BarsPeriod() { BarsPeriodType = (BarsPeriodType)14, Value = 10, Value2 = 20 }

        In place of (BarsPeriodType)14 you could use a normal type like BarsPeriodType.Day,

        You also need a valid trading hours name, you can look in the Trading hours manager if you need to locate the names of the various hours for your instrument.





        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi,
          Thanks
          I looked at the documentation, and made some progress. Now, how can I make the added data series non-instrument dependent ?
          So for example , I have this:
          AddDataSeries("AAPL",new BarsPeriod { BarsPeriodType = BarsPeriodType.Day, Value = 1 }, 20,"Default 24x7",false);
          which compiles ok.
          Now instead of having a fixed instrumentName such as "AAPL" , I want the dataseries to be loaded with the current instrument that is used on my chart.
          If I omit the 1'st argument (instrument name) I get compile errors .
          Is it possible to use the current instrument?
          Thanks

          Comment


            #6
            Hello Leope,

            Right now it is not supported to have a dynamic instrument with AddDataSeries. You may see some scripts that use the Instrument variable here however that will fail in some tools so we really have no suggestion for adding dynamic data right now. I will add your vote to the feature request that we have for this.

            For a final version of the script what would suggest would be to make instances or make a master version of the code like StraetgyMaster. Then you can do a SaveAs from that for each new instrument and give it a specific name for that instrument. That also allows for customization per instrument if you needed it and you also retain the original code in case you need to update it later. The downside is that you would have to update the individual scripts if something changes.



            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hello Jesse,
              Thanks. I don't understand:
              Doesn't the AddDataSeries(Data.BarsPeriodType.Day, 1) use dynamic instrument ? since this works fine,
              All I wanted was to use the same AddDataSeries with the barsToLoad.
              How does adding the 'barsToLoad' change the AddDataSeries(Data.BarsPeriodType.Day, 1) from non-dynamic to dynamic ?
              Thanks

              Comment


                #8
                Hello Leope,

                That is a supported overload which inherits the primary instrument. That is not the same as providing a variable which won't always work.

                At this time there is not a way to reconfigure the overloads, each is used for a different purpose and in this case you would not be able to inherit the primary with the overload with BarsToLoad.


                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,603 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                8 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
                4 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                12 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X