Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bollinger band indicator on OBV with alert

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

    Bollinger band indicator on OBV with alert

    Hello,

    I wish I could code an indicator that applies the bollinger bands to the OBV. This would allow me to have a signal when the OBV breaks out of bollinger bands. Do you have a small piece of code to see how to proceed please?
    I think you have to create a data series from the OBV, but I don't see how to do it. Attached is a screenshot to illustrate:



    #2
    Hello jodu49,

    Thank you for your note.

    I've created a simple example indicator that calculates the OBV with Bollinger Bands based on it. This will play a sound and print an alert to the Alerts Log window when the OBV crosses above or below the upper or lower bollinger bands. This should give you a jumping off point to add your own logic.

    Please let us know if we may be of further assistance to you.
    Attached Files

    Comment


      #3
      Thanks very much! That's great ;-)

      Can you tell me how can we send an sms notification on a smartphone please? It seems to me that it is necessary to create a sharing service?

      Comment


        #4
        Hello jodu49,

        Thank you for your reply.

        You would first need to set up an email address and then set up a Text Message Via Email sharing service, yes.

        Please follow the steps below to set up an email account with NinjaTrader 8:
        • Navigate to the Control Center > Tools > Options
        • Click in the Share Services box
        • Click to highlight 'Email' or 'Text message via Email' and click add
        • Fill out your email information and click OK
        • Below I have provided a link to our Support Forum on e-mail SMTP setups which includes details regarding using Gmail.
        https://www.ninjatrader.com/support/...008#post262008

        Once you have your Email share service set up, you can proceed to set up the Text message via Email to receive texts.

        To set up a text messages account that can be used to send messages from NinjaTrader, select 'Text message via email' from the 'available' section and click the add button. The Properties section should be available to enter the needed information to set up your 'Text message via email' Share Service. NinjaTrader needs the SMS address and MMS address for the entered phone number in order to send the messages as expected. Depending on your phone provider, you can use the preconfigured selections available in the 'Preconfigured Settings' section.

        Here is a publicly available link from our help guide which goes over these settings and properties in further detail: https://ninjatrader.com/support/help...gShareServices

        When all that is set up, you can then use Share() within your scripts to share to the Text message via Email sharing service:



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

        Comment


          #5
          Hello,
          It's ok for sending alerts by gmail. Difficult to adjust but I found that it was necessary to set up a password for application on my google account.

          On the other hand, can you tell me how I can make the signal arrows appear on the indicator instead of the chart please?
          Right now I'm using this, friends I don't know how to display on the indicator: Draw.ArrowDown(this, "MyArrowDown", false, 0, High[0], Brushes.Red);

          Thank you for you precious help

          Comment


            #6
            IIn fact, I would like this:

            Comment


              #7
              Hello jodu49,

              Thank you for your reply.

              If you want your drawing objects to appear on the indicator panel, set DrawOnPricePanel to false in State.SetDefaults:

              Code:
              protected override void OnStateChange()
              {
              if (State == State.SetDefaults)
              {
              Description = @"Example";
              Name = "ExampleIndicator";
              Calculate = Calculate.OnBarClose;
              IsOverlay = false;
              DisplayInDataBox = true;
              [B]DrawOnPricePanel = false;[/B]
              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;
              }
              }
              Please note you will need to completely remove the indicator and re-add it to the chart for this change to take effect after compiling.

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

              Comment


                #8
                Hello

                Can you help me. I would keep displaying a line each time the obv crosses the bollinger for the first time as in this screenshot.

                I have already made this beginning of code which produces the lines of the screenshot. But I only want to keep the first lines.

                Thanks for your help.

                Comment


                  #9
                  Originally posted by jodu49 View Post
                  Hello

                  Can you help me. I would keep displaying a line each time the obv crosses the bollinger for the first time as in this screenshot.

                  I have already made this beginning of code which produces the lines of the screenshot. But I only want to keep the first lines.

                  Thanks for your help.

                  My code is :

                  protected override void OnBarUpdate() {
                  int bar=Count-1-CurrentBar;

                  if (OBV1[0]>Bol1.Upper[0]) {
                  Print("bar="+bar+" >> Buy");
                  //Draw.ArrowUp(this, "MyArrowUp", false, 0, Low[0], Brushes.Lime);
                  Draw.VerticalLine(this,"VLUp"+bar,Time[0],Brushes.Lime);
                  }
                  if (OBV1[0]<Bol1.Lower[0]) {
                  Print("bar="+bar+" >> Sell");
                  //Draw.ArrowDown(this, "MyArrowDn", false, 0, High[0], Brushes.Red);
                  Draw.VerticalLine(this,"VLDn"+bar,Time[0],Brushes.Red);

                  }

                  Comment


                    #10
                    It's ok, I found by adding a test with a boolean.

                    Comment


                      #11
                      Originally posted by jodu49 View Post
                      It's ok, I found by adding a test with a boolean.
                      Hi jodu,

                      So, please how do you add "a test with a boolean" in your script.

                      omololu

                      Comment


                        #12
                        if (OBV1[0]<Bol1.Lower[0]) {
                        if (Filter_OnlyFirstSignal & LastSignal=="Sell") return;
                        LastSignal="Sell";

                        Comment


                          #13
                          Originally posted by jodu49 View Post
                          if (OBV1[0]<Bol1.Lower[0]) {
                          if (Filter_OnlyFirstSignal & LastSignal=="Sell") return;
                          LastSignal="Sell";
                          Thanks jodu.

                          I suppose these codes go inside the protected override void OnBarUpdate() ... Right ? ... and how ? And how/where do you define Filter_OnlyFirstSignal and LastSignal ?

                          omololu

                          Comment


                            #14
                            LastSignal is a private string variable to be defined at the beginning of the public class.
                            Filter_OnlyFirstSignal is to be defined in the external properties. It is not mandatory, just leave it out if you wish.

                            Comment


                              #15
                              Originally posted by jodu49 View Post
                              LastSignal is a private string variable to be defined at the beginning of the public class.
                              Filter_OnlyFirstSignal is to be defined in the external properties. It is not mandatory, just leave it out if you wish.
                              jodu,

                              Thank you very very much.

                              omololu

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              612 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              355 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              105 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              561 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              564 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X