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

an indicator that i add to a strategy analyzer chart is not displayed?.

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

    an indicator that i add to a strategy analyzer chart is not displayed?.

    an indicator that i try to add to a strategy analyzer chart does not get displayed?.

    i am experienced at adding the HMA indicator to a chart because i use it regularly, so i can't figure out what i am doing wrong.

    any advise will be greatly appreciated

    #2
    Hello joemiller,

    Thanks for writing in.

    In order to have an indicator display on a chart when added to a strategy, it must be added with AddChartIndicator().

    Please see here for more information: https://ninjatrader.com/support/help...tindicator.htm

    If you have any other questions, please do not hesitate to ask.
    JimNinjaTrader Customer Service

    Comment


      #3
      i'm assuming that i can't do it with the strategy builder unless i unlock the code?
      it that correct?

      Comment


        #4
        Hello joemiller,

        Thanks for writing back.

        That isn't necessary as you can check the "Plot on chart" tick box when adding the indicator in the Condition Builder. This tick box will add the AddChartIndicator() method in the appropriate place.

        Please let me know if we may be of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello joemiller,

          Thanks for writing back.

          That isn't necessary as you can check the "Plot on chart" tick box when adding the indicator in the Condition Builder. This tick box will add the AddChartIndicator() method in the appropriate place.

          Please let me know if we may be of further assistance.
          per directions, i edited both of my indicators by checking the specified box for each . however, still no indicators are displayed on the chart. below is part of the total code generated by the strategy builder. there is a '' AddChartIndicator(HMA2) '' statement at the very end. i expected to see two'' AddChartIndicator(HMA2) '' statements because i have two indicators [i.e.] the median of the HMA and the close of the HMA.

          --------PART OF TOTAL CODE GENERATED BY STRATEGY BUILDER---------
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = @"Enter the description for your new custom Strategy here.";
          Name = "HMAxover3";
          Calculate = Calculate.OnBarClose;
          EntriesPerDirection = 1;
          EntryHandling = EntryHandling.AllEntries;
          IsExitOnSessionCloseStrategy = true;
          ExitOnSessionCloseSeconds = 30;
          IsFillLimitOnTouch = false;
          MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
          OrderFillResolution = OrderFillResolution.Standard;
          Slippage = 0;
          StartBehavior = StartBehavior.WaitUntilFlat;
          TimeInForce = TimeInForce.Gtc;
          TraceOrders = false;
          RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
          StopTargetHandling = StopTargetHandling.PerEntryExecution;
          BarsRequiredToTrade = 20;
          // Disable this property for performance gains in Strategy Analyzer optimizations
          // See the Help Guide for additional information
          IsInstantiatedOnEachOptimizationIteration = true;
          HmaPeriodInput = 2;
          ProfitGoal = 0;
          StopLoss = 0;
          }
          else if (State == State.Configure)
          {
          SetProfitTarget("", CalculationMode.Currency, ProfitGoal);
          SetStopLoss("", CalculationMode.Currency, StopLoss, false);
          }
          else if (State == State.DataLoaded)
          {
          HMA1 = HMA(Convert.ToInt32(HmaPeriodInput));
          HMA2 = HMA(Median, Convert.ToInt32(HmaPeriodInput));
          HMA2.Plots[0].Brush = Brushes.Goldenrod;
          AddChartIndicator(HMA2);
          }
          }

          Comment


            #6
            Request for remote logon platform support

            to platform support team...
            please remotely logon to my computer to help me resolve this issue.

            Comment


              #7
              Hello joemiller,

              Thanks for writing back.

              NinjaScript inquiries are typically best handled by email and on the forum so that we can provide sample code, code references, links to resources, etc.

              If you still would like to arrange a remote support session, please write into platformsupport[at]ninjatrader[dot]com with the text "1681092 ATTN Jim" to arrange a time we may reach you during our remote support hours. Our regular support hours are 8:30am to 6pm US Eastern, Monday through Friday.

              Just to demonstrate, I have created a simple strategy using the Strategy Builder that only has a condition to check if an HMA indicator is equal to itself.


              In the above screenshot you can see that I have "Plot on chart" checked.


              In this screenshot you can observe the AddChartIndicator() code generated within OnStateChange()


              The final screen shot shows the indicator plotting in the Strategy Analyzer.

              Please create this strategy on your end to observe the behavior and please check your current strategy and make sure it is not throwing any errors in the Log tab of the Control Center or in the NinjaScript output window.

              Please let me know if I may be of further assistance.
              JimNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Jim View Post
                Hello joemiller,

                Thanks for writing back.

                NinjaScript inquiries are typically best handled by email and on the forum so that we can provide sample code, code references, links to resources, etc.

                If you still would like to arrange a remote support session, please write into platformsupport[at]ninjatrader[dot]com with the text "1681092 ATTN Jim" to arrange a time we may reach you during our remote support hours. Our regular support hours are 8:30am to 6pm US Eastern, Monday through Friday.

                Just to demonstrate, I have created a simple strategy using the Strategy Builder that only has a condition to check if an HMA indicator is equal to itself.


                In the above screenshot you can see that I have "Plot on chart" checked.


                In this screenshot you can observe the AddChartIndicator() code generated within OnStateChange()


                The final screen shot shows the indicator plotting in the Strategy Analyzer.

                Please create this strategy on your end to observe the behavior and please check your current strategy and make sure it is not throwing any errors in the Log tab of the Control Center or in the NinjaScript output window.

                Please let me know if I may be of further assistance.
                in my strategy builder, my strategy indicator for my strategy is mentioned multiple times in the conditions panel. must i check the ''plot on chart'' box every time i see it in the process of building the strategy?

                Comment


                  #9
                  Hello joemiller,

                  Thanks for the note.

                  To add an indicator to a chart through a strategy in NinjaTrader 8, you will need to use the AddChartIndicator() method. When this method is invoked that indicator is added to a chart.

                  When you click the "Plot on Chart" tick box, that line of code is added appropriately, and that indicator will be added to the chart.

                  If that tick box is not checked while adding a second instance of that indicator, there is no line of code that is placed that would remove the AddChartIndicator() line of code.

                  Therefore, having two indicators of the same configuration (one with Plot on Chart checked and one unchecked,) will still show that indicator on the chart.

                  You can observe this behavior by testing the strategy with both of the "Plot on Chart" tick boxes checked, with one of them checked, and without any of them checked. You can also click View Code to see the resulting code for a more in depth understanding.

                  Please let me know if you have any additional questions.
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Jim View Post
                    Hello joemiller,

                    Thanks for the note.

                    To add an indicator to a chart through a strategy in NinjaTrader 8, you will need to use the AddChartIndicator() method. When this method is invoked that indicator is added to a chart.

                    When you click the "Plot on Chart" tick box, that line of code is added appropriately, and that indicator will be added to the chart.

                    If that tick box is not checked while adding a second instance of that indicator, there is no line of code that is placed that would remove the AddChartIndicator() line of code.

                    Therefore, having two indicators of the same configuration (one with Plot on Chart checked and one unchecked,) will still show that indicator on the chart.

                    You can observe this behavior by testing the strategy with both of the "Plot on Chart" tick boxes checked, with one of them checked, and without any of them checked. You can also click View Code to see the resulting code for a more in depth understanding.

                    Please let me know if you have any additional questions.
                    many thanks james,
                    so i need only check the box in one instance of the box's appearance, and it doesn't have to be the first time i have the opportunity to check the box ... is that correct?

                    Comment


                      #11
                      disregard my question ''i need only check the box in one instance of the box's appearance, and it doesn't have to be the first time i have the opportunity to check the box ... is that correct?''. that is correct, i tested it per your suggestion.

                      a new question ... how do i shift [displace] an indicator on a strategy analyzer chart?

                      Comment


                        #12
                        if i can't shift [displace] an indicator on a strategy analyzer chart i think maybe i can mickey-mouse a ''fix'' by adjusting the bar number references in the in the strategy builder ... does that make sense?

                        i want to do the adjustment so that i can check my real time chart against what the strategy analyzer chart is telling me to make sure i am using realistic indicator trading signals - but of course i don't want to go to all that trouble if i can somehow just simply shift the indicator on the strategy analyzer chart.

                        so standing by for answer to ''can i shift [displace] an indicator on a strategy analyzer chart?''

                        //////////////////////////////////////////////// RESPONSE TO POST#13 VIA EDIT BUTTON //////////////////////////////////////////////////////
                        this is my first reply to the request in post#13 [i.e.] ''In the future, please use the Edit button to update your posts on the forums''
                        per suggestion in post#13, i am going to take a shot at applying the first unlocked code example because it looks easier to me ... do you agree?
                        the code i am going to use is ...

                        protected override void OnStateChange()
                        {
                        if (State == State.SetDefaults)
                        {
                        Displacement = 2; // Plots the indicator value from 2 bars ago on the current bar
                        AddPlot(Brushes.Orange, "SMA");
                        }
                        }
                        /////////////////////////////////////////////////////////////////////////////////////////////////
                        please tell me where to add the code. i made the addition as follows and got lots of errors.
                        i added 4 lines as shown.

                        protected override void OnStateChange()
                        {
                        if (State == State.SetDefaults)

                        //JM APR14'17 ADDED FOLLOWING 4 LINES OF UNLOCKED CODE TO DISPLACE HMA INDICATOR ON STRATEGY
                        // ANALYZER CHART PER https://ninjatrader.com/support/help...splacement.htm
                        {
                        Displacement = 1; // Plots the indicator value from 2 bars ago on the current bar
                        AddPlot(Brushes.Orange, "HMA");
                        }


                        {
                        Description = @"Enter the description for your new custom Strategy here.";
                        Name = "HMAinflectionTwoSetsBeforeUnlocking";
                        Calculate = Calculate.OnBarClose;
                        EntriesPerDirection = 1;
                        EntryHandling = EntryHandling.AllEntries;
                        IsExitOnSessionCloseStrategy = true;
                        ExitOnSessionCloseSeconds = 30;
                        Last edited by joemiller; 04-14-2017, 08:52 AM.

                        Comment


                          #13
                          Hello joemiller,

                          Thanks for the additional question.

                          There is not an option to change the displacement of an indicator within the Strategy Analyzer. Also there is not an option to set displacement through the Strategy Builder. With unlocked code, this can be done in one of two ways:

                          1. You can create a clone of an indicator that has its displacement set to where you want it. Please see the example from the documentation on displacement for implementation:

                          Code:
                          protected override void OnStateChange()
                          {
                              if (State == State.SetDefaults)
                              {
                                  Displacement = 2; // Plots the indicator value from 2 bars ago on the current bar     
                                  AddPlot(Brushes.Orange, "SMA");
                              }
                          }


                          2. You can unlock your strategy and add a line of code to displace the indicator you have added with AddChartIndicator(). A quick search of the forums has lead me to this example from my colleague Jesse:

                          Code:
                          ...
                          
                          else if (State == State.Configure)
                          {
                          	mySma= SMA(12);
                          	AddChartIndicator(mySma);
                          				
                          } else if(State == State.Historical){
                          	mySma.Displacement = 25;
                          }


                          In the future, please use the Edit button to update your posts on the forums. This practice keeps the forum threads tidy and easy to read for anyone browsing the forum to find solutions.

                          Thanks for your understanding, please let me know if you have any additional questions.
                          JimNinjaTrader Customer Service

                          Comment


                            #14
                            see post#12 for reply to post#13.
                            hereafter, my post responses will be in post#12 via my using the edit button.

                            Comment


                              #15
                              please tell me if i am doing the requested edit button responses correctly in post#12 ... the way i am doing it seems a bit cumbersome. also, i am trying to get this done before cob today
                              otherwise i am dead in the water for the weekend.

                              in the meantime ...
                              i have unsuccessfully tried two changes to the unlocked code. displayed below is the last change and is marked with comment beginning '//JM'.

                              please tell me how to correctly make the modification, or we can use teamviewer if you prefer.

                              protected override void OnStateChange()
                              {
                              if (State == State.SetDefaults)

                              //// //JM APR14'17 ADDED FOLLOWING 4 LINES OF UNLOCKED CODE TO DISPLACE HMA INDICATOR ON STRATEGY
                              //// // ANALYZER CHART PER https://ninjatrader.com/support/help...splacement.htm
                              //// {
                              //// Displacement = 1; // Plots the indicator value from 2 bars ago on the current bar
                              //// AddPlot(Brushes.Orange, "HMA");
                              //// }


                              {
                              Description = @"Enter the description for your new custom Strategy here.";
                              Name = "HMAinflectionTwoSetsBeforeUnlocking";
                              Calculate = Calculate.OnBarClose;
                              EntriesPerDirection = 1;
                              EntryHandling = EntryHandling.AllEntries;
                              IsExitOnSessionCloseStrategy = true;
                              ExitOnSessionCloseSeconds = 30;
                              IsFillLimitOnTouch = false;
                              MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                              OrderFillResolution = OrderFillResolution.Standard;
                              Slippage = 0;
                              StartBehavior = StartBehavior.WaitUntilFlat;
                              TimeInForce = TimeInForce.Gtc;
                              TraceOrders = false;
                              RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                              StopTargetHandling = StopTargetHandling.PerEntryExecution;
                              BarsRequiredToTrade = 20;
                              // Disable this property for performance gains in Strategy Analyzer optimizations
                              // See the Help Guide for additional information
                              IsInstantiatedOnEachOptimizationIteration = true;
                              HmaPeriod = 9;
                              }
                              else if (State == State.Configure)
                              {
                              }
                              else if (State == State.DataLoaded)
                              {
                              HMA1 = HMA(Convert.ToInt32(HmaPeriod));
                              }
                              }
                              Last edited by joemiller; 04-14-2017, 09:54 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cre8able, Today, 03:20 PM
                              1 response
                              9 views
                              0 likes
                              Last Post cre8able  
                              Started by fiddich, Today, 05:25 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post fiddich
                              by fiddich
                               
                              Started by gemify, 11-11-2022, 11:52 AM
                              6 responses
                              804 views
                              2 likes
                              Last Post ultls
                              by ultls
                               
                              Started by ScottWalsh, Today, 04:52 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by ScottWalsh, Today, 04:29 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post ScottWalsh  
                              Working...
                              X