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

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 funk10101, Today, 09:43 PM
          0 responses
          2 views
          0 likes
          Last Post funk10101  
          Started by pkefal, 04-11-2024, 07:39 AM
          11 responses
          36 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Yesterday, 08:51 AM
          8 responses
          44 views
          0 likes
          Last Post bill2023  
          Started by yertle, Today, 08:38 AM
          6 responses
          25 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          24 views
          0 likes
          Last Post algospoke  
          Working...
          X