Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Issue with Bars.PercentComplete on backtesting vs 'live chart' historical data

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

    Issue with Bars.PercentComplete on backtesting vs 'live chart' historical data

    Hello guys,

    I just made my trading strategy all nice and ready to go, but ran into an odd incident that maybe someone out here can explain.

    I have a line in my code that says

    if(Bars.PercentComplete < 1)
    return;

    This is something I am using to simulate CalculateOnBarClose = true for only certain conditions, whereas I have to have CalculateOnBarClose = false hard-set or else other things won't work right.

    Anyway, in backtesting / strategy analyzer the things run great, because it would calculate properly and do the trades, etc etc, but when I open a live chart and start the strategy, the historical trades aren't showing up, and I have narrowed down to exactly why:

    Print(Bars.PercentComplete.ToString()); is running every time OnBarUpdate() is being called, and in strategy analyzer, it's printing 1.00, 1.00, 1.00 on every bar like it should.

    But in the historical data on my trading chart, it's printing 0.59, 0.59, 0.59 as the percent complete for all previous daily bars.

    Can anyone help me speculate why it's not calling those historical daily bars 100% complete? Thanks!


    ** Edit: For now, I just changed my code to not do a return; if bars.percentcomplete < .59, and it's working fine on both real charts and strategy analyzer -- but can anyone tell me why the number is .59 and not 1.00 on historical daily bars? Thx!

    ** Edit 2: No, sorry, it's not working fine.. because I'm getting onbarupdate being calculated on every tick again instead of only when the bar percent is fully complete, and it's just saying that bars.percentcomplete = 0.59 right now on every tick during the day
    Last edited by RunnrX; 09-13-2012, 12:16 PM.

    #2
    Hello RunnrX,
    Bars.PercentComplete is a property only relevant for the last (right-most) bar in real-time. Since it does not have [] indexes it isn’t tracking the CurrentBar progress, but only the last bar.

    In Backtest however you will get the correct values, but not in historical bars (when you are live).
    JoydeepNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    26 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, Yesterday, 09:53 PM
    2 responses
    49 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    192 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,234 views
    0 likes
    Last Post xiinteractive  
    Working...
    X