Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.



    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by helpwanted, Today, 03:06 AM
    1 response
    11 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    9 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    387 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X