Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

New pivot indicator

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

    New pivot indicator

    I actually want to show the last n days pivots on the current day's intraday chart. The following code is VERY slow and is unusable if I scroll into the past. Is there a way to do this?

    protected override void OnBarUpdate()
    {
    if (Bars.BarsSinceNewTradingDay >= 1)
    {
    Draw.Line(this, "tag1"+CurrentBar, true,0, PP.R3[0], 130, PP.R3[0], Brushes.Red, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag2"+CurrentBar, true,0, PP.R2[0], 130, PP.R2[0], Brushes.Red, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag3"+CurrentBar, true,0, PP.R1[0], 130, PP.R1[0], Brushes.Red, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag4"+CurrentBar, true,0, PP.Pp[0], 130, PP.Pp[0], Brushes.Blue, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag5"+CurrentBar, true,0, PP.S1[0], 130, PP.S1[0], Brushes.Green, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag6"+CurrentBar, true,0, PP.S2[0], 130, PP.S2[0], Brushes.Green, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag7"+CurrentBar, true,0, PP.S3[0], 130, PP.S3[0], Brushes.Green, DashStyleHelper.Dot, 1);

    Draw.Line(this, "tag8"+CurrentBar, true,0, PP.R3[1], 256, PP.R3[1], Brushes.Red, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag9"+CurrentBar, true,0, PP.R2[1], 256, PP.R2[1], Brushes.Red, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag10"+CurrentBar, true,0, PP.R1[1], 256, PP.R1[1], Brushes.Red, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag11"+CurrentBar, true,0, PP.Pp[1], 256, PP.Pp[1], Brushes.Blue, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag12"+CurrentBar, true,0, PP.S1[1], 256, PP.S1[1], Brushes.Green, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag13"+CurrentBar, true,0, PP.S2[1], 256, PP.S2[1], Brushes.Green, DashStyleHelper.Dot, 1);
    Draw.Line(this, "tag14"+CurrentBar, true,0, PP.S3[1], 256, PP.S3[1], Brushes.Green, DashStyleHelper.Dot, 1);
    }
    }

    Thanks.

    #2
    Hello chartish,

    The code you have provided would draw 15 lines on every single bar on the chart.

    If there were 100 bars on the chart this would be 1500 drawing objects. Likely there are way more than 100 bars on the chart.

    The amount of objects that must be drawn and kept in memory is extremely large.

    No, there would not be a way to render this extreme amount of objects in a faster way.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes, it certainly is possible to show the pivots for the last N days as long as you keep the value of N within reason. The level lines and labels should all be done in an OnRender loop. The code you posted is not a good approach.


      When you draw a text or line with a tag that is the same as that of an existing text or line, the properties of the previously created object are changed, but no new object is created;

      So, as long as you reuse the tags, your code would NOT be creating new drawing objects on every bar. The tag for each line must not change from bar to bar, so that when a new bar is added, you are just updating existing drawing objects and not adding to the memory load. In other words, DO NOT include the value of CurrentBar as part of the tag.

      The "just one more thing" question would be: Why would you want to do this?
      Last edited by Ricam; 05-10-2017, 02:43 PM.

      Comment


        #4
        Thanks Ricam. I plan on keeping n to about 3 or 4. The reason for doing this is to determine if prior pivots are still good support and resistance lines.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        636 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        571 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X