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

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 ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          35 views
          0 likes
          Last Post ageeholdings  
          Started by reynoldsn, Today, 02:34 PM
          0 responses
          6 views
          0 likes
          Last Post reynoldsn  
          Started by nightstalker, Today, 02:05 PM
          0 responses
          12 views
          0 likes
          Last Post nightstalker  
          Started by llanqui, Yesterday, 09:59 AM
          8 responses
          29 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by quicksandatl, Today, 01:39 PM
          1 response
          6 views
          0 likes
          Last Post quicksandatl  
          Working...
          X