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!
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
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.
-
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 r68cervera, Today, 05:29 AM
|
0 responses
3 views
0 likes
|
Last Post
by r68cervera
Today, 05:29 AM
|
||
Started by geddyisodin, Today, 05:20 AM
|
0 responses
6 views
0 likes
|
Last Post
by geddyisodin
Today, 05:20 AM
|
||
Started by JonesJoker, 04-22-2024, 12:23 PM
|
6 responses
35 views
0 likes
|
Last Post
by JonesJoker
Today, 05:14 AM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
12 responses
3,241 views
0 likes
|
Last Post
by Leafcutter
Today, 05:08 AM
|
||
Hi
by AveryFlynn
Started by AveryFlynn, Today, 04:57 AM
|
0 responses
7 views
0 likes
|
Last Post
by AveryFlynn
Today, 04:57 AM
|
Comment