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

adding together different indicators

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

    adding together different indicators

    Apologies if this has been asked before.

    How can I create an indicator that is the sum of other indicators of other data series?

    e.g new indicator = MA (data series 1) + MA (data series 2).....MA (data series n)

    Thanks.

    #2
    Hello SparkyBoy,

    You may do this by using the BarsArray object when using a Multiseries script for example:


    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Sum"));

    Add("MSFT",PeriodType.Day,1); //BarsArray 1
    Add("GOOG",PeriodType.Day,1); //BarsArray 2
    }

    protected override void OnBarUpdate()
    {
    // Check to make sure that you have enough data in all series
    if (CurrentBars[0] <= 1 || CurrentBars[1] <= 1 || CurrentBars[2] <= 1)return;

    if(BarsInProgress == 0)
    Sum.Set(SMA(BarsArray[1],14)[0]+SMA(BarsArray[2],14)[0]);
    }

    Here is a link to our Help Guide that talk about Multiseries scripts in more detail that you may view.


    Let me know if that will work for what you are looking for.
    JCNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by pibrew, Today, 06:37 AM
    0 responses
    0 views
    0 likes
    Last Post pibrew
    by pibrew
     
    Started by rbeckmann05, Yesterday, 06:48 PM
    1 response
    12 views
    0 likes
    Last Post bltdavid  
    Started by llanqui, Today, 03:53 AM
    0 responses
    6 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    15 views
    0 likes
    Last Post AaronKoRn  
    Working...
    X