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 jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,290 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    9 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    62 views
    0 likes
    Last Post halgo_boulder  
    Started by Option Whisperer, Today, 09:55 AM
    0 responses
    8 views
    0 likes
    Last Post Option Whisperer  
    Started by halgo_boulder, 04-20-2024, 08:44 AM
    2 responses
    25 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X