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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          160 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          307 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          245 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          348 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          178 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X