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

Reload all historical data by indicator on each BarClose?

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

    Reload all historical data by indicator on each BarClose?

    Hi, hope anyone can help.
    I was wondering if it is possible to add the manual "Reload all historical data" also into my custom indicator after each bar closes (OnBarClose).
    To put it in other words I need a simple line of code under OnBarUpdate that would call that function (Reload all historical data) so I can be sure all data on the chart are correct.
    I haven´t found anything in the Ninjascript manual about that.

    Thanks
    Peter

    #2
    Hello cyberpete76,

    That would not be something you should be doing from NinjaScript especially on each bar close, that would cause a large amount of cpu usage and during the reload time you will miss incoming data. Generally there wouldn't be a reason to reload all historical data during a trading session because each new bar is being generated by the live market data. Those bars can be saved as historical by enabling the option for that in the Tools -> Options -> Market data menu.

    JesseNinjaTrader Customer Service

    Comment


      #3
      OK, let me explain my problem.
      I recently encountered a situation, where I had a signal in my strategy for an EMA crossing and two bars later the market price went above ema20. In my strategy that sets a flag for a "no go" for an upcoming entry signal. Ten bars later the entry situation occured but as I had the "no go flag" active I did not enter the trade. But when I reloaded all historical data manually the bar´s candle wick which caused that "no go flag" simply disappeard and my entry signal became valid. But that was already after I missed the entry point and the whole trade. So by adding a "Reload all historical data" function into the code at each OnBarUpdate I would prevent that from happening.
      I found the manual about the ReloadAllHistoricalData(); function and added that line to my code as the first thing to be executed in the OnBarUpdate part. It it does not seem to do anything. Instead when I call the Reload all historical data manually on the chart where I have that modified indicator, the "Loading ..." text in the upper left corner of the chart appears but nothing else happens and the data loading is never finished.
      I hope there is a way how to solve my problem as apparently sometimes the real market data are not correctly plotted on the chart. Btw. I have compared the data also in two other platforms and the charts look all the same, but only with the Reloaded historical data in NT.

      Comment


        #4
        Who is your broker/data provider?

        Comment


          #5
          Well, I am using Forex.com now but I hade these problems in the past also with the Ninjatrader connection and also with FXCM.

          Comment


            #6
            Hello cyberpete76,

            If you are having connection problems that may be one reason the data would look different if you reload the data. If you otherwise don't see changes in the data but changes in the outcome from the strategy that's likely the strategies logic playing a part when you reload it.

            To get to the bottom of why that happened you would have had to run the script and used prints in realtime to see how that time period equated logically and then after reloading it output that data again to see how it processed historically. That would give you an answer to why that happened.

            The method you found in the help guide is only intended to be used only in the OnConnectionStatusUpdate() event.

            JesseNinjaTrader Customer Service

            Comment


              #7
              I am not having connection problems. The thing is as I explained. Sometimes there is a flaw in the data. I guess that is something that simply happens. But by reloading all the data at each bar close my described problem would be solved.
              There must be some workaround or any other way that would achieve the result I need?

              Comment


                #8
                Hello cyberpete76,

                There is nothing that I could recommend to do that, if you are seeing discrepancies in data you should address that instead of trying to find a work around. There's not any expectation for a flaw in data.

                Going back to your description I would still say that you need to add prints to identify what specifically changed surrounding your logic in that use case. That would let you know if something with your logic is at fault or if something with data is causing that.

                I recently encountered a situation, where I had a signal in my strategy for an EMA crossing and two bars later the market price went above ema20. In my strategy that sets a flag for a "no go" for an upcoming entry signal. Ten bars later the entry situation occured but as I had the "no go flag" active I did not enter the trade. But when I reloaded all historical data manually the bar´s candle wick which caused that "no go flag" simply disappeard and my entry signal became valid.
                The strategy is running and a condition becomes true to set your bool. If you now reload the strategy and that bool is no longer being set that means that something logically changed between those two runs of the strategy. In Realtime that logic equated to true but in historical it did not. To find out what that is you would have to add prints and test both situations to see what changed how the logic worked in historical.

                It is common to see the outcome of a strategy change when you have it run through a period of time in realtime and then reload it, the historical processing can be different based on a variety of factors.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Question,

                  So in regards to this? How do I reload the data series on my indicator? I have 3 data series added. Ive added in a menu in the top right of the chart menu. They click a button and I want the data series to reload.

                  For instance data series 1 is 5 min.

                  They make a change on the menu and now the data series is 10 min for instance.

                  I want my indicator to reload with the new 10 min data series.

                  Ive tried hacks like: System.Windows.Forms.SendKeys.SendWait("{F5}");

                  This would force the indicator chart to reload everything.

                  But this doesnt really work since I think my top level menu has the focus or some other issue.

                  Any ideas?


                  Comment


                    #10
                    Here's an idea of what im trying to do.
                    Attached Files

                    Comment


                      #11
                      Hello morpheus0,

                      The user would need to F5 reload the chart however your custom changes to the indicator would not be retained. You need to have the user use the indicators menu to adjust parameters if you want the script to reprocess over the data series. To reload a data series the user needs to use the instrument picture to choose an instrument or the data series window to adjust data series settings. A custom window would only be useful for future calculations that use a changed runtime variable value.
                      JesseNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by fx.practic, 10-15-2013, 12:53 AM
                      5 responses
                      5,404 views
                      0 likes
                      Last Post Bidder
                      by Bidder
                       
                      Started by Shai Samuel, 07-02-2022, 02:46 PM
                      4 responses
                      95 views
                      0 likes
                      Last Post Bidder
                      by Bidder
                       
                      Started by DJ888, Yesterday, 10:57 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by MacDad, 02-25-2024, 11:48 PM
                      7 responses
                      159 views
                      0 likes
                      Last Post loganjarosz123  
                      Started by Belfortbucks, Yesterday, 09:29 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post Belfortbucks  
                      Working...
                      X