Announcement

Collapse
No announcement yet.

Price Alert Script Please Help

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

  • Price Alert Script Please Help

    Could someone take a look at the following script and tell what the problem is. It does not play the sound and it does not draw the text properly.

    Thanks

    function preMain() {
    setStudyTitle("Price Alert");
    setPriceStudy(true)

    var fp1 = new FunctionParameter("Price1", FunctionParameter.NUMBER);
    fp1.setName("Price > _____");
    fp1.setLowerLimit(0);
    fp1.setDefault(1.8500);

    var fp2 = new FunctionParameter("Price2", FunctionParameter.NUMBER);
    fp2.setName("Price < _____");
    fp2.setLowerLimit(0);
    fp2.setDefault(1.8500);

    var fp3 = new FunctionParameter("Alert", FunctionParameter.STRING);
    fp3.setName("Sound");
    fp3.addOption( "On" );
    fp3.addOption( "Off" );
    fp3.setDefault("Off");

    }

    function main(Alert, Price1, Price2) {


    if ( Alert == "On" && close() > Price1){
    removeImage("PA1");
    drawTextRelative(0, (high() + .0075), "Price Alert", Color.white, Color.red, Text.VCENTER|Text.CENTER, "Arial", 14, "PA1");
    Alert.playSound("beam1.wav");

    }

    if ( Alert == "On" && close() < Price2){
    removeImage("PA2");
    drawTextRelative(0, (low() - .0075), "Price Alert", Color.white, Color.red, Text.VCENTER|Text.CENTER, "Arial", 14, "PA2");
    Alert.playSound("beam1.wav");
    }

    If ( Alert == "Off");{
    }

    return
    }
    Attached Files

  • #2
    I believe...

    All you need to do is the following...

    PHP Code:
    function preMain() {
    setStudyTitle("Price Alert");
    setPriceStudy(true)

    var 
    fp1 = new FunctionParameter("Price1"FunctionParameter.NUMBER);
    fp1.setName("Price > _____");
    fp1.setLowerLimit(0);
    fp1.setDefault(1.8500);

    var 
    fp2 = new FunctionParameter("Price2"FunctionParameter.NUMBER);
    fp2.setName("Price < _____");
    fp2.setLowerLimit(0);
    fp2.setDefault(1.8500);

    var 
    fp3 = new FunctionParameter("Alert"FunctionParameter.STRING);
    fp3.setName("Sound");
    fp3.addOption"On" );
    fp3.addOption"Off" );
    fp3.setDefault("Off");

    }

    function 
    main(AlertPrice1Price2) {

    //debugPrintln(Alert+" : "+Price1+" : "+Price2);

    if ((Alert == "On") && (close() > Price1)){
    drawTextRelative(0, (high() + 0.0075), "Price Alert"Color.whiteColor.redText.VCENTER Text.CENTER"Arial"14"PA1");
    Alert.playSound("beam1.wav");

    }

    if ((
    Alert == "On") && (close() < Price2)){
    drawTextRelative(0, (low() - 0.0075), "Price Alert"Color.whiteColor.redText.VCENTER|Text.CENTER"Arial"14"PA2");
    Alert.playSound("beam1.wav");
    }

    If ( 
    Alert == "Off");{
    }

    return

    By definition, your "drawTextRelative" functions are unique (because of the TAG parameter). So, you don't have to "remove" anything (including "images").

    Now remember, sounds only play on the current bars. But based on the logic of your script, I believe this should work - as long as Alert == "On". You may simply add the debug line to check the variable conditions.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      I appreciate the help but the sound still does not play.

      As the closing price moves up and down the sound should play as long as one of the conditions is meet.

      I am using the script on a 4 hour chart and I am assumming the the condition is check ever tick.

      Thanks

      Comment


      • #4
        OK... Debug Time..

        Are you seeing the price labels on the chart - the "alerts"??

        If you are, then the code is getting to the point where it should issue the sounds. If you are NOT seeing the text labels, then the code is never getting to that point - thus, no sounds..

        Try using this debug line in your code to see what your system is doing. You can view the information in the Formula Output Window.

        debugPrintln(Alert+" : "+(close() > Price1)+" : "+(close() < Price2));

        It should report something like..

        On : false : false
        or
        On : true : false

        you could also add the following into your alert triggering conditions... (your IF statements) to check if the code is actually getting into that portion of the code.

        debugPrintln("Alert #1 triggered");

        debugPrintln("Alert #2 triggered");

        The only other thing I can think of is "check to see that you set up your alerts to operate properly (use VIEW - then ALERTS). Now, make sure you have enabled AUDIO alerts and POP-UP alserts.

        That should do it...

        B
        Brad Matheny
        eSignal Solution Provider since 2000

        Comment


        • #5
          The easiest way to see what I'm talking about is to put the Alert on a one minute chart. It will redraw the text on a previous bar and the sound does not play.

          I have other alert scripts that are working so it is not an issue with the alert sound being off. The script writes the text on the charts but it does what I described above.

          It has something to do with the way the closing price is called I think.

          As I said I have several scripts that use a sound alarm and they work perfectly that is why I am so confuse about why this won't work.

          Thanks

          Comment


          • #6
            Hi Whatever, Could you please post a final version of your "Price Alerts" code, exactly what I am after as well.

            I sent you a PM, but I dont think it got thru !

            Thx heaps

            Comment


            • #7
              Found this after doing a search, "Price and alert"



              /***********************************
              Alexis C. Montenegro © February 2004
              ************************************/

              var nLastRawTime1;
              var nLastRawTime2;

              function preMain() {
              setPriceStudy(true);
              setStudyTitle("Alert");
              setCursorLabelName("AlertHi",0);
              setCursorLabelName("AlertLo",1);
              setDefaultBarFgColor(Color.blue,0);
              setDefaultBarFgColor(Color.red,1);

              var fp1 = new FunctionParameter("ThresholdHi", FunctionParameter.NUMBER);
              fp1.setDefault(0);

              var fp2 = new FunctionParameter("ThresholdLo", FunctionParameter.NUMBER);
              fp2.setDefault(0);

              }
              function main(ThresholdHi,ThresholdLo) {

              if(ThresholdHi!=0){
              if (getValue("rawtime",0) != nLastRawTime1) {
              if(high(-1)<=ThresholdHi&&high()>ThresholdHi){
              Alert.playSound("ding.wav");
              nLastRawTime1 = getValue("rawtime",0);
              }
              }
              }
              if(ThresholdLo!=0){
              if (getValue("rawtime",0) != nLastRawTime2) {
              if(low(-1)>=ThresholdLo&&low()<ThresholdLo){
              Alert.playSound("ding.wav");
              nLastRawTime2 = getValue("rawtime",0);
              }
              }
              }

              return new Array (ThresholdHi+"",ThresholdLo+"");
              }

              Comment


              • #8
                Price Alert Script

                Thanks for all the help.

                The following script sounds an alarm an writes a label, "Price Alert", on your chart each time the closing price is above or below your defined price level. If both price levels are zero the script is essentially turned off.

                The "Label Placement" in the study properties allows you to define how far above and below the High/Low the label will be drawn. "Off Label" - how far above the High.

                "Draw Lines" option lets you draw lines at the price level or not.

                If you want the alarm to sound once use Alexis code below.

                Thanks
                Attached Files

                Comment


                • #9
                  Unzip these files into the "Sounds" folder which is in the "Esignal" folder.
                  Attached Files

                  Comment


                  • #10
                    This one lets you have the Alrm play continually or one time.

                    You will need the sound zip below and hopefully the sound zip above.
                    Attached Files

                    Comment


                    • #11
                      Unzip this file into the "Sounds" folder located within the "esignal" folder.
                      Attached Files

                      Comment


                      • #12
                        Now if you could only add this...

                        Great work on the alerts guys. Now if you could only program a quick entry box to put the highs and lows in quickly so I can get rid of this Macro Express macro I made (which does some weird stuff sometimes). It too bad Esignal has overlooked this critical feature. No offense to Esignal, but it's alert functions are amongst the most pathetic I have ever seen. A professional daytrader lives and dies by alerts in my opinion. I understand they have RavenQuote's programmer there. I am surprised he hasnt had them put in some decent alert functions.... Cmon guys!

                        Comment

                        Working...
                        X