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:

    https://ninjatrader.com/support/help..._frame_and.htm
    https://ninjatrader.com/support/help...ipt_strate.htm

    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, 01: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 trader3000a, Today, 09:23 AM
              0 responses
              1 view
              0 likes
              Last Post trader3000a  
              Started by CharlieBoy, Today, 08:37 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_JustinD  
              Started by srbdoc, Today, 08:41 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_RyanS  
              Started by johnok, Yesterday, 04:09 PM
              1 response
              38 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by 306021, Today, 07:49 AM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_Eduardo  
              Working...
              X