Thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Sound alerts not working. issue with code?
Collapse
X
-
Sound alerts not working. issue with code?
Hello. Can you please review this file and tell me if there is an error in the code preventing it from playing alerts? It should be playing alerts, however it isn't.
Thanks
Tags: None
-
Hey, i'm no a developer, but just had a quick look. . have you logged that file path to Alert3.wav to make sure the full path is right? only a guess but maybe its not in the right file location?
Doesn't NinjaTrader.Core.Globals.InstallDir map to C:\Users\{YourUsername}\Documents\NinjaTrader 8 ? and the c:\program files\ninjatrader 8\sounds\ is where all the alerts sounds by default are.. maybe they don't match?
anyways i'm sure someone can give you a better response form a developers point of view, just throwing my guess out there.
-
Hello drewski1980,
xabcdtrading is correct, you should use a Print to confirm the path is correct.. The InstallDir part is correct but I believe you are missing a slash in your string to make a valid path.
The string.format should have one more slash in it to combine the paths
should likely be:Code:string.Format( @"{0}sounds\{1}", NinjaTrader.Core.Globals.InstallDir, BuySoundAlert)
Code:string.Format( @"{0}\sounds\{1}", NinjaTrader.Core.Globals.InstallDir, BuySoundAlert)
Comment
-
Thanks, I changed the code but it is still not working. I'm wondering if it should say true instead of false. see below.Originally posted by NinjaTrader_Jesse View PostHello drewski1980,
xabcdtrading is correct, you should use a Print to confirm the path is correct.. The InstallDir part is correct but I believe you are missing a slash in your string to make a valid path.
The string.format should have one more slash in it to combine the paths
should likely be:Code:string.Format( @"{0}sounds\{1}", NinjaTrader.Core.Globals.InstallDir, BuySoundAlert)
Code:string.Format( @"{0}\sounds\{1}", NinjaTrader.Core.Globals.InstallDir, BuySoundAlert)
should I change Code: PlaySound(string.Format( @"{0}\sounds\{1}", NinjaTrader.Core.Globals.InstallDir, SellSoundAlert));
alertArmed=false;
to this code: PlaySound(string.Format( @"{0}\sounds\{1}", NinjaTrader.Core.Globals.InstallDir, SellSoundAlert));
alertArmed=true;
Also, I get the following messages in ninjascript editor when opening the file, however I am still able to compile.
Thanks!
Comment
-
Hello drewski1980,
Try using a Print here to see what the value of the string is:
Print(string.Format( @"{0}\sounds\{1}", NinjaTrader.Core.Globals.InstallDir, BuySoundAlert));
The errors you are seeing is because of some formatting error. It looks like you have an error on each of the lines mentioned, if you made a mass change using replace all that may be something that could cause an error like that. You will need to double click each error and look at the code on the line it brings you to.
Comment
-
I'm not really an advanced programmer, I really can't do much beyond my previous posts. are you able to help with this?Originally posted by NinjaTrader_Jesse View PostHello drewski1980,
Try using a Print here to see what the value of the string is:
Print(string.Format( @"{0}\sounds\{1}", NinjaTrader.Core.Globals.InstallDir, BuySoundAlert));
The errors you are seeing is because of some formatting error. It looks like you have an error on each of the lines mentioned, if you made a mass change using replace all that may be something that could cause an error like that. You will need to double click each error and look at the code on the line it brings you to.
Thanks
Comment
-
Hello drewski1980,
Each of the errors need to be addressed, the most simple way is to double click on one of the errors which should bring you to that line. Then take a screenshot so we can see why that may be happening.
The print is so you can check what path is being used so you can make sure the file exists at that path
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
69 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
42 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
24 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
27 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
54 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment