Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Retrieving a value from a custom indicator from within a custom indicator

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

    Retrieving a value from a custom indicator from within a custom indicator

    Hi all,

    I'm using the Market Analyzer and have some custom indicators.

    I have 2 custom indicators on different time frames. Call the A2 and B60, where A is on 2 min and B is on 60 min.

    While A2 is running I want to retrieve the value for B60 -- the value that B60 passes to Plot0.Set

    I know about this to add the data series

    protected override void Initialize()
    {
    Add (PeriodType.Minute, 60);
    .. other initialization
    }

    and I know that I use BarsArray[1] to access that series.

    I know how to call the indicator

    B60 oCustom = this.B60(this.BarsArray[1],0);

    I'm guessing that a field in oCustom contains the result? Which one?

    Thanks in advance,

    john

    #2
    Hello jkmott59,

    Thank you for your post.

    oCustom[0] would access the value of the B60.

    Comment


      #3
      Thank you! Question about # of bars needed

      Thank you for that help. I'm getting the error about not having enough bars available to the called indicator (B60). It uses an EMA 8 period but other than that does not rely on any bars in the past, and does not use the CurrentBar test.

      I can adjust the CurrentBar in the A2 indicator but how do I know what to set it to?

      its not clear to me when the BarsArray[1] gets populated.

      thank you again for your help.

      john

      Comment


        #4
        Hello John,

        Thank you for your response.

        There would need to be at least 8 bars loaded. So if the A2 indicator is calling the B60 I would use the following line at the start of the OnBarUpdate() for the A2:
        Code:
        if(CurrentBars[0] <= BarsRequired || CurrentBars[1] <= 8)
        return;
        For information on CurrentBars please visit the following link: http://www.ninjatrader.com/support/h...urrentbars.htm
        For information on ensuring you have enough data before accessing it please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170

        Comment


          #5
          That took care of it, thanks

          Setting the bars to 20 made it happy. Thank you for your prompt response, this has added a valuable skill set to my ninjatrader toolbox.

          john

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          574 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          333 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X