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!
See more
See less

Partner 728x90

Collapse

bars ago range in one strategy instead of different strategies

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?

    #2
    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

    Comment


      #3
      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


        #4
        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
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          okay sweet. thanks for the guidance on that.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          11 views
          0 likes
          Last Post AaronKoRn  
          Started by carnitron, Yesterday, 08:42 PM
          0 responses
          10 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Yesterday, 07:51 PM
          0 responses
          11 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,981 views
          3 likes
          Last Post jhudas88  
          Started by rbeckmann05, Yesterday, 06:48 PM
          0 responses
          9 views
          0 likes
          Last Post rbeckmann05  
          Working...
          X