Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator hosted by strategy experiences State = Realtime on all historical bars

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

    Indicator hosted by strategy experiences State = Realtime on all historical bars

    Hi,
    a strategy on a chart loads an additional dataseries of 1 Tick data. It also uses AddChartIndicator() to add an indicator that uses that 1 Tick data.
    The indicator experiences State *Realtime* on all historical bars, which is not correct, and screws up the very careful calculations required of the indicator.
    TickReplay is not enabled.
    NT8 version 8.0.17.2

    example of my logging which checks this:

    on CurrentBar 5 11/03/2019 9:23:00 AM of BarCount 333, state=Realtime

    I don't think I should have to code around this problem. Looking forward to your thoughts.
    saltminer.

    #2
    Hello saltminer,

    Thank you for the post.

    I believe this could be expected if you only have Added the indicator to the chart but not called it in OnBarUpate.

    Here is an example which recreates the always Real-time print:

    Code:
    protected override void OnStateChange()
    {
    
        if (State == State.DataLoaded)
        {
            AddChartIndicator(SMA(20));
        }
    }
    
    protected override void OnBarUpdate()
    {
    
    }
    To get around this, you need to have the host call the indicator so its OnBarUpdate can be called for historical bars:

    Code:
    private SMA mySma;
    protected override void OnStateChange()
    {
        if (State == State.DataLoaded)
        {
            mySma = SMA(20);
            AddChartIndicator(mySma);
        }
    }
    
    protected override void OnBarUpdate()
    {
       double dummyPlaceholder = mySma[0];
    }
    If the indicator has no plots, in OnBarUpdate you can instead use:

    Code:
    mySma.Update();


    Can you confirm if your indicator is currently being used from OnBarUpdate? If so, do you have a simplified example like the above which you can provide with your reply?


    I look forward to being of further assistance.

    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