![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
|
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......lol
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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.
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Senior Member
|
Quote:
Can you post the line which triggers the alert ? |
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
|
I can post the step by step of the strategy if you like or email it.
|
|
|
|
|
|
#5 |
|
Senior Member
|
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
|
{
#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( "caragiom@gmail.com", "caragiom@gmail.com", "Alert Trade 9 minute chart", "Go long set stop at 30 T1 @20"); } |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
|
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; /// } /// } /// |
|
|
|
|
|
#8 |
|
Senior Member
|
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; // declare and intialize the bool flag
protected override void OnBarUpdate()
{
if (FirstTickOfBar) boolAlertSounded = false; //reset the bool flag at the start of the bar
// 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"); // only if bool flag is false, play sound
SendMail(
"caragiom@gmail.com", "caragiom@gmail.com", "Alert Trade 9 minute chart", "Go long set stop at 30 T1 @20");
boolAlertSounded = true; // set the bool flag to stop sound play
}
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| email alert every bar close | meirba | Miscellaneous Support | 1 | 03-26-2011 10:16 PM |
| sound alert() for a big bar | crmcwi | Indicator Development | 2 | 05-11-2010 05:30 AM |
| Alert set to once per bar | blarouche | Indicator Development | 4 | 08-18-2009 09:12 AM |
| audio alert upon completion of a bar | stephenszpak | Market Analyzer | 18 | 05-10-2009 01:57 AM |
| Alert on new bar? | tradingcube | Charting | 2 | 02-03-2009 12:22 PM |