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

Adding Indicator to Chart

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

    Adding Indicator to Chart

    Ok. I usually add indicators to my strategy without a problem, however I have this indicator that I have placed Plot into the code for reference in my strategy. If I place the indicator on my chart it plots the information. However when I add the indicator to the strategy, It plots nothing. Can you tell me what I may be missing.There are no errors shown.

    In the indicator information is populated using onmarketdata.


    private NinjaTrader.NinjaScript.Indicators.ddma.deltax RealtimeIndicator1;

    protected override void OnStateChange()
    {
    .......
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    }
    else if (State == State.DataLoaded)
    {

    RealtimeIndicator1 = deltax(Close, true, false, true, false);
    AddChartIndicator(RealtimeIndicator1);
    }

    #2
    Hello richa61416,

    Thank you for your post.

    This looks like the correct syntax. Is this a 3rd party indicator you got from elsewhere, or is this an indicator you created yourself? Do any errors appear in the log panel of the Control Center?

    Thanks in advance; I look forward to assisting you further.

    Kate W.NinjaTrader Customer Service

    Comment


      #3
      It is a 3rd party indicator made available for elite members, for which they provide the source code hence I can make any changes I want. I added the plots to the indicator, and they displayed fine, it is only the addchartindicator within strategies that fails to allow it to run. Any clues as to what may stop it from running on strategy?

      Comment


        #4
        Hello richa61416,

        Thank you for your reply.

        This sounds like it may be a state issue.



        If you are adding an indicator which is dependent on the correct State of the indicator, you will need to ensure that you are also calling the indicator from the strategy in OnBarUpdate(), otherwise your indicator will only process in State.RealTime for performance optimizations.

        Essentially if you dont call the indciator in OBU and only AddChartIndicator you can see it "not work" until later in realtime.

        So you could try something like this:

        protected override void OnBarUpdate()
        {
        // call deltax() historically to ensure the indicator processes its historical states as well
        double deltax1 = deltax(Close, true, false, true, false)[0];
        }

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        19 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X