Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fully calculated indicator at start of OnBarUpdate

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

    Fully calculated indicator at start of OnBarUpdate

    My strategy needs to access every bar of it's indicators at the start of OnBarUpdate. (To reduce complexity.)
    I managed to do this with this code at the start of OnBarUpdate:
    Code:
    if (CurrentBar == 0) {
        Bars.CurrentBar = Bars.Count - 1;
        indicator.Update();
        Bars.CurrentBar = 0;
    }
    It surprisingly works very well when I load the strategy into a chart.
    However, when using the Strategy Analyzer, it doesn't work. The indicators are not fully calculated at the start of OnBarUpdate.

    How do I manage to have the indicators fully calculated when CurrentBar == 0?

    #2
    Hello Bobin,

    What you are doing would be unsupported, its not expected for your script to have all indicator data at the start of OnBarUpdate. The way all scripts are expected to work with OnBarUpdate is to process each datapoint the same as it would in realtime. There is an expected order of operations in relation to data processing and indicator processing which your code is going to omit so not all tools will work with that.

    On bar 0 it would be expected for the strategy to call the indicator and then that indicator will process its bar 0 so the strategy could retrieve a plot value. That process continues all the way through historical data until you reach the end of bars.



    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    135 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X