Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 junkone, Today, 11:37 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by frankthearm, Yesterday, 09:08 AM
        11 responses
        41 views
        0 likes
        Last Post frankthearm  
        Started by quantismo, 04-17-2024, 05:13 PM
        5 responses
        35 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by proptrade13, Today, 11:06 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        35 views
        0 likes
        Last Post love2code2trade  
        Working...
        X