Announcement

Collapse
No announcement yet.

Delayed Alerts Function

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Delayed Alerts Function

    v10 was supposed to play multiple alerts even if triggered at the same time but it doesn't. I'm trying to come up with a work around. I'm going to have several charts running with the same indicator. I want all alerts if triggered to play no matter when triggered which should already be a basic function of this software. My alerts are set to sound when a new bar is created. If there are multiple alerts only one is audible. The only way looks to be a delay set for each indicator to play at a different time if triggered for each chart. I found this code buy JasonK from several years back.
    PHP Code:
    Alert.playSound(Market+".wav")  //does a : or ; go here
      
    var cntr 0;
      for (var 
    0Delayi++) {
      
    cntr++
      } 
    But it doesn't work they way I have it. I'm using Market+".wav" for a different wav and Delay for different delay times for each chart to make the adjustments with "edit studies".
    Can someone help ? Thanks !!
    Attached Files
    Last edited by huntergatherer; 07-28-2010, 04:00 PM.

  • #2
    Re: Delayed Alerts Function

    huntergatherer
    The first issue in your script is that you omitted to set a default for the FunctionParameter used to select which sound to play.
    For information on the FunctionParameter Object and examples of its use see the article available in the EFS KnowledgeBase
    You also have an error in the argument of the Alert function used in the second condition where you omitted a dot in the "wav" string
    As to the routine you are using to delay the sound it will not work as I see it.
    This is because you are executing the alert prior to running the for loop used to insert a delay. I suspect that the example by JasonK which you reference was somewhat different and probably had a second alert executed after the for loop which would make sense in that case as this would be inserting a delay between two alerts triggered by the same event within the same efs
    In your case instead all the alerts from the different instances of the script are triggered concurrently once the condition is true which would explain why you only hear one sound
    In the image enclosed below you can find a basic example of a script that will work when used in the proper context. Keep in mind that scripts running in a chart execute in order opposite to the one in which they are loaded [or displayed] in the chart ie the topmost script executes last while the one at the bottom executes first
    So in running this sample script you will need to set the longest delay in the first instance of the formula loaded in the chart and the shortest in the last one loaded [as shown in the chart enclosed with the image which also illustrates the delays used] Once you do that you should hear three distinct sounds [ding, buzz and door] at every new ba IOW all triggered by the same event but executed at different times. Keep also in mind that different sounds may need different delays depending on their length. Try changing the delay values and see when one sound will start interfering with another
    Lastly try searching the forums as I believe there are other examples of delays created using the Date Object
    Alex




    Originally posted by huntergatherer
    v10 was supposed to play multiple alerts even if triggered at the same time but it doesn't. I'm trying to come up with a work around. I'm going to have several charts running with the same indicator. I want all alerts if triggered to play no matter when triggered which should already be a basic function of this software. My alerts are set to sound when a new bar is created. If there are multiple alerts only one is audible. The only way looks to be a delay set for each indicator to play at a different time if triggered for each chart. I found this code buy JasonK from several years back.
    PHP Code:
    Alert.playSound(Market+".wav")  //does a : or ; go here
      
    var cntr 0;
      for (var 
    0Delayi++) {
      
    cntr++
      } 
    But it doesn't work they way I have it. I'm using Market+".wav" for a different wav and Delay for different delay times for each chart to make the adjustments with "edit studies".
    Can someone help ? Thanks !!

    Comment


    • #3
      Alexis, Thanks for your help.

      Avery told me v10 would play multiple alerts triggered at the same time. I upgraded from v8 and ran this test. I ran 4 charts same symbol and indicator with an alert. I used 4 different .wav files one for each indicator using a FunctionParemeter. When the event was triggered I should of heard all 4 .wavs at the same time but v10 did the same as v8. Only one .wav is audible. The others are triggered but you can't hear them. I disabled the audible alert and then could hear one of the remaing 3 and so on until the last chart played it's different .wav. The alerts are triggered but because there at the same time, at the creation of a new bar, only 1 .wav is audible. If I get a buy and stop exit alert at the same time from different markerts I want to hear both not just one. It's a basic function. Avery said they will investigate ????

      I'm now trying to do a work around. This is what I have so far. I moved the loop to below the getbarstate line. The indicator draws correctly and plays the alert but no matter what I set "Delay" for there is no delay. The .wav is played immediately when the new bar is created. I'm using 30000 for the setting which I guess is 30000 milliseconds or 30 seconds. Do I have the loop in the wrong place? You were correct on the original code by Jasonk that was to insert a delay between 2 alerts. I thought it was adding a delay to the top alert which is what i'm trying to do. I'm going to use a FunctionParemeter so that I can adjust the delay for the alerts manually for the size .wav for each alert and hopefully dial them in so they all play. I also would like to only delay just the alert not the indicator if possible.
      PHP Code:
      function main(Length1Source1ToggleChartDelayParams) {
      if (
      vCCI1 == nullvCCI1 = new CCIStudy(Length1Source1);
      setShowTitleParameters(eval(Params));
      if(
      getBarState()==BARSTATE_NEWBAR && isLastBarOnChart()){
      for (var 
      0Delayi++) {
      }
      if (
      Toggle != "Off"){
      if (
      Chart != "Off"){
      if(
      vCCI1.getValue(CCIStudy.CCI,0)>=&& vLastAlert1 != 1){
      Alert.playSound("notify.wav");
      vLastAlert1 1;}
      if(
      vCCI1.getValue(CCIStudy.CCI,0)<&& vLastAlert1 != 2){
      Alert.playSound("door.wav");
      vLastAlert1 2;
      }}} 
      Last edited by huntergatherer; 07-29-2010, 02:01 AM.

      Comment


      • #4
        huntergatherer

        ...no matter what I set "Delay" for there is no delay. The .wav is played immediately when the new bar is created. I'm using 30000 for the setting which I guess is 30000 milliseconds or 30 seconds.
        In your script the value of 30000 is not the amount of milliseconds but the number of iterations you have set for the loop. While the time it takes to execute that loop will depend on various factors [speed of your computer, etc] my guess is that it is in the order of a few hundred milliseconds which would be shorter than the length of the alerts hence not enough to prevent the sounds from cancelling each other out. If you look at the example I posted earlier you will see that I used 26,000,000 and 13,000,000 iterations to ensure that the sound alerts were enough apart to be heard individually.
        If you are instead trying to separate the alerts by a set amount of time then I would reiterate my previous suggestion to search the forums as I believe someone has posted an example of how to do that
        Alex


        Originally posted by huntergatherer
        Alexis, Thanks for your help.

        Avery told me v10 would play multiple alerts triggered at the same time. I upgraded from v8 and ran this test. I ran 4 charts same symbol and indicator with an alert. I used 4 different .wav files one for each indicator using a FunctionParemeter. When the event was triggered I should of heard all 4 .wavs at the same time but v10 did the same as v8. Only one .wav is audible. The others are triggered but you can't hear them. I disabled the audible alert and then could hear one of the remaing 3 and so on until the last chart played it's different .wav. The alerts are triggered but because there at the same time, at the creation of a new bar, only 1 .wav is audible. If I get a buy and stop exit alert at the same time from different markerts I want to hear both not just one. It's a basic function. Avery said they will investigate ????

        I'm now trying to do a work around. This is what I have so far. I moved the loop to below the getbarstate line. The indicator draws correctly and plays the alert but no matter what I set "Delay" for there is no delay. The .wav is played immediately when the new bar is created. I'm using 30000 for the setting which I guess is 30000 milliseconds or 30 seconds. Do I have the loop in the wrong place? You were correct on the original code by Jasonk that was to insert a delay between 2 alerts. I thought it was adding a delay to the top alert which is what i'm trying to do. I'm going to use a FunctionParemeter so that I can adjust the delay for the alerts manually for the size .wav for each alert and hopefully dial them in so they all play. I also would like to only delay just the alert not the indicator if possible.
        PHP Code:
        function main(Length1Source1ToggleChartDelayParams) {
        if (
        vCCI1 == nullvCCI1 = new CCIStudy(Length1Source1);
        setShowTitleParameters(eval(Params));
        if(
        getBarState()==BARSTATE_NEWBAR && isLastBarOnChart()){
        for (var 
        0Delayi++) {
        }
        if (
        Toggle != "Off"){
        if (
        Chart != "Off"){
        if(
        vCCI1.getValue(CCIStudy.CCI,0)>=&& vLastAlert1 != 1){
        Alert.playSound("notify.wav");
        vLastAlert1 1;}
        if(
        vCCI1.getValue(CCIStudy.CCI,0)<&& vLastAlert1 != 2){
        Alert.playSound("door.wav");
        vLastAlert1 2;
        }}} 

        Comment


        • #5
          my two cents are....

          When I developed my MENT Speech app (years ago), I ran into the same problem. The solution I came up with was to stage the WAV files into a looping solution that knew the amount of time each wave file required. That way, I could call a WAV file, loop and wait for it to finish, then call another WAV file (with the alert feature).

          I suggest you do something similar.

          The way I would handle this is by building an "Alert Manager app" that used Global Values (passing Array's of objects) from the individual efs files that generate the alert. This way, when the Alert Manager gets 2 or 3+ alerts, it could stage them and process them as you require.

          Sorry there is no better solution. As I understand it, if you call multiple alerts at the same time, esignal continues to cancel the previous calls and allows the most recent wav file to be played. I believe this is also a condition related to how the sound player is designed to work. In other words, multiple calls to play a sound result in the immediate cancellation of the preceding calls to play a sound - thus only the last sound requested is played.

          Hope this helps??
          Brad Matheny
          eSignal Solution Provider since 2000

          Comment


          • #6
            Thanks for your input Doji3333 that would probably be a good solution.

            Alexis, I was using 30000 as a reference to see if it represented milliseconds not iterations. Before my last post I used the 25 million in your example on down with no effect. I tried again after reading your recent post using larger numbers. A noticeable delay of 10 seconds kicks in using numbers over 100 million. So I opened 3 charts same indicator and set the iterations at 2, 100000000, 300000000 to see if they played the alert at different times and it works. Downside the eSignal app locks up during this delay. The alerts all play within a 20 second frame but the whole app is locked during. I have other apps running that continue to run but eSignal locks up until the alerts are played. CPU usage is high during the 20 second delay. I also used smaller combinations 2, 80000000, 200000000 which work but sometimes cut off the third alert. I'm using notify.wav and door.wav. I have the for loop code under getbarstate line. Is this locking the software? Is there a way to just delay the alert and not lock the software? If not this isn't going to work to well. I planned on using 3 minute wav files on numerous indictors.

            Probably have to figure out something with a raw time function instead of a loop. Will a time function lock the software and increase CPU usage? Another idea might be to modify the pop up window function that lists alerts that are triggered. Is the pop-up list a global type list of all alerts or does it only handle 1 individual alert? Can a audible alert be attached to the function to where a single alert fires when the alert window opens which should list all the alerts that were fired without missing anything. That way I just need one audible alert then read the list to see which ones were triggered.
            Last edited by huntergatherer; 07-29-2010, 01:51 PM.

            Comment


            • #7
              huntergatherer

              Another idea might be to modify the pop up window function that lists alerts that are triggered.
              Using the Alert.addToList() function would be a far more efficient solution as it does not require the use of any delay routines and can be just as effective [besides being simpler to implement]

              Is the pop-up list a global type list of all alerts or does it only handle 1 individual alert?
              It is a global list

              Can a audible alert be attached to the function to where a single alert fires when the alert window opens which should list all the alerts that were fired without missing anything.
              Yes it can.
              Alex


              Originally posted by huntergatherer
              Thanks for your input Doji3333 that would probably be a good solution.

              Alexis, I was using 30000 as a reference to see if it reperesented milliseconds not iterations. Before my last post I used the 25 million in your example on down with no effect. I tried again after reading your recent post using larger numbers. A noticeable delay of 10 seconds kicks in using numbers over 100 million. So I opened 3 charts same indicator and set the iterations at 2, 100000000, 300000000 to see if they played the alert at different times and it works. Downside the eSignal app locks up during this delay. Thge alerts all play within a 20 second frame but the whole app is locked. I have other apps running that continue to run but eSignal locks up until the alerts are played. CPU usage is high during the 20 second delay. I also used smaller combinations 2, 80000000, 200000000 which work but sometimes cut off the third alert. I'm using notify.wav and door.wav. I have the for loop code under getbarstate line. Is this locking the software? Is there a way to just delay the alert and not lock the software? If not this isn't going to work to well. I planned on using 3 minute wav files on numerous indictors.

              Probably have to figure out something with a raw time function instead of a loop. Will a time function lock the software and increase CPU usage? Another idea might be to modify the pop up window function that lists alerts that are triggered. Is the pop-up list a global type list of all alerts or does it only handle 1 individual alert? Can a audible alert be attached to the function to where a single alert fires when the alert window opens which should list all the alerts that were fired without missing anything. That way I just need one audible alert then read the list to see which ones were triggered.

              Comment


              • #8
                Bingo, I ran some test code and at minimum one alert is audible with a list of all triggered alerts with nothing missing. That will work!!

                Wish I found the addToList function before I spent 3 days creating 20+ .wav files for everything I trade.

                Thanks for the help Alexis.

                Comment


                • #9
                  huntergatherer
                  You are welcome
                  Alex


                  Originally posted by huntergatherer
                  Bingo, I ran some test code and at minimum one alert is audible with a list of all triggered alerts with nothing missing. That will work!!

                  Wish I found the addToList function before I spent 3 days creating 20+ .wav files for everything I trade.

                  Thanks for the help Alexis.

                  Comment

                  Working...
                  X