Announcement

Collapse
No announcement yet.

Alert.playSound

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

  • Alert.playSound

    In the EFS below the bar gets painted red if parameters occur.
    That works fine. But I just added the 2 lines immediately below.
    I would like the program to beep ( phone.wave) me if the LAST bar gets painted red but it is beeping on EVERY bar.
    What am I doing wrong? Thanks for any suggestions.


    if (vColor = Color.red)
    Alert.playSound( "C:\ProgramFiles\eSignal\Sounds\phone.wav");

    if ( h > h1 && h > h2 && h > h3 ...
    vColor = Color.red;

    if (vColor != null)
    setPriceBarColor(vColor);
    setDefaultPriceBarColor( Color.black );
    setComputeOnClose()
    if (vColor = Color.red)
    Alert.playSound( "C:\ProgramFiles\eSignal\Sounds\phone.wav");

    return;
    }

  • #2
    Re: Alert.playSound

    mjforex
    The comparison operator in the conditional statements should be == and not just = ie
    if(vColor == Color.red)
    That may not be the only reason why the efs is not working as expected however without seeing the entire script it is not possible to determine what the problem may be and suggest a solution. Post the complete formula and someone will be able to assist you
    Alex


    Originally posted by mjforex
    In the EFS below the bar gets painted red if parameters occur.
    That works fine. But I just added the 2 lines immediately below.
    I would like the program to beep ( phone.wave) me if the LAST bar gets painted red but it is beeping on EVERY bar.
    What am I doing wrong? Thanks for any suggestions.


    if (vColor = Color.red)
    Alert.playSound( "C:\ProgramFiles\eSignal\Sounds\phone.wav");

    if ( h > h1 && h > h2 && h > h3 ...
    vColor = Color.red;

    if (vColor != null)
    setPriceBarColor(vColor);
    setDefaultPriceBarColor( Color.black );
    setComputeOnClose()
    if (vColor = Color.red)
    Alert.playSound( "C:\ProgramFiles\eSignal\Sounds\phone.wav");

    return;
    }

    Comment


    • #3
      Alexis,

      Thanks that did it.
      So simple but I couldn't figure it out.

      Mjforex

      Comment


      • #4
        mjforex
        You are most welcome
        Alex


        Originally posted by mjforex
        Alexis,

        Thanks that did it.
        So simple but I couldn't figure it out.

        Mjforex

        Comment


        • #5
          follow up help please

          i tried the same thing here, see lines below...but i got a syntax error !! Please help. The bar is colored grey, but program didn't like it. See lines 105 and 106....106 ALERT alignment is shifted to the left, is that part of problem?? HELP !! THANKS !!! or should i move 105 and 106 after 101 ? Maybe I put it in wrong place?
          Thanks again.
          d




          96 nTRsV = nVol / nATR;
          97 }
          98
          99 if (nTRsV1 != null) {
          100 if ( (nTRsV / nTRsV1) > 1.5) setBarBgColor(Color.lightgrey);
          101 }
          102
          103 if (!bVol) nVol += "";
          104
          105 if (BarBgColor = = Color.lightgrey)
          106 Alert.playSound( "C:\ProgramFiles\eSignal\Sounds\phone.wav");

          107 return new Array(nTRsV, nVol);

          Comment


          • #6
            hi,

            I would remove lines 105 and 106 and replace lines 101 and 102 with:

            101 Alert.playSound( "C:\ProgramFiles\eSignal\Sounds\phone.wav");
            102 }

            Comment


            • #7
              sound keeps dinging

              I keep getting a ding ding ding, every one second despite the warning wave in formula (which has a different sound) even when the grey bar does initiate it keeps dinging. Did I do this correctly? See lines 101 below, thanks again.

              P.S. I copied the whole formula this time, maybe something triggered above lines that i didn't have in it before from truncated post below where i only put in last few lines. Thanks ! (Dang i don't know why the line numbers didn't get posted??)
              Well i started adding line numbers manually on this post, lines 100 and 101 are all on one line in the program, this post shows a return in middle of each.

              1 ************************************************** *
              2 Provided By : eSignal. (c) Copyright 2004
              3 Study: Using Volume to Detect Shifts In Power, by Vadim Gimelfarb
              4 Version: 1.0
              5
              6 9/3/2004
              7
              8 Notes:
              9 The background of the bar changes to light grey when the current
              10 TRsV value exceeds the prior bar's value by more than 1.5.
              11
              12 Formula Parameters: Default:
              13 ATR Length 1
              14 TRsV Thickness 2
              15 Volume Thickness 3
              16 TRsV Color Color.red
              17 Volume Color Color.blue
              18 Display Volume true
              19 ************************************************** **************/
              20
              21 function preMain() {
              22 setStudyTitle("True Range Specified Volume ");
              23
              24 // TRsV
              25 setCursorLabelName("TRsV", 0);
              26 setDefaultBarFgColor(Color.red, 0);
              27 setDefaultBarThickness(2, 0);
              28
              // Volume
              setCursorLabelName("Vol", 1);
              setDefaultBarFgColor(Color.blue, 1);
              setDefaultBarThickness(3, 1);
              setPlotType(PLOTTYPE_HISTOGRAM, 1);

              setShowTitleParameters(false);

              var fp1 = new FunctionParameter("nTRlength", FunctionParameter.NUMBER);
              fp1.setName("ATR Length");
              fp1.setLowerLimit(0);
              fp1.setDefault(1);

              var fp2 = new FunctionParameter("nThick0", FunctionParameter.NUMBER);
              fp2.setName("TRsV Thickness");
              fp2.setLowerLimit(1);
              fp2.setDefault(2);

              var fp2a = new FunctionParameter("nThick1", FunctionParameter.NUMBER);
              fp2a.setName("Volume Thickness");
              fp2a.setLowerLimit(1);
              fp2a.setDefault(3);

              var fp3 = new FunctionParameter("cColor0", FunctionParameter.COLOR);
              fp3.setName("TRsV Color");
              fp3.setDefault(Color.red);

              var fp3a = new FunctionParameter("cColor1", FunctionParameter.COLOR);
              fp3a.setName("Volume Color");
              fp3a.setDefault(Color.blue);

              var fp4 = new FunctionParameter("bVol", FunctionParameter.BOOLEAN);
              fp4.setName("Display Volume");
              fp4.setDefault(true);
              }

              var bEdit = true;
              var nCntr = 0;
              var vATR = null;
              var nTRsV = null;
              var nTRsV1 = null;

              function main(nTRlength, nThick0, nThick1, cColor0, cColor1, bVol) {
              if (bEdit == true) {
              setDefaultBarFgColor(cColor0, 0);
              setDefaultBarThickness(nThick0, 0);
              setDefaultBarFgColor(cColor1, 1);
              setDefaultBarThickness(nThick1, 1);
              if (vATR == null) vATR = new ATRStudy(nTRlength);
              bEdit = false;
              }

              if (getBarState() == BARSTATE_NEWBAR && nTRsV != null) {
              nTRsV1 = nTRsV;
              nCntr++;
              if (nCntr > 200) nCntr = 0;
              }

              bVol = eval(bVol);

              var nATR = vATR.getValue(ATRStudy.ATR);
              if (nATR == null) return;

              var nVol = volume();
              if (nATR == 0) {
              nTRsV = 0;
              } else {
              nTRsV = nVol / nATR;
              }

              99 if (nTRsV1 != null) {
              100 if ( (nTRsV / nTRsV1) > 1.5) setBarBgColor(Color.lightgrey);
              101 Alert.playSound ( "C:\ProgramFiles\eSignal\Sounds\warning.wav");
              102 }
              103
              104 if (!bVol) nVol += "";
              105
              106
              107 return new Array(nTRsV, nVol);
              108 }

              Comment


              • #8
                Try this:

                Play with the menu options to see which type of alert you like best; text in triggered alert window or sound.

                You can select different sound files and the threshold at which the alarm triggers.

                Also, if you set the threshold too low it will trigger more frequently on each new bar.

                P.S., it is best to not post line numbers because they must be deleted on this end to edit the efs script.
                Attached Files

                Comment


                • #9
                  done

                  done, i uploaded it, the original file constantly updates the formula, yours seems to do it at the end of the bar.

                  I figured out how to change the sound , by replacing NONE with "warning.wav" in line below. I assume "warning" works as
                  well as "warning.wav" since in my programs pull down detail window I don't see the *.wav after the file (fie extension that is)?

                  Thanks for adding all various options. That was some adder to program, all those "menu" items!

                  The popup text alert is working.

                  Waiting sound to kick in, I guess tomorrow , because it's closing in a couple of minutes. Yes tomorrow it will have to be.....

                  Thanks Wayne for your help.

                  Dee

                  PS see end of day file for comparison --- top stacked study is original, bottom one is your's modified.
                  --welll that didnt work, can't see how to attach file on this forem?! Sorry. Anyway the volumes are off by comparisons.
                  Last edited by virgiliodi; 04-14-2008, 01:09 PM.

                  Comment


                  • #10
                    A little improvement so it doesn't wait till the end of the bar.

                    For the sound just select the sound file you want from the menu. You could also change the default *.wav in the menu to whatever you like.

                    So, this attached efs doesn't wait till a new bar paints and has a default of "warning.wav" in the menu.
                    Attached Files
                    Last edited by waynecd; 04-14-2008, 01:25 PM.

                    Comment


                    • #11
                      sound.wav

                      For my alert I have put in "phone.wav"
                      but instead of the phone.wav it just goes "ding"

                      I have tried other .wavs and still it just goes "ding"

                      What am I doing wrong this time?

                      Comment


                      • #12
                        my own reply--sound.wav

                        by using "\\" instead of "\" that got the sound to play properly.
                        That is in the file location area.

                        So it would be "C:\\Program Files\\.......

                        Thought I would post my own answer in case someone else had the same problem

                        Comment


                        • #13
                          correction

                          Sorry for wasting everyone time.
                          The previous post from me was wrong.
                          What actually helped the problem was a space between
                          Program and Files in the address. I had them typed w/o a space

                          Comment


                          • #14
                            Re: my own reply--sound.wav

                            mjforex
                            The reason why it did not work using the single '\' character in your path is because in JavaScript that character needs to be escaped with another '\\' character (see the section Using Special Characters in Strings in this article of the Core JavaScript Guide)
                            Alex


                            Originally posted by mjforex
                            by using "\\" instead of "\" that got the sound to play properly.
                            That is in the file location area.

                            So it would be "C:\\Program Files\\.......

                            Thought I would post my own answer in case someone else had the same problem

                            Comment

                            Working...
                            X