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 ETFVoyageur, 05-07-2024, 07:05 PM
        16 responses
        129 views
        0 likes
        Last Post bltdavid  
        Started by ETFVoyageur, Today, 10:13 PM
        1 response
        6 views
        0 likes
        Last Post ETFVoyageur  
        Started by somethingcomplex, Today, 10:36 PM
        0 responses
        5 views
        0 likes
        Last Post somethingcomplex  
        Started by sofortune, Yesterday, 10:28 AM
        5 responses
        22 views
        0 likes
        Last Post sofortune  
        Started by guyonabuffalo, Today, 10:01 PM
        0 responses
        2 views
        0 likes
        Last Post guyonabuffalo  
        Working...
        X