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

OnBarUpdate() and renko

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

    OnBarUpdate() and renko

    Is OnBarUpdate invoked after every renko bar completes? For example, assuming I'm using 2 tick renko bars.If the price goes up 2 ticks or more from the high of the previous bar a new renko bar will form. Is onbarupdate called immediately after this happens? I'm getting some strange/inconsistent behavior with some of my stops and I've noticed a few missed triggers when using renko bars/bricks. I'm using the close of each bar for my entry/exit logic.When using small bar sizes with renko it's possible to have several bars form at nearly the same time. If the price gaps is it possible for multiple renko bars to have the same time stamp and thus be thrown into the same obu call? I would assuming obu is invoked after each bar and since it only takes milliseconds to run through the script it can keep up with each bar.
    Last edited by gordongekko; 03-20-2018, 08:30 AM.

    #2
    Hello gordongekko,

    Thanks for opening the thread.

    OnBarUpdate() is an event based method for whenever incoming data comes in. Since we wait for the first tick of a new bar to trigger a bar close, we will always see iterations for OnBarUpdate() whenever a bar closes. This is true for all bars and this method will not be skipped.

    We could add a print to OnBarUpdate() where we will see print for every bar completion in the output window.

    To find out why your triggers were not firing, we will need to look at what those condition's values were during that iteration of OnBarUpdate().

    When you add prints for your trigger conditions, do you see some more information that tells you why they did not become true?

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      It's not that they are not working it's that they are not consistently working but I've only had this issue with renko specifically so i wanted to get clarification on how it works with obu before digging any deeper into this issue.

      Comment


        #4
        I'm still having stops placed at odd price points when using closing values for renko bars even when I'm using logic as simple as: stop = MIN(Close, 5)[0]; Sometimes the stop will wind up nowhere close to this value on the chart and other times it will go exactly where it is supposed to go. I'm assuming that these renko bars have closing values of prices that actually occurred in the past so this shouldn't be possible.

        Comment


          #5
          Hello gordongekko,

          Thanks for your replies.

          The logic will tell the tale for how your orders are submitted. Without the full code and taking steps to print out what the strategy is doing, I am only left to speculate.

          Please answer the following questions so we may be of further help.

          When you add a prints for the price that is sent to your order method, what price do you see? Is the order method submitting to a different price level than the price level that is sent to the order method?

          How exactly are you submitting your stop loss order?

          What are the values printed for Close[0], Close[1], Close[2], Close[3], Close[4], and Close[5] when you add prints along side stop = MIN(Close, 5)[0];?

          Keep in mind, using SetStopLoss() will prep NinjaTrader so when an Entry method comes back as filled, the stop loss is then submitted. If the stop loss has not been updated when the strategy is flat, the previous stop loss value will be used.

          I have included resources for setting up debug prints, enabling TraceOrders, and public reference for SetStopLoss().

          Debugging - https://ninjatrader.com/support/foru...ead.php?t=3418

          TraceOrders - https://ninjatrader.com/support/foru...ead.php?t=3627

          SetStopLoss() - https://ninjatrader.com/support/help...etstoploss.htm

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

          Comment


            #6
            I'm testing this live on a dozen contracts so I can watch its behavior. When i use prints it prints the data for all of the bots in the same window and i can't follow it. Is there a way to assign the prints to a specified output window (1,2,3 etc.)? Also how do i print a value like MIN(Close, 5)[0];? Do i just print the value of the double this is referencing it?Also how do i put the name of the instrument in the print?

            Comment


              #7
              Hello gordongekko,

              I would typically recommend to test one NinjaScript at a time when debugging to focus on the behavior of one instance before involving prints from other instances in your tests.

              The PrintTo property can be set in a NinjaScript to change the tab the NinjaScript prints to in the output window.

              PrintTo - https://ninjatrader.com/support/help...us/printto.htm

              Printing out the value of an indicator can be done as follows:

              Code:
              Print(MIN(Close, 5)[0]);
              Code:
              stop = MIN(Close, 5)[0];
              Print(stop);
              It would then be important to see what that stop value is and how you are using it for your stop loss in your script.

              The name of an instrument can be found with the Instrument object.

              Code:
              Print(Instrument.FullName);
              Instrument.FullName - https://ninjatrader.com/support/help...t_fullname.htm

              Please let me know if you have any additional questions.
              JimNinjaTrader Customer Service

              Comment


                #8
                This is unrelated to previous question but can somebody explain why the ninjatrader 8 platform freezes up and maxes out your cpu when you ask it to pull a lot of data for multiple instruments simultaneously. I have a 7700k and it will run it to 100% and start hanging/freezing up until it finishes pulling all of the data. Why does it do this? This happens almost every time I launch the platform, turn on 10 or more bots simultaneously for testing, or load a bunch of instruments into the market analyzer when its running multiple indicators, etc.I don't understand why it needs to put this much stress on a modern cpu when doing something as simple as downloading/loading/processing historical data.
                Last edited by gordongekko; 03-20-2018, 03:24 PM.

                Comment


                  #9
                  Hello gordongekko,

                  To really answer this question we should break down "downloading/loading/processing historical data."

                  Downloading historical data will be effected by the following factors:
                  • Type of Data Downloaded (I.E. Tick, Minute, Daily)
                  • Amount of Days/Bars to load in the data series
                  • If Tick Replay is enabled
                  • Number of separate data series that are loading simultaneously
                  • Internet connection speeds


                  Loading will mostly be effected by the amount of data loaded altogether, when processing the historical data is where most performance is lost. NinjaTrader's built in components are designed to have minimal impact on performance and have been heavily tested to ensure decent performance in complex workspaces.

                  Processing Historical data will be effected by the following factors:
                  • How complex the processing NinjaScript is
                  • How many NinjaScripts we are loading simultaneously
                  • If any NinjaScripts require Tick Replay and additional processing for each tick of a data series
                  • Custom rendering that does not follow best practices and calculates data on render passes instead of outside the OnRender() method


                  NinjaTrader 8 will use multiple threads and the experience is much improved over NinjaTrader 7 performance wise. Performance issues are generally seen with complex NinjaScripts. A workspace built with custom NinjaScripts should be broken down to identify which scripts are causing the most performance draw, and the workspace should be built excluding any complex tools that are not needed.

                  Loading 10 simple scripts should not have a performance impact, but if the strategies incorporate complex indicators/calculations and incorporate additional data series, the impact will certainly be compounded.

                  If you can identify an issue with a specific NinjaTrader component by clearly demonstrating a performance issue only using that component or with a mix of other NinjaTrader bundled components, we can report the impact to the development team for further review.

                  I've included some tips for performance:

                  NinjaTrader 8 performance tips - https://ninjatrader.com/support/help...ance_tips2.htm

                  NinjaScript Best Practices for performance - https://ninjatrader.com/support/help...tm#Performance

                  A quick test to check the performance of a vanilla version of the platform can be done by starting the platform in Safe Mode. Please see the instructions below for enabling Safe Mode.

                  Temporarily disabling AddOns - https://ninjatrader.com/support/help...sablingAdd-Ons

                  Please let us know if we can provide further direction.
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Regarding my previous issue with the stops. The problem had nothing to do with renko. It was just a coding oversight on my end. I forgot to multiply and int by the tick size so the stop was being set on the point value of the instrument instead of the ticks.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by CommonWhale, Today, 09:55 AM
                    1 response
                    3 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by Gerik, Today, 09:40 AM
                    2 responses
                    7 views
                    0 likes
                    Last Post Gerik
                    by Gerik
                     
                    Started by RookieTrader, Today, 09:37 AM
                    2 responses
                    12 views
                    0 likes
                    Last Post RookieTrader  
                    Started by alifarahani, Today, 09:40 AM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by KennyK, 05-29-2017, 02:02 AM
                    3 responses
                    1,285 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Working...
                    X