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

Calling another indicator - data series

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

    Calling another indicator - data series

    What data series does it use when you call another indicator?

    The same one as the chart?

    How can you specify specifically another - say, you want to call another indicator on 200 ticks when the main indicator is on a 5 minute chart ?

    and is this code correct indicator.Value.GetValueAt(CurrentBar) to get the latest value?
    Last edited by NinjaCustomer; 05-07-2018, 10:15 AM.

    #2
    Hello NinjaCustomer,
    Thanks for your post.
    What data series does it use when you call another indicator?
    You are correct. Unless you specify for a different series to be used as the input then you will use the primary data series when calling an indicator. You are also correct that you could use that code for that purpose. For example, both of the following prints will produce the same value.
    Code:
    Print(SMA(20).Value.GetValueAt(CurrentBar));
    Print(SMA(20)[0]);
    How can you specify specifically another - say, you want to call another indicator on 200 ticks when the main indicator is on a 5 minute chart ?
    Something similar to the following snippet would add a 200 tick series, and then use that 200 tick series as an input to the SMA using BarsArray.
    Code:
    protected override void OnStateChange()
    {
    	else if (State == State.Configure)
    	{
    		AddDataSeries(BarsPeriodType.Tick,200);
    	}
    }
    protected override void OnBarUpdate()
    {
    	Print("The Primary Data Series' SMA(20) = "+SMA(BarsArray[0],20)[0]); 
            Print("My 200 Tick SMA(20) = "+SMA(BarsArray[1],20)[0]);
    }
    Please see the following help guide document for more information on BarsArray.
    Help Guide - BarsArray

    Please let me know if you have any questions.
    Josh G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Tin34, Today, 03:30 AM
    2 responses
    13 views
    0 likes
    Last Post Tin34
    by Tin34
     
    Started by sastrades, Yesterday, 09:59 AM
    2 responses
    27 views
    0 likes
    Last Post brucerobinson  
    Started by ETFVoyageur, Today, 12:52 AM
    1 response
    12 views
    0 likes
    Last Post Leeroy_Jenkins  
    Started by lollers, Today, 03:26 AM
    0 responses
    10 views
    0 likes
    Last Post lollers
    by lollers
     
    Started by aliyahany, Today, 03:16 AM
    0 responses
    2 views
    0 likes
    Last Post aliyahany  
    Working...
    X