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 Jonker, Today, 01:19 PM
          0 responses
          1 view
          0 likes
          Last Post Jonker
          by Jonker
           
          Started by futtrader, Today, 01:16 PM
          0 responses
          5 views
          0 likes
          Last Post futtrader  
          Started by Segwin, 05-07-2018, 02:15 PM
          14 responses
          1,791 views
          0 likes
          Last Post aligator  
          Started by Jimmyk, 01-26-2018, 05:19 AM
          6 responses
          838 views
          0 likes
          Last Post emuns
          by emuns
           
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          6 responses
          3,294 views
          1 like
          Last Post jgualdronc  
          Working...
          X