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