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

Passing Input of one indicator, to another indicator

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

    Passing Input of one indicator, to another indicator

    Hello,

    I have an indicator. A simple oscillator. It can have an input other than price. This all works fine. For example, instead of Close as the Input, I might have an input of SMA(Close,50). Again, this works fine.

    What I want to do, inside the indicator, is pass the same input series to another indicator, say, EMA within the code. So, I might say, EMA e = EMA(Input); and I am Expecting the original Input of SMA(Close,50) to apply, so effectively, it'd be EMA(SMA(Close,50))

    I hope this makes sense as to what I am trying to do. The input cannot be hardcoded as the input could be any indicator/price when it is added to the chart.

    Would you expect this to work? I am getting unexpected results, so wanted to verify with you that what I am doing is sound.

    Thanks.

    [edit: apologies - I just realised this is not in the indicator forum. I cannot delete posts. Please feel free to move it]

    #2

    Comment


      #3
      Hello pjsmith,

      EMA requires a period just like SMA.

      So:
      Print( EMA(SMA(50), 14)[0] );

      or

      private EMA myEMA;
      private SMA mySMA;

      mySMA = SMA(50);
      myEMA = EMA(mySMA, 14);

      Print(myEMA[0]);

      This will match a chart with the same data series and same indicators applied.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hi - Thanks both - I'm not sure my question was understood, though.

        When you add an indicator to a chart, you specify the input series. Typically this is the price, but can be another indicator, etc., So, my indicator processes this data and makes the plot. In this case, the input is an average, say, EMA(30). What I want to do, is reference another indicator from within the first, but calling the other indicator with the SAME input series as the user (me) specified. I tried this - SMA(Input, Period), but it did not seem to provide the expected result.

        So, it is not a case of trying to access values from another indicator but passing the same input series to it. Is my query clear? Should this work?

        Thanks.
        Last edited by pjsmith; 06-28-2021, 01:17 AM.

        Comment


          #5
          Hello pjsmith,

          The input series manually set in the indicator parameters, is the same as you would supply as the input series to an indicator call in code.

          If you use the EMA as the input series for the SMA manually, the EMA will be using the Close series as the input series, and the SMA will be using the EMA as the input series.
          Its the same in code when using an indicator as an input series. It is not different. If no input series is supplied to an indicator, the Close series is used as the Input series by default.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by hurleydood, 09-12-2019, 10:45 AM
          14 responses
          1,096 views
          0 likes
          Last Post Board game geek  
          Started by cre8able, Yesterday, 04:16 PM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by cre8able, Yesterday, 04:22 PM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by stafe, 04-15-2024, 08:34 PM
          5 responses
          28 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by StrongLikeBull, Yesterday, 04:05 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X