Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
bars ago range in one strategy instead of different strategies
Collapse
X
-
bars ago range in one strategy instead of different strategies
i'm trying to make an alert sound happen when a crossunder happens and then price touches a bollinger line so many bars preceding the crossunder. the price can touch the bollinger maybe 5 different bars from the crossunder. so the crossunder would have a bars ago of 5,6,7,8,9, and 10. instead of doing a different strategy for each one, can i combine them in one strategy?Tags: None
-
Hello SteveReiza,
Thanks for your post.
The PlaySound() method could be used to play a sound when a condition becomes true.
PlaySound(): https://ninjatrader.com/support/help.../playsound.htm
It would ultimately be up to you if you would like to combine multiple strategies into a single strategy script depending on your overall goal.
A NinjaScript strategy cannot see another strategy so if you need to trigger an alert sound when a condition occurs, you would need to add the condition to a single strategy script and call the PlaySound() method within your condition to play.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
-
okay sweet. i think i figured it out. i can do them in groups in one strategy.
is there a way to have the alert only make the sound once? because i have it working on the condition. but it keeps making the sound repetitively. i only want the alert to play once. any suggestions?
Comment
-
Hello SteveReiza,
Thanks for your notes.
You could consider using a bool in your custom logic to control when the PlaySound() method is triggered.
For example, you could create a bool variable initially set to true, check if the bool is true in your condition to call PlaySound() and the one line after calling PlaySound() set the bool to false.
That way the PlaySound() method would only be called when the bool is true and the bool would be set to false after the PlaySound() method fires.
Note that you would need to come up with custom logic in your script for resetting the bool to true at some point, otherwise the bool with remain false and PlaySound() will not trigger.
For example, if you wanted to reset the bool to true on the first tick of each new bar, you could create a condition that checks if IsFirstTickOfBar is true and set the bool to true.
IsFirstTickOfBar: https://ninjatrader.com/support/help...ttickofbar.htm<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
566 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
329 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
548 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment