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

Divergence Spotter Indicator Bug Fixed

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

    Divergence Spotter Indicator Bug Fixed

    NinjaTrader_Kate


    Hi, Kate.

    In your update to Divergence Spotter indicator you noted:

    "Fixed bug that kept indicator from loading on initial application to the chart (previously you had to reload NinjaScript on the chart for it to process properly)."

    Would you please elaborate on what causes this bug and the need for reloading NinjaScript on the chart for indicator to process correctly. I have seen this issue for several indicators that behave very similar. What is (or was) exactly done to fix the issue. Would be appreciated if you provide some generic script for fixing this issue.

    Many thanks.


    #2
    Hello aligator,

    Thank you for your note.

    The original indicator had some code in State.Configure that was checking whether ChartControl != null that wasn't getting triggered since when the State == State.Configure the ChartControl may not be available yet. This fix may not be applicable to what you're mentioning as this code is specific to this indicator.

    The original:

    Code:
     if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "DivergenceSpotterV2";
    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;
    
    indicatorType = DivergenceSpotter_IndicatorType.MACD; // Default setting for IndicatorType
    fastPeriod = 12; // Default setting for FastPeriod
    slowPeriod = 26; // Default setting for SlowPeriod
    signalPeriod = 9; // Default setting for SignalPeriod
    lookbackPeriod = 0; //If "0", then lookback to first instance of indicator crossing 0 line
    //if ">0", then lookback only that amount of bars
    barSensitivity=3; //small values increase divergences, large values decrease
    //ideal value is 50% of lookbackPeriod
    bkgopacity = 25;
    LastSignal = 0;
    BarOfLastSignal=-10;
    
    // User defined variables (add any user defined variables below)
    bardiff=0;
    DoneSearching = true;
    RunInit=true;
    
    AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Dot, "BuySignal");
    AddPlot(new Stroke(Brushes.DeepPink, 2), PlotStyle.Dot, "SellSignal");
    }
    else if (State == State.Configure)
    {
    if(RunInit && ChartControl != null)
    {
    RunInit=false;
    IsAutoScale = false;
    }
    }
    else if (State == State.DataLoaded)
    {
    TheIndicator = new Series<double>(this, MaximumBarsLookBack.Infinite);
    }
    Fixed version:

    Code:
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "DivergenceSpotterV2";
    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;
    IsAutoScale = false;
    
    indicatorType = DivergenceSpotter_IndicatorType.MACD; // Default setting for IndicatorType
    fastPeriod = 12; // Default setting for FastPeriod
    slowPeriod = 26; // Default setting for SlowPeriod
    signalPeriod = 9; // Default setting for SignalPeriod
    lookbackPeriod = 0; //If "0", then lookback to first instance of indicator crossing 0 line
    //if ">0", then lookback only that amount of bars
    barSensitivity=3; //small values increase divergences, large values decrease
    //ideal value is 50% of lookbackPeriod
    bkgopacity = 25;
    LastSignal = 0;
    BarOfLastSignal=-10;
    
    // User defined variables (add any user defined variables below)
    bardiff=0;
    DoneSearching = true;
    RunInit=true;
    
    AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Dot, "BuySignal");
    AddPlot(new Stroke(Brushes.DeepPink, 2), PlotStyle.Dot, "SellSignal");
    }
    else if (State == State.DataLoaded)
    {
    if(RunInit && ChartControl != null)
    {
    RunInit=false;
    }
    TheIndicator = new Series<double>(this, MaximumBarsLookBack.Infinite);
    }
    }
    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi There,
      I am trying to learn how this divergence spotter works. Is there any documentation of how to use it? I notice the StochasticK line is not plotting is there a settings That needs to be set?
      Any assistance would be greatly appreciated.

      Comment


        #4
        Hello dk992000,

        Thank you for your inquiry.

        According to this thread from the original developer of the NinjaTrader 7 version:

        The dots are an indication that a divergence is occuring between price and an oscillator or indicator. For instance, when prices push lower and the indicator moves higher, the dots will start to form above the price bars. The dots are a quick way to tell if price and the indicator are moving in different directions.
        https://ninjatrader.com/support/foru...rgence-spotter

        The actual stochastics plots are not plotted by this indicator so you would not see the Stochastics K line unless you add an instance of that indicator.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hi, Kate thx for your reply I found the two lines of code that needed to be changed for it to plot the Stoch lines.

          Comment


            #6
            what is the link to the updated install file,

            ALSO if I use RSI for my indicator to use for divergence, What input is for the period of the RSI indicator

            Thanks

            Comment


              #7
              Hello DTSSTS,

              Thank you for your reply.

              The Divergence Spotter indicator can be found on our publicly available User App Share here:

              https://ninjatraderecosystem.com/use...e-spotter-nt8/

              If you're using RSI as the indicator of choice in the Divergence Spotter, PeriodFast would be the period value necessary for that.

              Please let us know if we may be of further assistance.

              The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                ok thanks, I was not sure if the bug fix downloaded version was posted else where, thanks

                Comment


                  #9
                  Kate

                  I using divergence-spotter-nt8 in a strategy and plots are Buy Signal or Sell Signal. What is suppose to be the value of the Buy Signal and the Sell Signal

                  I was thinking Buy was equal to 1 and Sell was equal to -1 (from looking at the script)

                  Thanks

                  Comment


                    #10
                    Hello DTSSTS,

                    Thank you for your reply.

                    No, they will return the value at which the dots are placed on the chart, or 0. Basically, if the Buy signal is greater than 0, there is a buy signal, and if the sell signal is greater than 0 there is a sell signal.

                    Please let us know if we may be of further assistance to you.
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #11


                      Did you mean to say Sell Signal Less than 0, or to Confirm both are greater than 0
                      thanks

                      I am still having issues, I am testing in strategy with brush

                      // Long
                      if ((DivergenceSpotterV2AO.BuySignal[0] > 0))
                      {
                      BackBrush = Brushes.LimeGreen;
                      }

                      When I apply the indicator I get the default Blue and Pink Bars and the blue and pink dots, but with the strategy I get nothing
                      Last edited by DTSSTS; 05-24-2022, 02:58 PM.

                      Comment


                        #12
                        if I change to // Long
                        // Long
                        if ((DivergenceSpotterV2AO.BuySignal[0] == 0))

                        {
                        BackBrush = Brushes.LimeGreen;
                        }

                        // Short
                        if ((DivergenceSpotterV2AO.SellSignal[0] == 0))

                        {
                        BackBrush = Brushes.Crimson;
                        }

                        IF I only have the BuySignal
                        Then all bars are shown LimeGreen
                        IF I add SellSignal[0] == 0 then all bars are Crimson (because the SellSignal condition is later in the script

                        Comment


                          #13
                          Hello DTSSTS,

                          Thank you for your reply.

                          No, both SellSignal and BuySignal would return values greater than 0 if a buy or sell signal is present. They will always equal 0 if no buy or sell signals are being found.

                          However, in looking into this further, it appears this particular indicator is not intended to be used within a strategy as it's not possible to call it with all necessary parameters from the strategy. I am looking into whether modifying the inputs to be NinjaScriptProperties would allow this to be called from a strategy but thus far have not had success. I'll work on this further tomorrow as I'm at the end of my day today.

                          Thanks for your patience.
                          Kate W.NinjaTrader Customer Service

                          Comment


                            #14
                            Thank you, I have added the bwAO indicator and placed it as default, because when you load into a strategy they are not input settings (ie you cannot select which indicator to use for the divergence, so only the default can be used. After that modification I am plotting on charts and the Divergence is plotting the big Bars and the dots correctly) but when using in strategy I am having issues.

                            I did not ask earlier post, WHEN you are adding the indicator to your strategy there is not a drop down for select which indicator you wish to use (MACD, RSI, etc) I assume it loads the default and that is the only option when using in a Strategy, this is why I changed the Default

                            I have seen a few indicators that if you do not select Plot on Chart, they will not work in a strategy. I have not tried that yet

                            Update: I did try to PlotonChart and the indicator is added to the list of indicators but does not plot anything when added from a strategy

                            I also change my modification of default back to MACD, with the same results on the plots

                            This seems to imply that NO Divergence is being calculated from the strategy at all
                            Last edited by DTSSTS; 05-25-2022, 06:04 AM.

                            Comment


                              #15
                              Kate I got this to work by blocking the below lines of code


                              else if (State == State.DataLoaded)
                              {
                              // if(RunInit && ChartControl != null)
                              // {
                              // RunInit=false;
                              // }
                              TheIndicator = new Series<double>(this, MaximumBarsLookBack.Infinite);
                              }
                              }

                              protected override void OnBarUpdate()
                              {

                              // if(RunInit) return;

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Mindset, Today, 03:08 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Genesis2021, 06-24-2022, 05:19 PM
                              1 response
                              17 views
                              0 likes
                              Last Post NinjaTrader_Jason  
                              Started by thommo, 06-24-2022, 02:16 PM
                              1 response
                              24 views
                              0 likes
                              Last Post NinjaTrader_Jason  
                              Started by sgordet, 06-24-2022, 01:30 PM
                              3 responses
                              30 views
                              0 likes
                              Last Post NinjaTrader_Jason  
                              Started by Alpha2Omega007, Yesterday, 10:39 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post Alpha2Omega007  
                              Working...
                              X