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

Is Plots[x].Set(x + Close) possible?

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

    Is Plots[x].Set(x + Close) possible?

    I know what is in the title is not possible. I know that Plots are a collection holding all of the Plot objects that define the visualization characteristics of the indicator. The nice thing about Plots is that they can be indexed. I would like to be able to index through all my plots when I do a Plot.Set(). What si the best way to do this? Here is what I have:

    protected override void Initialize()
    {
    plot_history = new DataSeries[2];

    for( i=0; i<25; i++ )
    {
    Add( new Plot( short_up_color, PlotStyle.Line, "Plot" + i.ToString() ) );
    plot_history[i] = new DataSeries( this );
    }
    }

    protected override void OnBarUpdate()
    {
    This is not possible, but I would like to do something like this:
    for( i=0; i<25; i++) Plots[i].Set( special( i, x++ ) );

    I currently have to do this:
    Plot0.Set( plot_history[0] );
    Plot1.Set( plot_history[1] );
    Plot2.Set( plot_history[2] );
    * * *
    Plot2.Set( plot_history[24] );
    }

    #2
    Hello,

    Thank you for the question.

    What you are trying to do is certainly possible you would just need the correct syntax.

    Rather than calling the plot directly by its name, you would instead want to use the index system you already have.

    The Add statements are fine, to do the same in OnBarUpdate you would want to use Values instead of the PlotName.

    Code:
    protected override void Initialize()
    {
            for(int i = 0; i < 25; i++)
    	{
    		Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot" + i));	
            }
    }
    
    protected override void OnBarUpdate()
    {
    	for(int i = 0; i < 25; i++)
    	{
    		Values[i].Set(Close[0] + i);
    	}
    }
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you. Just what I was looking for.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kujista, Today, 05:44 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by elderan, Yesterday, 08:03 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by samish18, Yesterday, 08:57 AM
      8 responses
      25 views
      0 likes
      Last Post samish18  
      Started by DJ888, 04-16-2024, 06:09 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by RookieTrader, Today, 07:41 AM
      0 responses
      4 views
      0 likes
      Last Post RookieTrader  
      Working...
      X