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 rhyminkevin, Today, 04:58 PM
        4 responses
        52 views
        0 likes
        Last Post dp8282
        by dp8282
         
        Started by iceman2018, Today, 05:07 PM
        0 responses
        5 views
        0 likes
        Last Post iceman2018  
        Started by lightsun47, Today, 03:51 PM
        0 responses
        7 views
        0 likes
        Last Post lightsun47  
        Started by 00nevest, Today, 02:27 PM
        1 response
        14 views
        0 likes
        Last Post 00nevest  
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        50 views
        0 likes
        Last Post futtrader  
        Working...
        X