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

Erasing old plot data

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

    Erasing old plot data

    I was wondering if there is a way to erase old plot data. I created target lines and I want to erase the old target lines.


    AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Hash, "Target2"); //6

    everything is working well but the last 2 tasks are :

    Remove old plots,

    Inherit Plot brush color so I can use it for Draw.Text.

    Add plot can be changed in my parameters

    #2
    Hello ballboy11,

    Thanks for opening the thread.

    There is not a built in function to remove plots like you can with draw objects and RemoveDrawObject(). You could convert your plots to Draw Objects, or you can utilize one of the following approaches to accomplish this.

    You can use PlotBrushes to change the Brush for a plot that occurred so many bars ago.

    Code:
    PlotBrushes[0][5] = Brushes.Blue;
    This will set the first Plot's Brush from 5 bars ago to be blue. PlotBrushes will hold the Brush to be used for that plot. You could reference that PlotBrushes to get the assigned Brush so you can apply it to Draw.Text()

    You can also reset the DataSeries for that Plot to set the value from a certain number of bars ago to 0.

    Code:
    MyPlot.Reset(10);
    This will reset the value from 10 bars ago to 0.

    More information on PlotBrushes and Resetting a Plot's Data Series can be referenced in the help guide below.

    PlotBrushes - https://ninjatrader.com/support/help...lotbrushes.htm

    DataSeries.Reset - https://ninjatrader.com/support/help...n-us/reset.htm

    This topic was previously discussed for NinjaTrader 7. Here is a link to the forum post if you would like to reference other client's experiences: http://ninjatrader.com/support/forum...ad.php?t=54550

    Changing Plot parameters in the indicator dialog window is possible. The ArePlotsConfigurable bool must be set to true. Please see the documentation here for details: https://ninjatrader.com/support/help...nfigurable.htm

    Please let me know if you have any questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Plots and number of bars back

      I tried the reset and it gives me an index error,
      How can I find the index of the first bar on the screen?

      Comment


        #4
        Hello ballboy11,

        Thanks for the reply.

        My example for calling Reset on 10th bar ago would require 10 bars otherwise it would throw an indexing error.

        You can read more about resolving indexing issues involving having enough bars here: http://ninjatrader.com/support/forum...ead.php?t=3170

        If you would like to find the bar index for the left most bar on the screen, you should override OnRender() and use ChartBars to reference the FromIndex. You may refer to the documentation below for complete usage and understanding.

        FromIndex - http://ninjatrader.com/support/helpG..._fromindex.htm

        OnRender() - http://ninjatrader.com/support/helpG...s/onrender.htm

        Please let me know if I may be of further assistance.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rbeckmann05, Today, 05:50 AM
        0 responses
        3 views
        0 likes
        Last Post rbeckmann05  
        Started by doihaveto13, Today, 05:45 AM
        0 responses
        2 views
        0 likes
        Last Post doihaveto13  
        Started by giulyko00, 04-24-2024, 12:03 PM
        9 responses
        43 views
        0 likes
        Last Post giulyko00  
        Started by memonic, Yesterday, 01:23 PM
        2 responses
        25 views
        0 likes
        Last Post memonic
        by memonic
         
        Started by merc410, Today, 03:41 AM
        2 responses
        18 views
        0 likes
        Last Post merc410
        by merc410
         
        Working...
        X