How to code a sound alert - NinjaTrader Programming | futures io social day trading
futures io futures trading


How to code a sound alert
Updated: Views / Replies:8,028 / 12
Created: by Saroj Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

 
 1  
 
Thread Tools
 

How to code a sound alert

 
Arcata, CA
 
Trading Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
 
Saroj's Avatar
 
Posts: 486 since Jun 2009
Thanks: 232 given, 411 received

How to code a sound alert

Putting in a sound alert

Insert the following under “#region Variables”
-------------------------
private bool soundOn = true; // on/off switch for audio alerts
private string alert1Sound = "alert1.wav"; //audio alert for Condition1
private string alert2Sound ="alert2.wav"; //audio alert for Condition2
private bool Condition1 = false;//will be set to the conditions for alert1
private bool Condition2 = false; //will be set to the conditions for alert2
-------------------------
soundOnallows the user to turn sound on and off
The wav files will be displayed as the default wav files. With the entries in the Properties section, you can change them to something else.
The Condition variables are only necessary if you choose to use them to hold the results of your criteria.

Insert the following files under C:\ProgramFiles\NinjaTrader6.5\sounds (modify for your specific installation path if different; but note that this is the executables directory, not the data directory for NinjaTrader which is typically in the “My Documents” directory. “Directory” means same as “Folder”)
-------------------------
alert1.wav
alert2.wav
-------------------------
These are fictitious file names. Find a wav file that you want and either rename to these names or change the names in the Variables section to those you select.

Insert the following under “#region Properties “ – it doesn’t have to be directly below; just somewhere before the #endregion for “Properties”.

-------------------------
[Description("what will help the user decide how to choose their entry")]
[Category("Parameters")]
public string Alert1Sound
{
get { return alert1Sound; } // this name matches that in the Variables section
set { alert1Sound = value; }
}
[Description("what will help the user decide how to choose their entry ")]
[Category("Parameters")]
public string Alert2Sound
{
get { return alert2Sound; } // this name matches that in the Variables section
set { alert2Sound = value; }
}
-------------------------
The name following “public string” will display in the Parameter area in the indicator dialogue box in the left column. The Description will appear below the parameters when the user clicks on that entry box. Enter something like “Sound file to play for long alert”.

Insert the following under “OnBarUpdate()” at the place in your logic where you want the alert:
-------------------------
if (Condition1 && soundOn) PlaySound(alert1Sound);}
if (Condition2 && soundOn) PlaySound(alert2Sound);}

If you don't want your sound to play every tick of the bar when condition is met you can use:
if (Condition1 && soundOn && FirstTickOfBar) PlaySound(alert1Sound);
if (Condition2 && soundOn && FirstTickOfBar) PlaySound(alert2Sound);
-------------------------
Condition1 and Condition2 can be either boolean variables that have been set to your criteria or you can insert your boolean statement itself.

All of the names above in bold can be replaced by your own names; however where they are the same spelling as in the example, they must be so in your modifications as well. Also in the properties section, the name following “public string” must be spelled differently from the similar name following “return” and in the set statement. Typically this is accomplished by putting the first letter following “public string” in caps.


Last edited by Saroj; October 14th, 2009 at 06:39 PM. Reason: noticed that some key words got mashed together in the paste operation; added "FirstTickOfBar" per roonius
 
 
Norcross, Ga
 
Trading Experience: Advanced
Platform: NinjaTrader, Tradestation, Think Or Swim
Broker/Data: Mirus Zen-Fire
Favorite Futures: ES
 
Posts: 15 since Sep 2009
Thanks: 5 given, 1 received

Good Stuff. Thanks.

 
 
the coin hunter
virginia
 
Trading Experience: Intermediate
Platform: ninja
Favorite Futures: NQ
 
cory's Avatar
 
Posts: 5,955 since Jun 2009
Thanks: 823 given, 7,724 received


a clear and concise guide of how to code the sound alert, excellent!

 
 
Denver, CO
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: TF, ES, CL
 
roonius's Avatar
 
Posts: 132 since Jun 2009
Thanks: 20 given, 286 received


Saroj View Post
Insert the following under “OnBarUpdate()” at the place in your logic where you want the alert:
-------------------------
if (Condition1 && soundOn) PlaySound(alert1Sound);
if (Condition2 && soundOn) PlaySound(alert2Sound);
-------------------------
Condition1 and Condition2 can be either boolean variables that have been set to your criteria or you can insert your boolean statement itself.


One small addition for those who run their indicators or strategies tick by tick (CalculateOnBarClose = false).

If you don't want your sound to play every tick of the bar when condition is met you can use:
if (Condition1 && soundOn && FirstTickOfBar) PlaySound(alert1Sound);
if (Condition2 && soundOn && FirstTickOfBar) PlaySound(alert2Sound);

The following 5 users say Thank You to roonius for this post:
 
 
Frankfurt
 
Trading Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 923 received

Just gotta say : Wow + ThanX saroj !

max-td
 
 
Here, GA
 
 
Posts: 148 since Jun 2009
Thanks: 1 given, 74 received

Saroj, Would you by chance have an Example of NT calling a C++ DLL in your bag of tricks? I have a mental block on this one. BTW very nice effort on the code and explanation above.

 
 
Arcata, CA
 
Trading Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
 
Saroj's Avatar
 
Posts: 486 since Jun 2009
Thanks: 232 given, 411 received


TAJTrades View Post
Saroj, Would you by chance have an Example of NT calling a C++ DLL in your bag of tricks? I have a mental block on this one. BTW very nice effort on the code and explanation above.

sorry TAJ, no... I'm just learning NS/C#.. but I'll bet there are examples in the NT forum... please post if you find one.

 
 
Arcata, CA
 
Trading Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
 
Saroj's Avatar
 
Posts: 486 since Jun 2009
Thanks: 232 given, 411 received


roonius View Post
One small addition for those who run their indicators or strategies tick by tick (CalculateOnBarClose = false).

If you don't want your sound to play every tick of the bar when condition is met you can use:
if (Condition1 && soundOn && FirstTickOfBar) PlaySound(alert1Sound);
if (Condition2 && soundOn && FirstTickOfBar) PlaySound(alert2Sound);

thanks roonius... if anyone else has suggestions or enhancements.. please feel free

 
 
Yonkers, NY/USA
 
Trading Experience: Beginner
Platform: NinjaTrader
Favorite Futures: SI
 
Posts: 5 since Mar 2012
Thanks: 1 given, 4 received

Insert the following under “OnBarUpdate()” at the place in your logic where you want

"Insert the following under “OnBarUpdate()” at the place in your logic where you want the alert:"

This code is great so thank you so much, but I need just a little more help since I'm not well versed in programming. I have an indicator I'm trying to add sound to. I have done what I can to follow your directions but need help in finding the "place in my logic" to add this part of the code.

Many Thanks,
Julius

 
 
Houston, TX
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Optimus Futures, AMP, CQG
Favorite Futures: 6E
 
TheWizard's Avatar
 
Posts: 1,731 since Jun 2009
Thanks: 519 given, 4,179 received



juliusnyny View Post
"Insert the following under “OnBarUpdate()” at the place in your logic where you want the alert:"

This code is great so thank you so much, but I need just a little more help since I'm not well versed in programming. I have an indicator I'm trying to add sound to. I have done what I can to follow your directions but need help in finding the "place in my logic" to add this part of the code.

Many Thanks,
Julius

@juliusnyny,

You can always post a request in the "Want your Ninjatrader indicator created free?" thread. If you upload the indicator, I'm sure someone (myself included) would be most happy to add the code for you, at the precise point in the logic where you want it. Then you can see how it's done & go from there.

After all, it's what you learn AFTER you know it all, that counts!

 



futures io > > > > > How to code a sound alert
Thread Tools



Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Using Order Flow Analysis & Longer Term Trading w/John @ No BS Trading

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sound alert if contract number exceeds a certain level in the Dom? DrE6 NinjaTrader 46 November 15th, 2016 06:23 PM
NT7 sound alert failure baberg NinjaTrader 3 July 27th, 2011 06:38 AM
Syncing a sound alert with arrows protrader007 NinjaTrader Programming 9 March 16th, 2011 09:48 PM
Alert - no sound-NT7 Al2010 NinjaTrader Programming 4 January 30th, 2011 07:02 PM
ADXVMA for Sharky - Could alert code be added with fields for wav files? Todd NinjaTrader 2 June 23rd, 2009 12:24 PM


All times are GMT -4. The time now is 03:51 PM. (this page content is cached, log in for real-time version)

Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts