Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicators only showing last price

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

    indicators only showing last price

    I have tried to make three different indicators including this simple one and the only thing that shows up in the rows on the market analyzer is the last price.


    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    if (Close[0] > High[1])
    {
    Plot0.Set(High[0]);
    }
    }


    thanks for any help with this

    #2
    There is internal logic that sets underlying values that have not been set to the current close price. Try something like this.

    if (Close[0] > High[1])
    {
    Plot0.Set(High[0]);
    }
    else
    Plot0.Set(0);

    This way you see a value of 0 in the MA column when your condition evaluates to false.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks for your quick reply. Still it appers its not working. here is my full code for the simple one.

      #region Using declarations
      using System;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.ComponentModel;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Gui.Chart;
      #endregion

      // This namespace holds all indicators and is required. Do not change it.
      namespace NinjaTrader.Indicator
      {
      /// <summary>
      /// Enter the description of your new custom indicator here
      /// </summary>
      [Description("Enter the description of your new custom indicator here")]
      public class test1 : Indicator
      {
      #region Variables
      // Wizard generated variables
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      #endregion

      /// <summary>
      /// This method is used to configure the indicator and is called once before any bar data is loaded.
      /// </summary>
      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
      CalculateOnBarClose = false;
      Overlay = false;
      PriceTypeSupported = false;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Use this method for calculating your indicator values. Assign a value to each
      // plot below by replacing 'Close[0]' with your own formula.
      if (Close[0] > High[1])
      {
      Plot0.Set(High[0]);
      }
      else
      Plot0.Set(0);
      }

      #region Properties
      [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
      [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
      public DataSeries Plot0
      {
      get { return Values[0]; }
      }

      [Description("")]
      [Category("Parameters")]
      public int MyInput0
      {
      get { return myInput0; }
      set { myInput0 = Math.Max(1, value); }
      }
      #endregion
      }
      }

      Comment


        #4
        To clarify, you have never seen it return the High or a value of 0? Only the close?
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by Josh View Post
          To clarify, you have never seen it return the High or a value of 0? Only the close?
          RIGHT, It will only show 0 when there is NO price data in the last. i have tried reloading the script as well. Not really sure what I am doing wrong??

          Comment


            #6
            I suspect you might have not compiled your indicator then. Maybe you only saved it. Open your indicator in the NinjaScript editor and press F5 to compile.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by Josh View Post
              I suspect you might have not compiled your indicator then. Maybe you only saved it. Open your indicator in the NinjaScript editor and press F5 to compile.
              Thanks, I thought I already did that but I did it again just to be sure. then I reloaded via F5 in the Market Analyzer and it still shows the last price???

              thanks for your help

              Comment


                #8
                Have you tried removing the indicator and then readding it to the Market Analyzer?

                An easier way to check your indicator would be to throw it onto a chart. You can see its behavior throughout all your historical data. If it works as expected in the chart then we can further debug what might be causing problems with its implementation in the Market Analyzer.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by Josh View Post
                  Have you tried removing the indicator and then readding it to the Market Analyzer?

                  An easier way to check your indicator would be to throw it onto a chart. You can see its behavior throughout all your historical data. If it works as expected in the chart then we can further debug what might be causing problems with its implementation in the Market Analyzer.
                  Hello,

                  I have tried to remove it and then readding it. I also just tried a chart but it doesnt really seem to do much (i dont see anything) to the chart in terms of "indicating" a positive.

                  It appears like the code just doesnt do anything, but I am unsure how to make it any simplier and also be able to know I can actually write the code properly

                  Comment


                    #10
                    Found the problem. Because you are using High[1] you need to first ensure you have enough bars to do this comparison. You will need to add this line of code at the beginning of the OnBarUpdate() method:
                    Code:
                    if (CurrentBar < 1)
                         return;
                    Please check out this tip for a more detailed explanation: http://www.ninjatrader-support.com/v...ead.php?t=3170
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by Josh View Post
                      Found the problem. Because you are using High[1] you need to first ensure you have enough bars to do this comparison. You will need to add this line of code at the beginning of the OnBarUpdate() method:
                      Code:
                      if (CurrentBar < 1)
                           return;
                      Please check out this tip for a more detailed explanation: http://www.ninjatrader-support.com/v...ead.php?t=3170
                      Thanks, That appears to be the problem. Where can I find out what is needed and not? I have been reading the manual and examples but having a hard time "getting my head around it". At least in terms of KNOWING what I need to put in to get what I want in to work?

                      thanks again!!!

                      Comment


                        #12
                        What do you mean by what is needed or not? The easiest way to figure out how to fix your code is to program up what you think is what you want then debug it till it actually does what you want. Please check out this tip on how to debug. It is the process I went through on your indicator to determine the error. http://www.ninjatrader-support.com/v...ead.php?t=3418
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by Josh View Post
                          What do you mean by what is needed or not? The easiest way to figure out how to fix your code is to program up what you think is what you want then debug it till it actually does what you want. Please check out this tip on how to debug. It is the process I went through on your indicator to determine the error. http://www.ninjatrader-support.com/v...ead.php?t=3418
                          Thanks again so much for your reply. I guess I am looking for a direction on where to read how to make the indicators from the very beginning.

                          thanks again

                          Comment


                            #14
                            There are some very useful tutorials that can help you pick things up. I'll link you to the first tutorial in the series. You can see the rest on the left hand side.

                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by Josh View Post
                              There are some very useful tutorials that can help you pick things up. I'll link you to the first tutorial in the series. You can see the rest on the left hand side.

                              http://www.ninjatrader-support.com/H...tml?Overview23
                              Thanks once again and I will spend some time there and in the manual.

                              The more I am working with NT the more I like it.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              574 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              332 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              553 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X