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

Get Historical Bars

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

    Get Historical Bars

    Hi all,
    this is my first post on the forum as I'm quite new to Ninja.

    I'm trying to develop a strategy in Ninja, and I need to get some historical daily bars EOD closing in order to define some parameters:

    Ie. I'm trading FESX and I want to know what was the closing price of FDAX yesterday.

    I tried to go down the route of Add without too much success, as it seems this requires to wait for the first bar of FESX to be created while I would like to know the number for FDAX before starting the strategy.

    Any help appreciated.

    Thanks

    #2
    Hello phi3zz0,

    Welcome to the NinjaTrader Support Forums!

    If you are applying your Strategy to the FESX instrument that would be expected, as it would load up the Primary Data Series (the Input Series that you set your strategy to) first and then it would process your time-frame/instruments next. You can still be able to access the data historically, but you may want to just make sure that you have enough bars before your strategy is being calculated would be one way around it.

    An example for checking to make sure you have enough bars before calculated can be seen at the following thread.



    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC,
      thanks for your reply. I would like to understand if it's possible to call the method to calculate my parameters before the strategy starts as this will avoid to check an additional condition when the strategy is running.

      If not I will try to stick to your solution which, if I'm getting it right, is to calculate my parameters the first bar which I suppose is historical therefore will be downloaded at run time.

      Thanks
      Antonio

      Comment


        #4
        Hello Antonio,

        The method that would be called as your Strategy starts so that you can check any variable or parameters would be the OnStartUp() method. There you can check your variable and logic before OnBarUpdate(). Note that this method would not have access to any Pricing data, only variable and resources. If you need Pricing data you would have to use the OnBarUpdate() method.

        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC,
          fine. I've dropped a condition OnBarUpdate like

          if(CurrentBar == Minimum Bars Required)
          {
          //set my parameters
          }

          In this way the condition to be evaluated is simple and quicker to do. Is there not any other way to do this without having an additional (useless and time consuming) condition into the code?

          Thanks
          Antonio

          Comment


            #6
            Hello Antonio,

            What parameters are you trying to set inside of that condition?

            A check of CurrentBar to an integer value is not very time consuming and very quick to be able to process.
            JCNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rayyyu12, Today, 12:47 AM
            0 responses
            2 views
            0 likes
            Last Post rayyyu12  
            Started by ETFVoyageur, 05-07-2024, 07:05 PM
            17 responses
            133 views
            0 likes
            Last Post ETFVoyageur  
            Started by ETFVoyageur, Yesterday, 10:13 PM
            1 response
            8 views
            0 likes
            Last Post ETFVoyageur  
            Started by somethingcomplex, Yesterday, 10:36 PM
            0 responses
            9 views
            0 likes
            Last Post somethingcomplex  
            Started by sofortune, 05-10-2024, 10:28 AM
            5 responses
            22 views
            0 likes
            Last Post sofortune  
            Working...
            X