Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.Brandon H.NinjaTrader Customer Service
-
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.htmBrandon H.NinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Jonker, Today, 01:19 PM
|
0 responses
1 view
0 likes
|
Last Post
by Jonker
Today, 01:19 PM
|
||
Started by futtrader, Today, 01:16 PM
|
0 responses
5 views
0 likes
|
Last Post
by futtrader
Today, 01:16 PM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
14 responses
1,791 views
0 likes
|
Last Post
by aligator
Today, 11:47 AM
|
||
Started by Jimmyk, 01-26-2018, 05:19 AM
|
6 responses
838 views
0 likes
|
Last Post
by emuns
Today, 11:27 AM
|
||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
6 responses
3,294 views
1 like
|
Last Post
by jgualdronc
Today, 10:56 AM
|
Comment