Announcement

Collapse
No announcement yet.

reset/rearm sound alerts

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

  • reset/rearm sound alerts

    I need some help in resetting/rearming sound alerts other than reloading formulas Is it possible to create a reset text box? or some other way to rearm the alert once the alert situation has been dealt with from a trading or maintance standpoint?

    TIA

  • #2
    Hello stockwolf,

    You could use a text button to rearm an Alert. There's many ways to control this type of action depending on the specific logic of your formula. It sounds like you have a situation where the Alert is being triggered on every trade once your alert condition is true. If you only want the alert to be triggered the first time during the bar interval, take a look at AlertOncePerBar.efs. This example rearms the alert condition once a new bar starts and will only allow the alert to be triggered once per bar.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thanks for the reply Jason, I should have provided a bit more information. The problem that I am having is the alarm is sounding on every tick, I have included here the portion of code which paints chart bars the same color throughout the entire cycle of a BUY or a SELL, and this is also where I am attempting to have the sound alert called from. Perhaps the sound alert needs to be called from a different location or by a different method

      else if(BAMMSValue > vSMA)
      setPriceBarColor(Color.green);
      setBarThickness(2);
      setBarFgColor(Color.green);
      Alert.playSound("C:\\Documents and Settings\\My Music\\outthere.wav");

      } else if(BAMMSValue < vSMA) {
      setPriceBarColor(Color.red);
      setBarThickness(2);
      setBarFgColor(Color.red);
      Alert.playSound("C:\\Documents and Settings\\My Music\\hello.wav");
      }

      Thanks for your help

      Comment


      • #4
        Hello stockwolf,

        You need to incorporate some global flags that only allow the alerts to trigger the first time the condition is true. The example formula I pointed out in my previous message uses this method.

        Your code would look something like below.

        PHP Code:
        else if(BAMMSValue vSMA) {
            
        setPriceBarColor(Color.green);
            
        setBarThickness(2);
            
        setBarFgColor(Color.green);
            if (
        bLong == false) {
                
        Alert.playSound("C:\\Documents and Settings\\My Music\\outthere.wav");
                
        bLong true;    // global var
                
        bShort false;  // global var
            
        }
        } else if(
        BAMMSValue vSMA) {
            
        setPriceBarColor(Color.red);
            
        setBarThickness(2);
            
        setBarFgColor(Color.red);
            if (
        bShort == false) {
                
        Alert.playSound("C:\\Documents and Settings\\My Music\\hello.wav");
                
        bShort true;
                
        bLong false;
            }

        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Thanks for the help Jason, after inputting the flags like you suggested I am getting an error which tells me that "bshort is not defined"

          Thanks again

          Comment


          • #6
            Hello stockwolf,

            You need to make them global variables by initializing them outside of main().

            PHP Code:

            var bLong false;
            var 
            bShort false;

            function 
            main() {
            ...
            ... 
            Jason K.
            Project Manager
            eSignal - an Interactive Data company

            EFS KnowledgeBase
            JavaScript for EFS Video Series
            EFS Beginner Tutorial Series
            EFS Glossary
            Custom EFS Development Policy

            New User Orientation

            Comment


            • #7
              Great and thanks Jason, that did the trick.

              Well, I'm not much of a programmer, unfortunately the gal who has helped to put my ideas into code form has MS and is not doing well. Anyway, one last question, and I really do appreciate your help, how can I get the alert to sound at the Close of the signal bar, for example, when the alert sounds now, if the bar changes from red to green and back to red then to green on the same bar, the alerts sound each time the bar changes color. (I have adjusted the inputs to cause multiple changes per bar)

              Ok
              Thanks a ton

              Comment


              • #8
                Hello stockwolf,

                You can do this two ways. The easiest thing to do is add setComputOnClose() to your preMain() function. This will force the EFS to only execute once per bar after each bar closes.

                The other option is to use getBarState() and put your code inside a check for BARSTATE_NEWBAR, which only occurs once at the open of a bar. This will essentially do the same thing as setComputeOnClose(). However, you will also need to change the conditional statements to look at the values from the previous bar. Your code would look something like below.

                PHP Code:
                if (getBarState() == BARSTATE_NEWBAR) {
                    var 
                BAMMSValue_1 BAMMSValue;  // BAMMSValue needs to be global
                    
                var vSMA_1 vSMA;  // vSMA also needs to be global
                    
                ...
                    ...
                    
                    else if(
                BAMMSValue_1 vSMA_1) {  // create _1 variables that store the previous bar's values.
                        
                setPriceBarColor(Color.green);
                        
                setBarThickness(2);
                        
                setBarFgColor(Color.green);
                        if (
                bLong == false) {
                            
                Alert.playSound("C:\Documents and Settings\My Music\outthere.wav");
                            
                bLong true;    // global var
                            
                bShort false;  // global var
                        
                }
                    } else if(
                BAMMSValue_1 vSMA_1) {
                        
                setPriceBarColor(Color.red);
                        
                setBarThickness(2);
                        
                setBarFgColor(Color.red);
                        if (
                bShort == false) {
                            
                Alert.playSound("C:\Documents and Settings\My Music\hello.wav");
                            
                bShort true;
                            
                bLong false;
                        }
                    }

                This new modification may also make the global boolean variables, bLong and bShort unnecessaray.
                Jason K.
                Project Manager
                eSignal - an Interactive Data company

                EFS KnowledgeBase
                JavaScript for EFS Video Series
                EFS Beginner Tutorial Series
                EFS Glossary
                Custom EFS Development Policy

                New User Orientation

                Comment

                Working...
                X