• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 tvaughan4, Today, 01:02 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by RtelTrade, Today, 01:27 PM
      0 responses
      4 views
      0 likes
      Last Post RtelTrade  
      Started by NinjaTrader_Brandon, Today, 01:19 PM
      0 responses
      8 views
      0 likes
      Last Post NinjaTrader_Brandon  
      Started by nedstrader, Today, 01:01 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by RolloHarper, Today, 12:59 PM
      0 responses
      8 views
      0 likes
      Last Post RolloHarper  
      Working...
      X