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 ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      180 views
      0 likes
      Last Post jeronymite  
      Started by DanielSanMartin, Yesterday, 02:37 PM
      2 responses
      13 views
      0 likes
      Last Post DanielSanMartin  
      Working...
      X