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

CPU with Lines and Text

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

    CPU with Lines and Text

    Hello,

    I could finish another indicator today that is plotting lines at highs, lows... and with text at theses lines and rectangles to show sessions. But when I attach the indicator Ninja stucks. In UtyMonitor I see high numbers for Text, Line and Rectangle.

    I add dataseries 1 day on a chart with only 30 days loaded and in the code I have
    if(CurrentBars[1]<1) // BIP== day
    return;

    if(CurrentBars[1]>1)
    {
    Draw.Line(this, "high2", false, 100, Highs[1][1], -100, Highs[1][1], Brushes.Green, DashStyleHelper.Dot, 2);
    Draw.Text(this, "high2text", false, "G_H/T2", -1, Highs[1][1]+2*TickSize, 0, Brushes.Green, smallFont, TextAlignment.Left, null, null,1);
    ...
    ...
    There are 8 lines and text with this logic and for the 30 days rectangles for rth (= 30 rectangles) and 30 x 3 = 90 lines, but no text for these lines and rectangles.

    Why does this need so much PC-ressources?

    Thank you!
    Tony

    #2
    Hello tonynt,

    Thank you for your reply.

    From the sample code provided it doesn't look like you're restricting these to be drawn only when the secondary daily series is processing. If your primary series is running on price change or on each tick or is a fairly quick moving series, you could really be putting a strain on your system redrawing all 90+ lines each time OnBarUpdate() is processing for the primary series. If you separate the drawing objects that are only dependent on the secondary daily series into the following condition, do you see performance improve and fewer resources being used:

    Code:
    if (BarsInProgress == 1)
    {
    // logic to draw objects based on daily series goes here
    }
    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply. In the meantime I have examined further and I see that the very highest numbers in uty-monitor is from orderflowvolumeprofile. I have for 8 instruments each a 30 minute chart with 2 orderflowvolume profiles (each instrument one ETH and one profile RTH). Days in data loaded is 30 (the purpose of profile is to examine larger periods).

      Is this too much? (I have NT8 on a fast computer with big RAM, I know about recommendations, I mean if this number of profiles would cause cpu problems on pc with recommended performance)

      Thank you!
      Tony

      Comment


        #4
        iin the meantime I changed in the code the logic to avoid that drawings are done with every onbarupdate. I use a bool but to my surprise it doesnt draw the lines nor text but sets bool true. What might be wrong here please?

        if(BarsInProgress==2)
        {
        if(levelsdrawn==false)
        {
        Draw.Line(this, "high2", false, 100, Highs[1][1], -100, Highs[1][1], Brushes.Green, DashStyleHelper.Dot, 2);
        Draw.Text(this, "high2text", false, "G_H/T2", -1, Highs[1][1]+2*TickSize, 0, Brushes.Green, smallFont, TextAlignment.Left, null, null,1);
        if(IsFirstTickOfBar)
        levelsdrawn=true;
        }}

        Thank you!
        Tony

        Comment


          #5
          Hello tonynt,

          Thank you for your reply.

          I'd really need to see more than this snippet of code to say why that may be occurring. Would you be able to provide a larger snippet of the script, or the entire script so I may better understand what may be occurring?

          Thanks in advance; I look forward to assisting you further.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Hello,

            thank you for your reply. I reduced the code to a minimum to show what its about. The purpose is to plot lines at highs and lows of specific days and label those to know easily which day it is (I removed further codings in this reduced code)

            As uty-monitor shows for drawings high numbers so I thought it makes sense to reduce the drawing by onbarupdate with a bool so that its done only once a day (as the levels are from prior days and no further update necessary)

            Thank you!
            Tony
            Attached Files

            Comment


              #7
              Hello tonynt,

              Thank you for your reply.

              In your example script you're drawing it on the 5 minute bars, and you're never setting the bool back to false so they can be redrawn. I've modified the script to demonstrate. This runs on each tick, but the lines only redraw on the first tick of a new daily bar. I've combined the first tick of bar check and corrected BarsInProgress check to make this a little simpler.

              Please let us know if we may be of further assistance to you.
              Attached Files
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                Hello Kate,

                thank you for your reply. Yes, with daily bar it works this way (I had it before this way but without eachtick).

                I should have sent you a script not with daily bars but with certain time range, my fault that I didnt think about different situation.
                I´m curious how you would resolve this to do it once a day. Its also a reduced code as I sent before.

                Thank you for your support!
                Tony
                Attached Files

                Comment


                  #9
                  Hello tonynt,

                  Thank you for your reply.

                  I would suggest comparing the two scripts if it's not clear what I've done as far as modifications to the initial script you provided. Your issue here is that you are looking at a specific time range, which becomes problematic. Also, you're not providing for a reset of the lines at a given point - you never set the bool back to false so the lines can be redrawn after the first time they are drawn. Further, if your time frame is outside of the days loaded for the chart, you'd receive an error with this.

                  Please let us know if we may be of further assistance to you.
                  Kate W.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello Kate,

                    I try to do the quesition different and more accurately: I could modify the SampleGetHighLowByTimeRange for what I need. But there is one isse I can not resolve: this sample works only when EndTime>StartTime. How can one use it for overnight with StartTime>Endtime (16:15 to 9:30). I´m working round now 2 days with this and cant make any progress.

                    Thank you!
                    Tony
                    Last edited by tonynt; 11-25-2020, 07:39 AM. Reason: modify question for easier solution

                    Comment


                      #11
                      Hello tonynt,

                      Thank you for your reply.

                      I do not have the sample script you mentioned. Would you be able to provide an example of what you currently have set up?

                      Thanks in advance; I look forward to assisting you further.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello Kate,

                        thank you for your reply. Its this link https://ninjatrader.com/support/help...ce_samples.htm

                        and as described the problem is that it can not be used for overnight/or when starttime>endtime.

                        I tried 2 days with workarounds but I dont know how it can give the highesthigh and lowestlow for time 16:15 to 9:30 next day.

                        Thank you!
                        Tony
                        Attached Files

                        Comment


                          #13
                          Hello tonynt,

                          Thank you for your reply.

                          That example is designed for time frames within the same day, it's not intended to be used for a timespan that spans beyond a single day into the next day. If you try to put in a start time that is greater than the end time, it will simply return out of OnBarUpdate.

                          I will see about working up a similar example that will work with spans that go from one day to another. With tomorrow being the Thanksgiving holiday, it may take a bit to complete.

                          Thanks for your patience, I look forward to assisting you further.
                          Kate W.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello Kate,

                            any news on the sample about spans from one day to another?

                            Thank you!
                            Tony

                            Comment


                              #15
                              Hello tonynt,

                              Thank you for your patience.

                              Actually it was a bit of a hard one. We've just completed the example this afternoon. This example is specifically to plot the high/low of an overnight timespan and will not work properly with intraday timespans.

                              Please let us know if we may be of further assistance to you.
                              Attached Files
                              Kate W.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Rapine Heihei, Today, 08:19 PM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 08:25 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by f.saeidi, Today, 08:01 PM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 07:51 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by frslvr, 04-11-2024, 07:26 AM
                              5 responses
                              96 views
                              1 like
                              Last Post caryc123  
                              Working...
                              X