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 pibrew, 04-28-2024, 06:37 AM
        2 responses
        17 views
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by Philippe56140, 04-27-2024, 02:35 PM
        7 responses
        56 views
        0 likes
        Last Post kevinenergy  
        Started by arunkumar3, 08-25-2023, 12:40 PM
        3 responses
        169 views
        0 likes
        Last Post Trader2024!  
        Started by DJ888, 04-26-2024, 10:57 PM
        2 responses
        17 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by port119, 04-27-2024, 02:43 PM
        3 responses
        31 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X