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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    54 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    71 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X