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 obtained from multiple graphs

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

    Indicator obtained from multiple graphs

    Hi,

    I have three different charts, I want to create an indicator to apply only to one of these charts.
    The indicator must generate a print on the graph (or other) starting from the analysis of all three graphs and their indicators.

    It's possible? A few examples?

    Thanks Alberto

    #2
    HI Alberto, thanks for posting.

    There is support for multi instrument/timeframe scripts in the NinjaScript library. Use AddDataSeries() to add extra data series. The primary series will be the chart you run the indicator from. See here for a full guide on multi instrument/timeframe scripts. We also have a couple of strategy examples here:




    Best regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the answer.

      Is there an example applied to indicators and not to strategies?

      Thanks Alberto

      Comment


        #4
        Hi Alberto, see here for an indicator example:
        https://ninjatrader.com/support/foru...king-something

        Best regards,
        -ChrisL
        Last edited by NinjaTrader_ChrisL; 12-07-2021, 02:19 PM.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the answer.

          Code:
          namespace NinjaTrader.NinjaScript.Indicators
          {
          public class XXX : Indicator
          {
          private EMA emaEC_8;
          private EMA emaEC_21;
          
          private EMA emaAC_8;
          private EMA emaAC_21;
          
          
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          .....
          }
          else if (State == State.Configure)
          {
          AddDataSeries(BarsPeriodType.Minute, 10);
          }
          else if (State == State.DataLoaded)
          {
          emaEC_8 = EMA(BarsArray[0], 8);
          emaEC_21 = EMA(BarsArray[0], 21);
          
          emaAC_8 = EMA(BarsArray[1], 8);
          emaAC_21 = EMA(BarsArray[1], 21);
          }
          }
          
          protected override void OnBarUpdate()
          {
          if ( BarsInProgress!=0 )
          return;
          
          // ensure both series have at least X bar
          if ( CurrentBars[0]<21 || CurrentBars[1]<21 )
          return;
          
          emaEC_8C[0] = emaEC_8[0];
          emaEC_21C[0] = emaEC_21[0];
          
          emaAC_8C[0] = emaAC1_8[0];
          emaAC_21C[0] = emaAC1_21[0];
          
          if (
          ( Closes[0][0]>emaEC_8[0] || Closes[0][0]>emaEC_21[0] )
          && ( Closes[0][0]>emaAC_8[0] || Closes[0][0]>emaAC_21[0] )
          )
          { .... }
          
          
          }
          }
          }
          Questions:

          1) I use:
          Code:
          if ( CurrentBars[0]<21 || CurrentBars[1]<21 )
          return;
          Is there an alternative way to use only EMA 8 and start using EMA 21 when we have 21 bars?

          2) I use:
          Code:
          emaEC_8 = EMA(BarsArray[0], 8);
          emaEC_21 = EMA(BarsArray[0], 21);
          
          emaAC_8 = EMA(BarsArray[1], 8);
          emaAC_21 = EMA(BarsArray[1], 21);
          I use BarsArray[0] (or BarsArray[1]), but usually I see using Close:
          Code:
          SMA1 = SMA(Close, 10);
          What are the differences?

          3) Difference between Closes[0][0] (or Closes[1][0]) and Inputs[0][0] (or Inputs[1][0])???

          Thanks Alberto

          Comment


            #6
            Hi Alberto, thanks for the follow up.

            1. You can use EMA8 when CurrentBar is less than 21 and greater than 8, then continue to use a 21 ema after CurrentBar reaches 21.

            2. BarsArray is a way of targeting the default price series of each series added to the script (Closes[0], Closes[1], etc). You can alternatively use Opens, Closes, Highs, Lows, etc.

            3. Inputs can be an indicator data series input for the primary series, Closes is always going to be a price series.

            Best regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thanks Alberto

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by kujista, Today, 06:23 AM
              4 responses
              14 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by traderqz, Yesterday, 09:06 AM
              2 responses
              16 views
              0 likes
              Last Post traderqz  
              Started by traderqz, Today, 12:06 AM
              3 responses
              6 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by RideMe, 04-07-2024, 04:54 PM
              5 responses
              28 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by f.saeidi, Today, 08:13 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X