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

jWilliams2 arrow/sound signal

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

    jWilliams2 arrow/sound signal

    Hi all.

    Working on it for 4 days now with getting nowhere.

    All I try to do is to get one arrow and sound once the jWilliams2 changes color. Unable to get it to plot only once per changed color (arrow+sound under/above the first bar only for up or down and a dot+sound when color changed back to natural)

    If anyone in the community will be able to do it and posted it here or in the share indicators section it will be great and may also serve as a benchmark for creating similar signals/alerts for color changed indicators.

    Thanks in advance,

    Tzachi.

    #2
    Tzachi, what is the code you are using to try to get it to play only once?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Austin,

      See attached. I try to have the jWilliams2 that plot the lines that change colors when rising/falling to add the arrow/sound once for the first bar when its happened.

      It is the jWilliams2 indicator with the DrawArrow and PlaySound addition to plots.

      Cannot get it to work.
      Attached Files

      Comment


        #4
        Tzachi, it looks like you're just checking for Rising() and Falling() conditions, thus the sound would occur every time the bar is rising or falling. You'll have to check for a peak or valley condition instead so it activates just once. Another option would be to use true/false flags to play the sound only after the first rising or falling condition and then reset upon the opposite condition.

        Valley:
        Code:
        if (dataSeries[0] > dataSeries[1] && dataSeries[1] < dataSeries[2])
        // valley, play sound
        A peak would have the opposite signs in the above code.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Austin,

          How and where would you add true/false flags code ?
          Can you please help with this for the indicator in question?

          Thanks.

          Comment


            #6
            If someone has a few minutes and the know how, can you add for me the arrow/sound to plot only once per direction for the first bar when jWilliams2 color changed?

            Working on it for the last few days and still cannot get it to work.
            Thanks in advance.
            Attached Files

            Comment


              #7
              Tzachi, the pseudo-code would look something like this:
              Code:
              bool alreadyRising = false;
              bool alreadyFalling = false;
              
              OnBarUpdate()
              {
                if (Rising(your indicator here))
                {
                  if (!alreadyRising)
                  {
                     // play sound
                  }
                  alreadyFalling = false;
                  alreadyRising = true;
                }
                if (Falling(your indicator))
                {
                   if(!alreadyFalling)
                   {
                      // play sound
                   }
                   alreadyFalling = true;
                   alreadyRising = false;
                }
              }
              AustinNinjaTrader Customer Service

              Comment


                #8
                Austin,

                PERFECT.

                Many thanks.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by geddyisodin, Today, 05:20 AM
                3 responses
                20 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by lorem, Today, 09:18 AM
                1 response
                5 views
                0 likes
                Last Post lorem
                by lorem
                 
                Started by bmartz, Today, 09:30 AM
                0 responses
                5 views
                0 likes
                Last Post bmartz
                by bmartz
                 
                Started by GussJ, 03-04-2020, 03:11 PM
                14 responses
                3,245 views
                0 likes
                Last Post GussJ
                by GussJ
                 
                Started by ArkansasClint, Today, 09:28 AM
                0 responses
                2 views
                0 likes
                Last Post ArkansasClint  
                Working...
                X