Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Read closed source indicator A values in indicator B

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

    Read closed source indicator A values in indicator B

    Hi,

    I would like to build a new custom indicator based on another which is closed source. I have tried to follow https://forum.ninjatrader.com/forum/...ther-indicator and https://forum.ninjatrader.com/forum/...-are-not-plots but it seems I am doing something wrong, as I get errors either on the constructor:


    Code:
    ​
    private IndicatorClosed indicatorClosed = new IndicatorClosed("P1", "P2", 10);
    'NinjaTrader.NinjaScript.Indicators.IndicatorClose d' does not contain a constructor that takes 3 arguments


    The definition available to me for the closed source indicator is:
    Code:
    namespace NinjaTrader.NinjaScript.Indicators {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase {
            private IndicatorClosed[] cacheIndicatorClosed;
    
            public IndicatorClosed IndicatorClosed(string p1, string p2, string p3) {
                return IndicatorClosed(Input, p1, p2, p3);
            }
    
            public IndicatorClosed IndicatorClosed(ISeries<double> input, string p1, string p2, string p3) {
                // ...
            }
        }
    }​
    If I just do
    Code:
    ​
    private IndicatorClosed indicatorClosed;
    ...
    indicatorClosed = IndicatorClosed("P1", "P2", 10);
    ​​
    It builds but then I get the runtime error:
    Code:
    ​
    Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.


    Do you know how I should instantiate the closed indicator so I can access the various data series generated by the closed indicator ?

    Thanks in advance

    #2
    Hello, thanks for writing in. The initialization should take place in OnStateChanged, in the DataLoaded state. For an example of how to initialize an indicator and where to place the code, see the "SampleMACrossover" strategy in the Strategies folder. You can also check Intellisense in the editor that will give you a parameter list. You can pull this up as soon as you type the opening '(' in your script e.g.

    indicatorClosed = IndicatorClosed( <- after you type this, IntelliSense will show you a list of overloads.

    Kind regards,
    -ChrisL​

    Comment


      #3
      Hi Chris,

      Thanks for the prompt reply. I did not thought of the examples. Worked like a charm, thank you so much.

      Have a good day,

      Yoan

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 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