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

Adding Audio & Message Alert to MACD BB

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

    Adding Audio & Message Alert to MACD BB

    Hello, i'm using the " MACD BB " indicator' located in the download section and I want to simply create an audio alert & message alert optoin.
    Can anyone please help me. the indicator code is attached:

    Thank you......
    Last edited by paruchuriphani; 05-30-2013, 08:27 AM.

    #2
    Hello paruchuriphani,

    Thank you for your post.

    The following code snippet shows how to create these alerts, this would be added to the OnBarUpdate() method:
    Code:
                           if(CrossAbove(dotSeries, BB_UpperBand, 1))
    			{
    				Alert("Up", NinjaTrader.Cbi.Priority.High, "MACD crossed above Upper Band", "Alert1.wav", 10, Color.Black, Color.Yellow);
    			}
    			if(CrossBelow(dotSeries, BB_LowerBand, 1))
    			{
    				Alert("Down", NinjaTrader.Cbi.Priority.High, "MACD crossed below Lower Band", "Alert1.wav", 10, Color.Black, Color.Yellow);
    			}
    For information on Alert() please visit the following link: http://www.ninjatrader.com/support/h.../nt7/alert.htm

    For information on CrossAbove() please visit the following link: http://www.ninjatrader.com/support/h...crossabove.htm

    For information on CrossBelow() please visit the following link: http://www.ninjatrader.com/support/h...crossbelow.htm

    Please let me know if you have any questions.

    Comment


      #3
      Hello,

      Thank you so much for your reply

      please tell me.. how to add this code to my indicator? because i am a layman in ninja script.

      thank you.

      Comment


        #4
        Hello paruchuriphani,

        Thank you for your response.

        Please go to the NinjaTrader Control Center > Tools > Edit NinjaScript > Indicator > double click on the MACDBBLines > then in the OnBarUpdate() section of the code add the bold lines below:
        Code:
        		protected override void OnBarUpdate()
        		{
        		
        			bbMacd.Set(MACD(Input, fast, slow, smooth)[0]);
        				
        			double Avg = EMA(bbMacd,length)[0];
        			double SDev = StdDev(bbMacd,length)[0];	
        			double upperBand=Avg+(stDv*SDev);
        			double lowerBand=Avg-(stDv*SDev);
        			
        			BB_UpperBand.Set(upperBand);
           			BB_LowerBand.Set(lowerBand);
        			dotSeries.Set(bbMacd[0]);
        			currentBar=CurrentBar;
        			
        			[B][I]if(CrossAbove(dotSeries, BB_UpperBand, 1))
        			{
        				Alert("Up", NinjaTrader.Cbi.Priority.High, "MACD crossed above Upper Band", "Alert1.wav", 10, Color.Black, Color.Yellow);
        			}
        			if(CrossBelow(dotSeries, BB_LowerBand, 1))
        			{
        				Alert("Down", NinjaTrader.Cbi.Priority.High, "MACD crossed below Lower Band", "Alert1.wav", 10, Color.Black, Color.Yellow);[/I][/B]
        			}
        		}
        Once complete press F5 to compile.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Thanks for your reply...

          please tell me how to add green arrow for buy call & red for sell in the main chart.

          Comment


            #6
            Hello paruchuriphani,

            Thank you for your response.

            You will need to add the DrawArrowDown() or DrawArrowUp() methods to your code after the desired condition has been met.

            For information on DrawArrowDown() please visit the following link: http://www.ninjatrader.com/support/h...warrowdown.htm

            For information on DrawArrowUp() please visit the following link: http://www.ninjatrader.com/support/h...rawarrowup.htm

            Please let me know if I may be of further assistance.

            Comment


              #7
              HI,

              Thank you so much for your reply,

              I try this code for Draw Up & Down Arrows

              protected override void OnBarUpdate()
              {

              bbMacd.Set(MACD(Input, fast, slow, smooth)[0]);

              double Avg = EMA(bbMacd,length)[0];
              double SDev = StdDev(bbMacd,length)[0];
              double upperBand=Avg+(stDv*SDev);
              double lowerBand=Avg-(stDv*SDev);

              BB_UpperBand.Set(upperBand);
              BB_LowerBand.Set(lowerBand);
              dotSeries.Set(bbMacd[0]);
              currentBar=CurrentBar;

              if(CrossAbove(dotSeries, BB_UpperBand, 1))
              {
              PlaySound("alert4.wav");
              DrawArrowUp("up arrow" + CurrentBar, false, 0, BB_UpperBand[0] - 2 * TickSize, Color.Green);

              }

              if(CrossBelow(dotSeries, BB_LowerBand, 1))
              {
              PlaySound("alert4.wav");
              DrawArrowDown("down arrow" + CurrentBar, false, 0, BB_LowerBand[0] + 2 * TickSize, Color.Red);

              }
              }


              But result is like this... please find the attachment


              Thank You,
              Last edited by paruchuriphani; 02-24-2013, 07:04 AM.

              Comment


                #8
                Hello paruchuriphani,

                Thank you for your response.

                You would create two private bools in the Variables section:
                Code:
                #region Variables
                private bool up = true;
                private bool down = true;
                Then you would use these in the condition, if up is true and the CrossAbove() then draw the arrow and play the sound and vice versa for the CrossBelow(). However, the bools must be set as false once the condition is met. For example:
                Code:
                if(CrossAbove(dotSeries, BB_UpperBand, 1) [B]&& up[/B])
                {
                PlaySound("alert4.wav");
                DrawArrowUp("up arrow" + CurrentBar, false, 0, BB_UpperBand[0] - 2 * TickSize, Color.Green);
                [B]up = false;
                down = true;[/B]
                }
                
                if(CrossBelow(dotSeries, BB_LowerBand, 1) [B]&& down[/B])
                {
                PlaySound("alert4.wav");
                DrawArrowDown("down arrow" + CurrentBar, false, 0, BB_LowerBand[0] + 2 * TickSize, Color.Red);
                [B]up = true;
                down = false;[/B]
                }
                Please let me know if you have any questions.

                Comment


                  #9
                  Thank you Mr.PatrickH

                  i want a script for email alert . i wrote this script . is this correct or not? please tell me.

                  if(CrossAbove(dotSeries, BB_UpperBand,1)&&up)
                  {
                  PlaySound("Alert4.wav");
                  DrawArrowUp("up arrow" + CurrentBar, false, 0, BB_UpperBand[0] - 2 * TickSize, Color.Green);
                  up=false;
                  down=true;
                  SendMail ("[email protected]","phaniparuchuri@ymail. com", Instrument.MasterInstrument.Name,"Sell this equity !");

                  }

                  if(CrossBelow(dotSeries, BB_LowerBand,1)&&down)
                  {
                  PlaySound("Alert4.wav");
                  DrawArrowDown("down arrow" + CurrentBar, false, 0, BB_LowerBand[0] + 2 * TickSize, Color.Red);
                  up=true;
                  down=false;
                  SendMail ("[email protected]","phaniparuchuri@ymail. com", Instrument.MasterInstrument.Name,"Buy this equity !");
                  }
                  }
                  Last edited by paruchuriphani; 02-21-2013, 10:52 AM.

                  Comment


                    #10
                    Hello,

                    While I can't verify the correctness of the if statement the SendMail() does look correct as you have it in the format

                    SendMail(string from, string to, string subject, string text)

                    one thing i noticed is that your "to" email address might have a typo

                    not sure if you wanted to have [email protected]

                    LanceNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks for your reply

                      i will change that mail ID yahoo to gmail...after i change that email ID. is that work's or not?

                      please tell me about "Instrument.MasterInstrument.Name"

                      Comment


                        #12
                        Hello,

                        If that is a valid email address then it will work. I was just pointing this out as I did not know if this was a typo or the correct input for your email address.

                        Originally posted by paruchuriphani View Post
                        please tell me about "Instrument.MasterInstrument.Name"
                        This will give you the name of the instrument being used:


                        Please let me know if I can be of further assistance.
                        LanceNinjaTrader Customer Service

                        Comment


                          #13
                          Thank you Lance for your reply

                          i have one more question i wrote a script for BUY & SELL alerts in MACDBB . I want my BUY&SELL alert signals in my main chart. please find the attachment.


                          if(CrossAbove(dotSeries, BB_UpperBand,1)&&up)
                          {
                          PlaySound("Alert4.wav");
                          DrawArrowUp("up arrow" + CurrentBar, false, 0, BB_UpperBand[0] - 2 * TickSize, Color.Green);
                          up=false;
                          down=true;
                          SendMail ("[email protected]","paruchuriphani@gmail. com", Instrument.MasterInstrument.Name,"Buy this equity !");

                          }

                          if(CrossBelow(dotSeries, BB_LowerBand,1)&&down)
                          {
                          PlaySound("Alert4.wav");
                          DrawArrowDown("down arrow" + CurrentBar, false, 0, BB_LowerBand[0] + 2 * TickSize, Color.Red);
                          up=true;
                          down=false;
                          SendMail ("[email protected]","paruchuriphani@gmail. com", Instrument.MasterInstrument.Name,"Buy this equity !");
                          }
                          }
                          Last edited by paruchuriphani; 02-24-2013, 07:04 AM.

                          Comment


                            #14
                            Hello,

                            There isn't a supported way to have your indicator plot to more than one panel. You would need to use a separate script to perform this check.

                            You could create a strategy/indicator that looks at the MACDBB values and then draws the arrows on the primary panel

                            Please let me know if I can be of further assistance.
                            LanceNinjaTrader Customer Service

                            Comment


                              #15
                              Hello,

                              please give me more information on how to create a "strategy/indicator" please give me your guidance.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              57 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X