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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        50 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        16 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X