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

  • Apo84
    replied
    Thanks Alberto

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    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

    Leave a comment:


  • Apo84
    replied
    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

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    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.

    Leave a comment:


  • Apo84
    replied
    Thanks for the answer.

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

    Thanks Alberto

    Leave a comment:


  • NinjaTrader_ChrisL
    replied
    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

    Leave a comment:


  • Apo84
    started a topic Indicator obtained from multiple graphs

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by burtoninlondon, Today, 12:38 AM
0 responses
4 views
0 likes
Last Post burtoninlondon  
Started by AaronKoRn, Yesterday, 09:49 PM
0 responses
12 views
0 likes
Last Post AaronKoRn  
Started by carnitron, Yesterday, 08:42 PM
0 responses
11 views
0 likes
Last Post carnitron  
Started by strategist007, Yesterday, 07:51 PM
0 responses
13 views
0 likes
Last Post strategist007  
Started by StockTrader88, 03-06-2021, 08:58 AM
44 responses
3,982 views
3 likes
Last Post jhudas88  
Working...
X