Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Proper approach to coding an indicator inside another indicator

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

    Proper approach to coding an indicator inside another indicator

    Hello Again:

    I have created an indicator called jelABG that produces a single plotted result. The plot is correct and this indicator is working as intended. the jelABG indicator is a complex calculation involving 3 different types of moving averages at which each extracted datapoint is involved in an equation and stored in a final Series<double> variable (Values[0]), then plotted.

    I am creating a second indicator, called jelSpread for which I wish to pass the high and low along with a period value into the first indicator (jelABG) or obtain a value to perform calculations on in my second indicator.

    To accomplish this, in my second indicator (jelSpread) I created to variables as follows:

    private ISeries<double> dsHigh;
    private ISeries<double> dsLow;
    In the OnStateChange event where State == State.SetDefaults I have the following:

    dsHigh = new Series<double>(this, MaximumBarsLookBack.Infinite);
    dsLow = new Series<double>(this, MaximumBarsLookBack.Infinite);
    In the OnBarUpDate event I am populating those variables as follows:

    dsHigh = jelABG(High, _barPeriod);

    dsLow = jelABG(Low, _barPeriod);
    The dsHigh and dsLow seem to be populating fine, but I am concerned that I am reloading those variables by rerunning the jelABG indicator with each new bar. Is there a better place for this coding other than the OnBarUpDate event? I need to ensure that as each bar is formed, that I get the latest data from the jelABG indicator.

    Don't get me wrong, this works, I just think I might be using too much system resources taking this approach. It will be fine if it was only one chart, but my setup as 12 charts on 2 monitors open at a time - not including the tabs...

    Thanks,

    #2
    Hello jeliner,

    Thank you for your post.

    The OnBarUpdate override would be needed if you want to recalculate this value each bar that is processed.

    Because you are supplying the high and low to the indicator, that will change its input parameters so a cached copy of the indicator would not likely be used. I couldn't really suggest any other location for this logic, however, if you do not need to call this on every OnBarUpdate you could look at ways to correct that using logic.

    Outside of using logic to control how frequently this is called, you would likely need to look into alternate ways to do your calculation in a more efficient way if it is taking too many resources on your PC.



    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    571 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    331 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    549 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    549 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X