Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Basic question: Indicator on an Indicator

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

    Basic question: Indicator on an Indicator

    Hello-

    I'm new to NinjaTrader, but not new to programming in C# (I'm working here to port some indicators I wrote in NeoTicker to NinjaTrader).

    My question involves Ninja Trader's protocol when writing an indicator on an indicator. In this case, the example would be creating a Moving Average on Momentum, which itself is based on a calculated data series.

    I'm not sure if NinjaTrader allows nested indicators, but here's what I've been doing:

    Code:
    double myValue = Math.Log(System.Convert.ToDouble(Close[0]));
                
                logSeries.Set(myValue);
                
                momentumSeries.Set(Momentum(logSeries, 1)[0] * 100);
                
                M_EMA_1.Set(EMA(momentumSeries, 10)[0]);
    So you can see there I created a value that's really just the LN of the closing value; I then set those values to a data series to be used by Momentum. I get caught up when I try and use that momentumSeries later in an EMA calculation.

    Where am I screwing up, and is this even possible?

    #2
    Addendum

    I tried the following:

    Code:
    logSeries.Set(Math.Log(System.Convert.ToDouble(Close[0])));
                
                momentumSeries.Set(Momentum(logSeries, 1)[0] * 100);
                
                M_EMA_1.Set(EMA(momentumSeries, LT_ROC_EMA_Period)[0]);
    Obviously logSeries and momentumSeries are DataSeries types. The code above does not result in any output.

    As an aside, how can I debug (set break points) in the NinjaScript editor, or do I load up the .CS project in Visual Studio and wait for Ninja to call it?

    Comment


      #3
      Hi cgeorgan,

      Welcome to NinjaTrader and to the forum.

      Nesting the dataseries within an indicator should be no problem.

      First, please take a look at this page from our help guide for the necessary steps to properly create a data series.
      Page at - http://www.ninjatrader-support.com/H...culationLogic2
      Sample at - http://www.ninjatrader.com/support/f...ead.php?t=7299

      Also, check your Log tab in the Control Center while running the indicator, for any errors.

      As for debugging, you could certainly open the script in VS, or you can use Print() statements or Try/Catch blocks within NinjaTrader.
      Print()'s - http://www.ninjatrader.com/support/f...ead.php?t=3418
      Try/Catch - http://www.ninjatrader.com/support/f...ead.php?t=9825
      TimNinjaTrader Customer Service

      Comment


        #4
        Thanks guys, taking a little time but getting up to speed.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 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
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        549 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X