Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator plots only one value

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

    Indicator plots only one value

    I have a simple indicator to plot a dot if close price is x% higher than open price. It only plots for one value for the most recent bar and doesn't work on historical data. Is there a setting to make it do for historical bars as well?

    #2
    without seeing this "code", there might be a if (Historical) return type thing in there...

    Comment


      #3
      I didn't find that in my code.. please see bleow code. its just plotting one value (last value whenever its true even its in historical data). My question is why is not plotting for all bars when its true

      public class jBar : Indicator
      {
      #region Variables
      // Wizard generated variables
      private int myInput0 = 1; // Default setting for MyInput0
      // User defined variables (add any user defined variables below)
      #endregion
      private double percent = 25; // Default setting for Percent
      private int distance = 3;
      private int emavalue = 3;

      /// <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"));
      Overlay = 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(CurrentBar < 1) return;

      //if (Close[0] > High[0] - ((High[0] - Low[0]) * (percent / 100)) && Range()[0] > (EMA(Range(), 20)[1] * 1.5))//EMA(Range(), emavalue)[0] > (EMA(Range(), emavalue)[1] * 1.2))
      if (Close[0] < High[0])
      {
      //Jbars[0] = Low[0] - distance * TickSize;

      DrawDot("tag1", true, 0, High[0] + TickSize, Color.DarkGreen);


      }

      Comment


        #4
        Hello chakriare,

        Thank you for writing in.

        You need to ensure the tag for each of your dots are different. With the code provided, the DrawDot() method will always overwrite the position of an already existing dot with the tag of "tag1". This is why you only see one dot.

        Per the help guide (https://ninjatrader.com/support/help...?drawdot.htm):

        A user defined unique id used to reference the draw object. For example, if you pass in a value of "myTag", each time this tag is used, the same draw object is modified. If unique tags are used each time, a new draw object will be created each time.
        One way to make your tags unique is by appending them with CurrentBar.

        Example:
        Code:
        DrawDot("tag1" + CurrentBar, true, 0, High[0] + TickSize, Color.DarkGreen);
        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Thank You. It worked.

          Comment


            #6
            Hah! I thought that looked familiar.

            The original has what you were looking for:





            Code:
            				DrawDot ( "tag"+counter, true, 0, Low[0]-distance, Color.Green );

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            164 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            318 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            246 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            350 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            179 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Working...
            X