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

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 usazencort, Today, 01:16 AM
          0 responses
          1 view
          0 likes
          Last Post usazencort  
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          603 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          6 responses
          23 views
          0 likes
          Last Post xiinteractive  
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          22 views
          0 likes
          Last Post Pattontje  
          Started by flybuzz, 04-21-2024, 04:07 PM
          17 responses
          230 views
          0 likes
          Last Post TradingLoss  
          Working...
          X