Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

drawing cpu

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

    drawing cpu

    Hello,

    I need to draw horizontal lines on the chart. I can do it by reading from an csv file, and I can do it by the syntax in obarupdate. But as the levels dont need to be updated with every bar because the are calculated only one time from current open I would like to use with onstartup or initilialize. Do I understand correctly that this is not so CPU intensive as to do in obarupdate.

    And as there are a lot of levels I´d like to have the properties in one line like

    ("price100HB", false, price100HB, Color.SaddleBrown, DashStyle.Solid, 2);

    how would this work in Initialize please? I can´t find in the forum (to code as shown here)

    Thank you
    Tony

    #2
    If you have to do it in on bar update, use a flag to run it only 1 time.

    If ( drawnobjects==0)
    {
    drawnobjects=1;
    Drawline....
    }

    Comment


      #3
      Thank you for writing.

      I will be reviewing your code and this case. When I have additional details I will follow up here on this thread.

      Comment


        #4
        Hello,

        Thank you for writing in.

        You would need to use the OnBarUpdate() method as there is no guarantee the bars data and thus price data has loaded by Initialize() or OnStartUp(). This means you could simply use a bool that is true when you set the DrawHorizontalLine() method and then false once set.

        For example:

        // Variables

        private bool flag = true;

        ...

        protected override void OnBarUpdate()

        {

        if (flag)

        {

        Draw.HorizonalLine(this, "price100HB", Close[0], Brushes.Navy);

        flag = false;

        }

        }

        Don't hesitate to contact us with any other NinjaTrader items we may assist with.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pibrew, Today, 06:37 AM
        0 responses
        0 views
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        12 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        10 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        15 views
        0 likes
        Last Post AaronKoRn  
        Working...
        X