Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to add an indicator to strategy without adding it to chart

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

    How to add an indicator to strategy without adding it to chart

    Hi,

    I can add an indicator to strategy (i.e. then using it in OnBarUpdate) like this:

    Code:
    // In Initialize()
    MyIndicator m_indicator = MyIndicator(Parameter);
    Add(m_indicator)
    
    // in OnBarUpdate()
    if (m_indicator.IndicatorValue[barsBack] > 0)
    ...
    Assume now that I do not want my indicator to appear on the chart but I still would like to use it internally. How do I do that in the most efficient way?

    Thank you!

    #2
    Hi Alex, I guess I'm not exactly following you here - you would not have to Add the indicator in for display to use this efficient way of referencing it.

    Comment


      #3
      Please confirm that if I assign a reference to my m_indicator variable then the indicator will be accessible at any moment thereafter (in OnBarUpdate and so on).

      Also, what exactly happens when we write MyIndicator m_indicator = MyIndicator(Parameter);?

      I mean when the indicator's object is constructed and the like?

      Comment


        #4
        Alex, your understanding is correct.

        Most of the background can be still found here from where ( I believe ) this technique originated sometime ago - http://web.archive.org/web/201004282...ds/rwt/rwt004/

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, Yesterday, 10:06 AM
        0 responses
        22 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        19 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        14 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        10 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        41 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X