Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Finding gaps in an uptrend

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

    Finding gaps in an uptrend

    Hi,

    I have written a custom indicator to find gaps in an uptrend. Basically I want to identify gaps where the current day's low is higher than the previous trading day's high which should find me any gaps in an uptrend.

    I want to be able to output a value of +1 when I find a gap so that I can then filter on this value in the Market Analyser when I incorporate this custom indicator there.

    The code I am using is as follows:

    protectedoverridevoid 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 (Low[0] < PriorDayOHLC().PriorClose[0])
    {
    Value.Set(
    1);
    }
    else
    {
    Value.Set(
    0.0);
    }
    }

    Please let me know if you think this will give me what I need.

    Many thanks,

    Evan

    #2
    Originally posted by evan.hatch View Post
    Hi,

    I have written a custom indicator to find gaps in an uptrend. Basically I want to identify gaps where the current day's low is higher than the previous trading day's high which should find me any gaps in an uptrend.

    I want to be able to output a value of +1 when I find a gap so that I can then filter on this value in the Market Analyser when I incorporate this custom indicator there.

    The code I am using is as follows:

    protectedoverridevoid 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 (Low[0] < PriorDayOHLC().PriorClose[0])
    {
    Value.Set(
    1);
    }
    else
    {
    Value.Set(
    0.0);
    }
    }

    Please let me know if you think this will give me what I need.

    Many thanks,

    Evan
    Why not just say Low[0] > Hiogh[1] as your condition?

    Comment


      #3
      Hello evan.hatch,

      The following assumes you are using a minute chart (or interval less than day).

      To ensure you have the current day's low (and not the low of the current minute bar) you can use CurrentDayOHL().CurrentLow[0].


      To find yesterday's high you can use PriorDayOHLC().PriorHigh[0].


      For example:
      Code:
      if (CurrentDayOHL().CurrentLow[0] > PriorDayOHLC().PriorHigh[0])
      {
      // execute code
      }
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hi Chelsea,

        Many thanks for your response. I can confirm that I am not using minute data and am only using Yahoo EOD data so the assistance you have provided should be very useful for me.

        Please can you point me to some sample code or examples which might help me if I wanted to do further calculations for any of the gaps that I find. I am probably going to want to calculate the percentage of the gap based on the previous day's close.

        So I probably won't be outputting a value of 1 it will more likely be different values based on the calculations. If there is no gap then the indicator should still be output as 0.

        I hope this helps clarify my thoughts further.

        Many thanks,

        Evan

        Comment


          #5
          Hi Evan,

          If you do not have intra-day data, this would not work. In this case, use the method proposed by koganam and use Low[0] > High[1] on a daily chart.

          I'm not aware of any examples for what you are specifically trying to achieve. However, I do have an example of plotting a value for the Market Analyzer to use as a trigger in the Alert/Cell/Filter conditions.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          579 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 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
          554 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