• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Simon Investimens, Today, 03:26 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by fx.practic, Today, 05:15 AM
    0 responses
    3 views
    0 likes
    Last Post fx.practic  
    Started by guidoisot, Today, 05:03 AM
    0 responses
    2 views
    0 likes
    Last Post guidoisot  
    Started by EnveousColnago, Yesterday, 06:58 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by owreivmatot, Today, 01:38 AM
    0 responses
    1 view
    0 likes
    Last Post owreivmatot  
    Working...
    X