Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Managing Plots for Strategy vs Presentation

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

    Managing Plots for Strategy vs Presentation

    I have a custom indicator that drives out only one value but uses two plots to implement differential coloring based on certain conditions. For example, If the indicator value is moving up or flat, the green plot1 is set, else the red plot2 is set. Now, if I want to use that value from the indicator in a strategy, I would need to merge the values from both plots 1 and 2 into a single dataseries to get a single value for each bar. Alternatively, I could push a 3rd plot from the indicator where the value is set at the close of each bar, but the plot color would need to be set to transparent. Hopefully this shows that plotting techniques for visual presentation may differ from those used to pass a data series to a strategy.

    Can you offer any best practices, over and above what I have shared here, for how best to address these two objectives simultaneously? I assume it is better to have fewer plots and fewer dataseries for processing efficiency. For example, is overriding a single Plot to manage plot color and push out a single dataseries more efficient than bifurcating several plots to do the same, when ultimately strategy processing and optimization will be involved. Thanks.

    Regards,

    Whitmark
    whitmark
    NinjaTrader Ecosystem Vendor - Whitmark Development

    #2
    Adding an additional plot likely will not have a performance impact. However, what I would do is have a new DataSeries object and expose that.

    For example:

    private DataSeries mySeries;

    In Initialize():
    mySeries = new DataSeries(this);

    Set the values for each bar in OnBarUpdate()

    Then expose a property for it:

    public DataSeries MySeries
    {
    get
    {
    Update(); // This is important
    return mySeries;
    }
    }

    See here for info on Update() http://www.ninjatrader-support.com/H...V6/Update.html
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray . . . this is just the technique I was looking for to be able to pass dataseries values between indicators and strategies without necessarily adding more plots that would appear in the indicator panel.

      One follow-up question, however. When I compare the approach you recommend with the example in the help under update() that is shown below, I see that the latter did not require a dataseries to be passed. Are there instances where you would prefer to use one approach vs the other? In my case, I would like to be able to refer back to previous barsago values in the dataseries from within the strategy. Thanks.


      Code:
      tripleValue = 0;
      
      private double 
      protected override void OnBarUpdate() 
      { 
          if (CurrentBar < 20) 
              return; 
      
          tripleValue = SMA(20)[0] * 3; 
          Values[0].Set(SMA(20)[0]); 
      } 
      
      public double TripleValue 
      { 
          get 
          { 
              Update(); 
              return tripleValue; 
          } 
      }
      whitmark
      NinjaTrader Ecosystem Vendor - Whitmark Development

      Comment


        #4
        Rule of thumb is if you need to store data on each bar then use a DataSeries, if you only need to know the current state, use any data type.
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        578 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X