How to set up an email alert only for the Peaking volume.So far it sends alertts on eachand every bar.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Peaking Volume alert
Collapse
X
-
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.htmCal H.NinjaTrader Customer Service
-
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.Originally posted by NinjaTrader_Cal View PostHello 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
Comment
-
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?Originally posted by cachevery View PostHi 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
-
Hi Tasker,sure,please take a look at the attached.Originally posted by Tasker-182 View PostI 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?Attached Files
Comment
-
Originally posted by cachevery View PostP.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
-
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.Originally posted by cachevery View PostP.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.
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:
Hope this helps.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]
Comment
-
Originally posted by Tasker-182 View PostThe 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:
Hope this helps.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]
Yes,that helped.Thanks Tasker!
Comment
-
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
-
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.Originally posted by cachevery View PostHi 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..
You will need to move your code above the break statement. Be careful with the { }.
Comment
-
Hello Tasker,i moved the code above the "break" statement,as you`ve suggested,and it feelsOriginally posted by Tasker-182 View PostMy 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 { }.
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
-
It would help if you could copy/paste that section of the code to look at.Originally posted by cachevery View PostHello 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
-
Sure,Tasker,Originally posted by Tasker-182 View PostIt would help if you could copy/paste that section of the code to look at.
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
-
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
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
325 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment