Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with Highs and Lows - Max and Min Range Plots

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

    Problem with Highs and Lows - Max and Min Range Plots

    HI,
    I created am Indicator for Ploting the maximum and minimum prices traded over a period of time.
    I am having an issue with the High and Low values from the price series which seems to ignorre the candle tails, using only the open and close values as highs and lows. (see capture)

    I have tried this with data captured live from an Apex connection and from a Ninjatrader Live Connection on 2 different instruments.

    Is it possible that the price series is wrong?
    Am I wrong with what High and Low data series should represent?
    Can you please tell me if this is an error in my coding?

    My goal is to capture the top and bottom tails.

    Click image for larger version

Name:	capture high and lows issues.png
Views:	129
Size:	55.1 KB
ID:	1311419


    Click image for larger version

Name:	capture lows.png
Views:	83
Size:	50.4 KB
ID:	1311420




    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "RangeMaxMin";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    AddTicks = 0;
    RangeBars = 10;
    AddPlot(Brushes.SeaGreen, "Upper");
    AddPlot(Brushes.OrangeRed, "Lower");
    }
    else if (State == State.Configure)
    {
    max = MAX(Low,RangeBars);
    min = MIN(High, RangeBars); ​
    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    double max0 = max[0];
    double min0 = min[0];

    Upper[0] = max0 + AddTicks * TickSize;
    Lower[0] = min0 - AddTicks * TickSize;

    }​

    #2
    Hello horacioofman,

    Thank you for your post.

    We have an existing sample script which demonstrates getting the highest high and lowest low over a specified time range and plots them on the chart:



    Please let us know if you have any further questions.

    Comment


      #3
      HI Gaby,

      Thanks for your prompt answer.
      I took a look at the indicator you send me and it has some differences from the indicator I need..
      The indicator I am building reflects the most recents highs and lows from a period of x bars ago until the last one (these creates moving bands)
      The iindicator you sent me shows the highs and lows for a given period in the past (like from 9:40 to 9:59 am) and remains constant.

      With that said.your sample indicator works and calculates correcty the HighestHigh and LowestLow based on the High and Low on the Price Series
      double highestHigh = MAX(High, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];
      double lowestLow = MIN(Low, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];


      My indicator​ is using the same High and Low from the same Price Series
      else if (State == State.Configure)
      {
      max = MAX(Low,RangeBars);
      min = MIN(High, RangeBars);
      }
      }
      protected override void OnBarUpdate()
      {
      //Add your custom indicator logic here.
      double max0 = max[0];
      double min0 = min[0];

      Upper[0] = max0 + AddTicks * TickSize;
      Lower[0] = min0 - AddTicks * TickSize;


      But my indicator is ignoring the tails of the candles. See capture
      Click image for larger version

Name:	Capture.response 22 jul 1.png
Views:	84
Size:	9.7 KB
ID:	1311484
      Your sample indicator is the shorter line above. My indicator is the continuous line a few ticks under.


      The following Larger shows both indicators. The sample indicator you provided is are the short fixed lines. And my indicator is the continuous line..
      YOu can see how your indicator included the tails, while mine ignored them
      Click image for larger version

Name:	Capture.response 22 jul 2.png
Views:	86
Size:	66.0 KB
ID:	1311485


      Comment


        #4
        Hi horacioofman,

        I don't know if this will fix your problem, but I noticed a discrepancy between what you said was in their code versus yours, see the bold parts:

        With that said.your sample indicator works and calculates correcty the HighestHigh and LowestLow based on the High and Low on the Price Series
        double highestHigh = MAX(High, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];
        double lowestLow = MIN(Low, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];


        My indicator​ is using the same High and Low from the same Price Series
        else if (State == State.Configure)
        {
        max = MAX(Low,RangeBars);
        min = MIN(High, RangeBars);
        }​
        Unless there's a specific reason you needed it written that way, have you tried setting your "max" to "high" and "min" to "low" like the sample script has it written? It might not be calculating at the outer ends of the wicks because of that. But I'm still learning this stuff myself, so I could be wrong. Just thought I'd give ya something to try, in case it helps, while ya wait for the real experts to chime in

        Comment


          #5
          Originally posted by TakeFlight View Post
          Hi horacioofman,

          I don't know if this will fix your problem, but I noticed a discrepancy between what you said was in their code versus yours, see the bold parts:



          Unless there's a specific reason you needed it written that way, have you tried setting your "max" to "high" and "min" to "low" like the sample script has it written? It might not be calculating at the outer ends of the wicks because of that. But I'm still learning this stuff myself, so I could be wrong. Just thought I'd give ya something to try, in case it helps, while ya wait for the real experts to chime in

          Great catch!!!
          I will try changing that. It was definitely wrong.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          595 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          554 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X