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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        57 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X