Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
One Alert per bar
Collapse
X
-
One Alert per bar
I am using the Wizard. My strategy is a cross of the zeroline and want to have it give one Alert per bar. Right now it gives alerts for everytime the price moves. I am not a programmer, so any help would be great. I added emails to the alert and yes I am getting alot of emails......lolTags: None
-
Hello,
Thanks for the forum post!
The best way to change this to once per bar is to change the indicator to only calculate once per bar instead of on each tick. To do this right click on the chart and go to strategies. Then change the setting for Calculate On Bar Close to true. This will cause the code to run only once per bar which will be what your looking for on your alert.
Let me know if I can be of further assistance.BrettNinjaTrader Product Management
-
How is your alert being triggered?Originally posted by Viper3 View PostI am using the Wizard. My strategy is a cross of the zeroline and want to have it give one Alert per bar. Right now it gives alerts for everytime the price moves. I am not a programmer, so any help would be great. I added emails to the alert and yes I am getting alot of emails......lol
Can you post the line which triggers the alert ?
Comment
-
{
#region Variables
// Wizard generated variables
privateint myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#endregion
///<summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
///</summary>
protectedoverridevoid Initialize()
{
Add(WoodiesCCI(
2, 5, 50, 34, 25, 14, 60, 100, 2));
Add(WoodiesCCI(
2, 5, 50, 34, 25, 14, 60, 100, 2));
CalculateOnBarClose =
true;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Condition set 1
if (CrossAbove(WoodiesCCI(2, 5, 50, 34, 25, 14, 60, 100, 2), 0, 1))
{
DrawArrowUp(
"My up arrow" + CurrentBar, false, 0, Low[0], Color.Lime);
PlaySound(
@"C:\Program Files\NinjaTrader 7\sounds\Alert1.wav");
SendMail(
"[email protected]", "[email protected]", "Alert Trade 9 minute chart", "Go long set stop at 30 T1 @20");
}
Comment
-
So I need to put it under Variables. can you help me write that part. I did this but it need to be written right.
region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// boot alreadyAlertThis = false;
/// OnBarUpdate()
/// {
/// if (FirstTickOfBar)
/// {alreadyAlertThisBar=false;}
/// if(alert conditions == true&& alreadyAlertThisBar == false)
/// {
/// Alert(.....)
/// alreadyAlertThisBar = true;
/// }
/// }
///
Comment
-
See what happens with this. You cannot do it in the wizard, You are going to have to unlock the code.
Code:private bool boolAlertSounded = false; [COLOR="blue"]// declare and intialize the bool flag [/COLOR] protected override void OnBarUpdate() { if (FirstTickOfBar) boolAlertSounded = false; [COLOR="Blue"]//reset the bool flag at the start of the bar[/COLOR] // Condition set 1 if (CrossAbove(WoodiesCCI(2, 5, 50, 34, 25, 14, 60, 100, 2), 0, 1)) { DrawArrowUp( "My up arrow" + CurrentBar, false, 0, Low[0], Color.Lime); if (!boolAlertSounded) PlaySound( @"C:\Program Files\NinjaTrader 7\sounds\Alert1.wav"); [COLOR="blue"]// only if bool flag is false, play sound[/COLOR] SendMail( "[email protected]", "[email protected]", "Alert Trade 9 minute chart", "Go long set stop at 30 T1 @20"); boolAlertSounded = true; [COLOR="blue"]// set the bool flag to stop sound play[/COLOR] }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
646 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
367 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
107 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
569 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment