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

Indicator Input Series

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

    Indicator Input Series

    I have created two indicators. The first uses up - down volume from primary data series, calculated on each tick with tick replay for historical bars. Works fine. The second is the cumulative sum of the first indicator, calculated on bar close. Second indicator:

    OnBarUpdate()
    if (CurrentBar <= BarsRequiredToPlot) return;

    if (Bars.IsFirstBarOfSession)
    Value[0] = Close[0];

    else
    { Value[0] = Value[1] + Close[0]; }

    Very simple. The problem is I cannot seem to make the second indicator use the first as input. I change Input series to first indicator, but it will always use price data series instead. I tried several different input series without success. I've done this many times with other indicators on indicators. Where am I going wrong?

    Also, I tried calling the first indicator from within the second by setting a variable = first indicator. All I got was a zero line. This second indicator only has any value in relation to the first, so no real reason to make it input flexible. Is there a way to force the second to always use the first as input series? Thanks.

    #2
    Hello HarvOS,

    To use input in your indicator you need to use the Input series: https://ninjatrader.com/support/help.../nt8/input.htm

    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello HarvOS,

      To use input in your indicator you need to use the Input series: https://ninjatrader.com/support/help.../nt8/input.htm
      Something like this? Or earlier state?

      State.Dataloaded
      Input[0] = IndicatorOne();

      Comment


        #4
        Hello HarvOS,

        That would be from OnBarUpdate just like other series such as Close. Input series is the specific input that you pass to the indicator when you call it from a different script.

        The help guide shows a sample of checking what type of input was passed and also how to use it to delegate logic based on the type of series. You would use it similar to Close and not assign it a value. Its value comes from the input you passed to the indicator.


        Print(Input[0]);

        Using an indicator as Input means passing it, for example SMA(EMA(12),12). The EMA is passed to the SMA as input. The SMA gets the EMA value by using Input[0] in its logic.

        If you instead mean to just call the indicator from your code you would do that by calling the indicator name and plot:

        double indicatorValue = IndicatorOne()[0];
        Last edited by NinjaTrader_Jesse; 07-27-2022, 09:54 AM.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Got it. Thank you!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by FrazMann, Today, 11:21 AM
          0 responses
          2 views
          0 likes
          Last Post FrazMann  
          Started by geddyisodin, Yesterday, 05:20 AM
          8 responses
          51 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cmtjoancolmenero, Yesterday, 03:58 PM
          10 responses
          36 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by DayTradingDEMON, Today, 09:28 AM
          4 responses
          24 views
          0 likes
          Last Post DayTradingDEMON  
          Started by George21, Today, 10:07 AM
          1 response
          19 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Working...
          X