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:6,134 / 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 90,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

Reply
 1  
 
Thread Tools Search this Thread
 

How to code a sound alert

  #1 (permalink)
Elite Member
Arcata, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
 
Saroj's Avatar
 
Posts: 482 since Jun 2009
Thanks: 223 given, 389 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
Reply With Quote
 
  #2 (permalink)
Elite Member
Norcross, Ga
 
Futures 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.

Reply With Quote
 
  #3 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,220 since Jun 2009
Thanks: 628 given, 6,318 received
Forum Reputation: Legendary


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

Reply With Quote
 
  #4 (permalink)
 Vendor: www.tradingstudies.com 
Denver, CO
 
Futures 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, 272 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);

Reply With Quote
The following 4 users say Thank You to roonius for this post:
 
  #5 (permalink)
Elite Member
Frankfurt
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 917 received

Just gotta say : Wow + ThanX saroj !

max-td
Reply With Quote
 
  #6 (permalink)
Trading for Fun
Here, GA
 
Futures Experience: Intermediate
Platform: Ninja
 
Posts: 146 since Jun 2009
Thanks: 1 given, 73 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.

Reply With Quote
 
  #7 (permalink)
Elite Member
Arcata, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
 
Saroj's Avatar
 
Posts: 482 since Jun 2009
Thanks: 223 given, 389 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.

Reply With Quote
 
  #8 (permalink)
Elite Member
Arcata, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
 
Saroj's Avatar
 
Posts: 482 since Jun 2009
Thanks: 223 given, 389 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

Reply With Quote
 
  #9 (permalink)
Trading Apprentice
Yonkers, NY/USA
 
Futures 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

Reply With Quote
 
  #10 (permalink)
Market Wizard
Houston, TX
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Optimus Futures
Favorite Futures: 6E
 
TheWizard's Avatar
 
Posts: 1,711 since Jun 2009
Thanks: 509 given, 4,072 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!
Reply With Quote

Reply



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

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

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 06:58 PM.

Copyright © 2017 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
Page generated 2017-12-16 in 0.16 seconds with 20 queries on phoenix via your IP 54.145.16.43