Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Peaking Volume alert

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

    Peaking Volume alert

    Hi everyone,

    How to set up an email alert only for the Peaking volume.So far it sends alertts on eachand every bar.
    Attached Files

    #2
    Hello Cachevery,

    Do you run the CalculateOnBarClose set to True or False?

    If you want to create an email you would need to use the SendMail() method to accomplish this.
    http://www.ninjatrader.com/support/h...l?sendmail.htm
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      Hello Cachevery,

      Do you run the CalculateOnBarClose set to True or False?

      If you want to create an email you would need to use the SendMail() method to accomplish this.
      http://www.ninjatrader.com/support/h...l?sendmail.htm
      Hi Cal,i set COBC to ttrue.sendmail() method doesn`t help whatsoever.When i try to imply it it sends alerts on each new bar.

      Comment


        #4
        Originally posted by cachevery View Post
        Hi Cal,i set COBC to ttrue.sendmail() method doesn`t help whatsoever.When i try to imply it it sends alerts on each new bar.
        I looked at the indicator you posted and did not see any Sendmail in the code. Can you show the section of the indicator where you implementing Sendmail?

        Comment


          #5
          Originally posted by Tasker-182 View Post
          I looked at the indicator you posted and did not see any Sendmail in the code. Can you show the section of the indicator where you implementing Sendmail?
          Hi Tasker,sure,please take a look at the attached.
          Attached Files

          Comment


            #6
            Originally posted by cachevery View Post
            Hi Tasker,sure,please take a look at the attached.
            P.S.I`ve tried to delete the increasing bar-to-bar snippet,since i only need the peaking volume alert,but,it sends alerts on every new bar,nonetheless.

            Comment


              #7
              Originally posted by cachevery View Post
              P.S.I`ve tried to delete the increasing bar-to-bar snippet,since i only need the peaking volume alert,but,it sends alerts on every new bar,nonetheless.

              if ( ( Slope(Volume,1,0) > Slope(Volume,2,1) ) &&
              ( Slope(Volume,1,0)>0 && Slope(Volume,2,1)>0 ) ) // and are both positive (rising)
              //Slope(IDataSeries series, int startBarsAgo, int endBarsAgo)
              {
              DrawText("V"+CurrentBar, true, peakMark, 0, High[0], yPixels, pColor, pfont, StringAlignment.Center, Color.Empty, Color.Empty, 10) ;
              SendMail("[email protected]", "[email protected]","Trade Alert PeakingVolume"," "+Instrument.FullName+" "+DateTime.Now);
              }

              Comment


                #8
                Originally posted by cachevery View Post
                P.S.I`ve tried to delete the increasing bar-to-bar snippet,since i only need the peaking volume alert,but,it sends alerts on every new bar,nonetheless.
                The reason that sendmail is operating on every bar is because you have not encapsulated the send mail statement with the logic that physically precedes it, thus on every bar update a send mail is sent.

                To encapsulate the send mail with the logic you need to use an opening "{" and a closing "}".

                For clarity and in this example, C# "allows" you to write a line of logic (the if statement) followed by an action, however it is poor coding practice not to encapsulate the action within { }. So the original code had one action which was the drawtext. When you added the sendmail method, C# treated it as another line of code not connected to the previous, to execute with each onbarupdate. By using the { } you can put as many actions as you wish to execute when the preceding condition (the if statement) is TRUE.

                Here is the way that section of code needs to look:

                Code:
                if (( Slope(Volume,1,0) > Slope(Volume,2,1) ) &&( Slope(Volume,1,0)>0 && Slope(Volume,2,1)>0 ) )// and are both positive (rising)
                			[COLOR="Red"]{[/COLOR]
                				DrawText("V"+CurrentBar, true, peakMark, 0, High[0], yPixels, pColor, pfont, StringAlignment.Center, Color.Empty, Color.Empty, 10) ;
                				SendMail("[email protected]", "[email protected]","Trade Alert PeakingVolume"," "+Instrument.FullName+" "+DateTime.Now);
                			[COLOR="red"]}[/COLOR]
                Hope this helps.

                Comment


                  #9
                  Originally posted by Tasker-182 View Post
                  The reason that sendmail is operating on every bar is because you have not encapsulated the send mail statement with the logic that physically precedes it, thus on every bar update a send mail is sent.

                  To encapsulate the send mail with the logic you need to use an opening "{" and a closing "}".

                  For clarity and in this example, C# "allows" you to write a line of logic (the if statement) followed by an action, however it is poor coding practice not to encapsulate the action within { }. So the original code had one action which was the drawtext. When you added the sendmail method, C# treated it as another line of code not connected to the previous, to execute with each onbarupdate. By using the { } you can put as many actions as you wish to execute when the preceding condition (the if statement) is TRUE.

                  Here is the way that section of code needs to look:

                  Code:
                  if (( Slope(Volume,1,0) > Slope(Volume,2,1) ) &&( Slope(Volume,1,0)>0 && Slope(Volume,2,1)>0 ) )// and are both positive (rising)
                  			[COLOR="Red"]{[/COLOR]
                  				DrawText("V"+CurrentBar, true, peakMark, 0, High[0], yPixels, pColor, pfont, StringAlignment.Center, Color.Empty, Color.Empty, 10) ;
                  				SendMail("[email protected]", "[email protected]","Trade Alert PeakingVolume"," "+Instrument.FullName+" "+DateTime.Now);
                  			[COLOR="red"]}[/COLOR]
                  Hope this helps.

                  Yes,that helped.Thanks Tasker!

                  Comment


                    #10
                    Hi Guys,have the same problem with another indicator.Could anyone help?I get alerts on each bar again.Please see the attached.I`ve tried to embed it in the bottom of the code as well as in the middle,as per the enclosed,but all futile..
                    Attached Files

                    Comment


                      #11
                      Originally posted by cachevery View Post
                      Hi Guys,have the same problem with another indicator.Could anyone help?I get alerts on each bar again.Please see the attached.I`ve tried to embed it in the bottom of the code as well as in the middle,as per the enclosed,but all futile..
                      My ninja trader PC is being scanned so i can only look at the indicator as a text file. What I see is that you placed your Sendmail below a break statement. So again the code you added will be executed on each bar update, as you already confirmed.

                      You will need to move your code above the break statement. Be careful with the { }.

                      Comment


                        #12
                        Originally posted by Tasker-182 View Post
                        My ninja trader PC is being scanned so i can only look at the indicator as a text file. What I see is that you placed your Sendmail below a break statement. So again the code you added will be executed on each bar update, as you already confirmed.

                        You will need to move your code above the break statement. Be careful with the { }.
                        Hello Tasker,i moved the code above the "break" statement,as you`ve suggested,and it feels
                        like it doesn`t send alerts on each bars.But why it prints 2 or 5 bars even though i set the 4 in the "Bar count" input,in the code menu.How do i get the exact 4 bars to trigger?

                        Comment


                          #13
                          Originally posted by cachevery View Post
                          Hello Tasker,i moved the code above the "break" statement,as you`ve suggested,and it feels
                          like it doesn`t send alerts on each bars.But why it prints 2 or 5 bars even though i set the 4 in the "Bar count" input,in the code menu.How do i get the exact 4 bars to trigger?
                          It would help if you could copy/paste that section of the code to look at.

                          Comment


                            #14
                            Originally posted by Tasker-182 View Post
                            It would help if you could copy/paste that section of the code to look at.
                            Sure,Tasker,

                            i`m not sure what section exactly,but i will post the entire code,with embeded email and sound alert now:

                            protected override void OnBarUpdate()
                            {
                            if (CurrentBar < BarCount)
                            {
                            Value.Set(0);
                            }
                            else
                            {
                            bool gotBars = false;

                            for (int i = 0; i < BarCount + 1; i++)
                            {
                            if (i == BarCount)
                            {
                            gotBars = true;
                            {
                            SendMail("[email protected]", "[email protected]","Trade Alert NBars"," "+Instrument.FullName+" "+Time[0]);
                            PlaySound(@"C:\Program Files (x86)\NinjaTrader 7\sounds\Alert4.wav");
                            }
                            break;
                            }

                            if (!(Close[i] > Close[i + 1]))
                            break;

                            if (BarUp && !(Close[i] > Open[i]))
                            break;

                            if (HigherHigh && !(High[i] > High[i + 1]))
                            break;

                            if (HigherLow && !(Low[i] > Low[i + 1]))
                            break;
                            }


                            Value.Set(gotBars == true ? 1 : 0);
                            }
                            }
                            Last edited by cachevery; 05-25-2014, 09:51 PM.

                            Comment


                              #15
                              The problem that it prints the arbitrary number of consecutive bars,it could be 2,1 or 7,as long asd i`m testing it now.I`m not sure what it is, but the logic suggests,that a desired amount of bar must appear to trigger alert.If one set it to 4 then it should trigger when four bars are in play,and not 5-6-7 or whatever.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              561 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              325 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
                              547 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              547 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X