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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        669 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        378 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X