Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price Gap Fill Indicator - Help Please

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

    Price Gap Fill Indicator - Help Please

    Goal: Identifies stocks which gapped up/down in past & now the price might try to fill the gap.

    #region Variables
    // Wizard generated variables
    private double priceGapPercent = 5.000; // Default setting PriceGapPercent
    // User defined variables (add any user defined variables below)
    public double GapHigh; // should retain value
    public double GapLow; //should retain value
    #endregion

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), PlotStyle.Bar, "Plot0"));
    CalculateOnBarClose = true;
    Overlay = false;
    PriceTypeSupported = false;
    GapHigh = double.NaN;
    GapLow = double.NaN;
    }

    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.
    //Plot0.Set(Close[0]);

    if ((High[0] >= GapLow*0.99) || (Low[0] <= GapHigh*1.01))
    {
    Plot0.Set(1);

    if (High[0] >= GapLow)
    {
    GapLow = Double.NaN;
    }

    if (Low[0] <= GapHigh)
    {
    GapHigh = Double.NaN;
    }
    }

    if (Low[0] >= (High[1] * (1 + priceGapPercent/100)))
    {
    GapHigh = Low[0];
    }

    if (High[0] <= (Low[1] - (High[1]*priceGapPercent/100)))
    {
    GapLow = High[0];
    }
    }

    -----------------------------------------------------------------------

    This logic works in Blocks scanning software and I was trying to make it work using NinjaTrader.

    The original code in Blocks is as follows:

    '# gapSizePercent = userinput.single = 5.00

    '#Cumulative
    Static GapHigh As Single
    Static GapLow As Single
    If isFirstBar Then
    GapHigh = Single.NaN
    GapLow = Single.NaN
    End If

    If Price.High >= GapLow*(0.99) Or Price.Low <= GapHigh*(1.01) Then
    Pass
    If Price.High >= GapLow Then GapLow = Single.NaN
    If Price.Low <= GapHigh Then GapHigh = Single.NaN
    'If Price.High >= GapHigh Then GapHigh = Single.NaN
    'If Price.Low <= GapLow Then GapLow = Single.NaN
    End If
    If Price.Low >= Price.High(1)+(Price.High(1)*(gapSizePercent)/100) Then GapHigh = Price.Low
    If Price.High <= Price.Low(1)-(Price.High(1)*(gapSizePercent)/100) Then GapLow = Price.High

    ------------------------------------------------------------------------

    I am able to compile the code in Ninja Trader but when I apply it on a stock chart like TEG, it does not seem to work.

    Few other symbols you can try:
    NCMI, SNPS, PRGO

    Can anyone help me as I am new to NinjaTrader. Am I doing anything wrong!!!

    #2
    Are there any errors in the Control Center log (tab on the far right)?

    You can also just try using 0 instead of NaN.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Thanks - Fixed it :-) How to share with others?

      I had to modify few things and absolutely need to use double.Nan for it to work correctly.

      Can you please tell me where can I post/share the code so that other people can use it.

      Comment


        #4
        Sure, if you'd like to upload it to the file-sharing section you can just click right here.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Thanks for quick response.

          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