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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        64 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        35 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        59 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Working...
        X