Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about using an indicator within a strategy

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

    Question about using an indicator within a strategy

    Hi. I am writing my own strategy and I need to use a custom indicator I created as its data is essential for determining entry points for my trades. However, from all that I have researched from the helpguide, it seems that I am restricted to using AddChartIndicator() whose purpose is solely for displaying an indicator on a chart. However, what I am interested in is the data that my indicator generates, which is stored in bar collections in the form of public concurrent dictionaries.

    Could you please advise me on how I can access the data from my custom indicator from within the strategy without essentially having to recopy most if not all of the code of the indicator into the strategy so as to generate the desired data?

    Thanks.

    #2
    Hello mbesha,

    Thanks for your post.

    Correct, AddChartIndicator() is to display the indicator on the chart when the strategy is run.

    To use an indicators output value within a strategy you could call the indicator directly, in the OnBarUpdate(), for example:

    double smaValue = SMA(14)[0]; // get the current value of the 14 period SMA.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    163 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    82 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    125 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    206 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    184 views
    0 likes
    Last Post CarlTrading  
    Working...
    X