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

Multi Instrument Indicator

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

    Multi Instrument Indicator

    I want to call the High and Low values of indicator XYZ of instrument ABC.

    Protected override void Initialize()
    {
    Add("ABC",PeriodType.Minute,1);
    }

    Protected override void OnBarUpdate()
    {
    double XYZHigh = XYZ().TheHigh[0];
    double XYZLow = XYZ().TheLow[0];
    }

    How do I reference ABC in the above OnBarUpdate for this to work?
    Thanks in advance

    #2
    Originally posted by 2Look4me View Post
    I want to call the High and Low values of indicator XYZ of instrument ABC.

    Protected override void Initialize()
    {
    Add("ABC",PeriodType.Minute,1);
    }

    Protected override void OnBarUpdate()
    {
    double XYZHigh = XYZ().TheHigh[0];
    double XYZLow = XYZ().TheLow[0];
    }

    How do I reference ABC in the above OnBarUpdate for this to work?
    Thanks in advance
    I believe this is what your looking for


    I just realised it was the indicator val you need not the high....

    See here.



    if you call your indicator as per normal but only in the correct BarsInProgress index then it will work.

    I dont know if you can call an indicator from the added timeframe directly without being in the correct barsinprogress but i would be interested to hear if there is a way.

    Here is an example

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Add("$AUDUSD", PeriodType.Minute, 5);
    Add("$EURUSD", PeriodType.Minute, 5);
    }


    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)Print ("Atr for AUDUSD 5 min = "+ATR(14)[0]);
    if (BarsInProgress == 2)Print ("Atr for EURUSD 5 min = "+ATR(14)[0]);

    }
    Last edited by marty087; 10-13-2015, 05:14 AM.

    Comment


      #3
      Hello 2Look4me,

      Thank you for your post.

      To reference the added bar series add BarsArray[1] to the indicator. For example:
      Code:
      XYZ(BarsArray[1]).TheHigh[0]

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fitspressoburnfat, Today, 04:25 AM
      0 responses
      2 views
      0 likes
      Last Post fitspressoburnfat  
      Started by Skifree, Today, 03:41 AM
      1 response
      4 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      603 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      23 views
      0 likes
      Last Post xiinteractive  
      Working...
      X