Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting from within a NinjaScript Strategy

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

    Plotting from within a NinjaScript Strategy

    I am experimenting with the reference sample found here (on NT8RC2):
    When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability


    Unfortunately, I am seeing some issues: values older than 1 year are duplicates of the value in the 'last' year of the plot. Or in other words: the indicator pattern is cyclic with a length of about 1 year.

    Looking at the code, this does not seem to be too surprising: The strategy exposes a Series<double> for the plot values and the indicator accesses this asynchronously using GetValueAt(). A series will initialize with a length of MaximumBarsLookBack at the time of instantiation - hence the plots being cyclic.

    Without knowing enough about NT right now, I assume that the length of the series is equivalent to MaximumBarsLookBack, which is set to 256 - hence the plots being cyclic with almost exactly one year.

    I don't want to set MaximumBarsLookBack to infinite for my whole strategy, so I came up with this:
    var tmp = MaximumBarsLookBack;
    MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
    EquityPercentPlot = new Series<double>(this);
    DrawdownPercentPlot = new Series<double>(this);
    MaximumBarsLookBack = tmp;


    I feel it's a terrible hack and was wondering if there was any better/ recommended solution for this issue?

    Thank you,
    best regards, Felix

    #2
    Hello fbertram,

    Yes, it is possible to initialize each series with an individual MaximumBarsLookBack setting.

    myDoubleSeries = new Series<double>(this, MaximumBarsLookBack.Infinite);

    Please see the NinjaTrader 8 help guide on Series<T> for further information.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X