Announcement

Collapse
No announcement yet.

alert.email

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

  • alert.email

    I have esignal set up to email alerts. When I click on view, alerts and set one up, it will successfully send me an email, but when i code an efs file to send me an email via alert.email("message here") the email never gets sent. I know the smtp server and all the settings are correct since i can recieve the alert email when i manually set it up. Can someone help?

  • #2
    Re: alert.email

    jarrodb
    Not sure if yours was a typo or not but the function is actually Alert.email() and not alert.email().
    Note that Javascript (which is at the foundation of EFS) is a case sensitive language.
    If that is not the issue then the reasons could be several and you will need to post your code - or a complete example that illustrates the issue - for someone to be able to determine what the problem may be and to provide a solution
    Alex


    Originally posted by jarrodb
    I have esignal set up to email alerts. When I click on view, alerts and set one up, it will successfully send me an email, but when i code an efs file to send me an email via alert.email("message here") the email never gets sent. I know the smtp server and all the settings are correct since i can recieve the alert email when i manually set it up. Can someone help?

    Comment


    • #3
      Alert.email()

      I did use Alert.email(). That was a typo in my post. I just added a few lines of code below to the previousDaysDailyBars.efs that would test sending an Alert.email(). It doesn't send the email, but when I manually enter an alert the email gets sent Any ideas?



      /************************************************** ****************************************
      Copyright © eSignal, a division of Interactive Data Corporation. 2005. All rights reserved.
      This sample eSignal Formula Script (EFS) may be modified and saved under a new filename;
      however, eSignal is no longer responsible for the functionality once modified.
      eSignal reserves the right to modify and overwrite this EFS file with each new release.
      @version 3.0 by Alexis Montenegro for eSignal
      ************************************************** *****************************************/

      function preMain() {
      setPriceStudy(true);
      setStudyTitle("PreviousDayDailyBars");
      setCursorLabelName("PD-O", 0); // Open
      setCursorLabelName("PD-H", 1); // High
      setCursorLabelName("PD-L", 2); // Low
      setCursorLabelName("PD-C", 3); // Close

      setDefaultBarStyle(PS_SOLID, 0); // Open
      setDefaultBarStyle(PS_SOLID, 1); // High
      setDefaultBarStyle(PS_SOLID, 2); // Low
      setDefaultBarStyle(PS_SOLID, 3); // Close

      setDefaultBarFgColor(Color.red, 0); // Open
      setDefaultBarFgColor(Color.black, 1); // High
      setDefaultBarFgColor(Color.black, 2); // Low
      setDefaultBarFgColor(Color.blue, 3); // Close

      setDefaultBarThickness(2, 0); // Open
      setDefaultBarThickness(4, 1); // High
      setDefaultBarThickness(4, 2); // Low
      setDefaultBarThickness(2, 3); // Close

      setPlotType(PLOTTYPE_FLATLINES, 0); // Open
      setPlotType(PLOTTYPE_FLATLINES, 1); // High
      setPlotType(PLOTTYPE_FLATLINES, 2); // Low
      setPlotType(PLOTTYPE_FLATLINES, 3); // Close
      }

      var bInit = false;
      var xOpen = null;
      var xHigh = null;
      var xLow = null;
      var xClose = null;
      var currentPrice = null;
      var alertTriggered = false;
      function main() {

      if(isMonthly() || isWeekly() || isDaily())
      return;

      if(bInit == false){
      xOpen = open(inv("D"));
      xHigh = high(inv("D"));
      xLow = low(inv("D"));
      xClose = close(inv("D"));
      bInit = true;
      }

      var vOpen = xOpen.getValue(-1);
      var vHigh = xHigh.getValue(-1);
      var vLow = xLow.getValue(-1);
      var vClose = xClose.getValue(-1);
      if(vOpen == null || vHigh == null || vLow == null || vClose == null)
      return;

      /*JUST ADDED CODE BELOW TO TEST IF IT WOULD SEND EMAIL*/
      currentPrice = getMostRecentTrade();
      if (alertTriggered == false)
      {
      debugPrint(currentPrice);
      Alert.email(currentPrice);
      alertTriggered = true;
      }

      return new Array (vOpen,vHigh,vLow,vClose);
      }

      Comment


      • #4
        Re: Alert.email()

        jarrodb
        Alerts are executed only on the current bar (so as to avoid a slew of alerts being triggered on each historical bar as the script loads in a chart). In your code the variable alertTriggered is set to true on the first execution of the script which happens on the first bar as the script loads in the chart hence the condition is no longer evaluated by the time it reaches the current bar. To verify this just add a getCurrentBarIndex() to the debug statement eg
        PHP Code:
        if (alertTriggered == false)
        {
           
        debugPrint(currentPrice);
           
        Alert.email(getCurrentBarIndex()+"  "+currentPrice);
           
        alertTriggered true;

        and you will see that the bar index being returned is the one of the first bar on the chart. To resolve this add a condition to your statement that checks that the bar being processed is the current bar eg
        PHP Code:
        if (alertTriggered == false && getCurrentBarIndex() == 0)
        {
           
        debugPrint(currentPrice);
           
        Alert.email(getCurrentBarIndex()+"  "+currentPrice);
           
        alertTriggered true;

        and the email alert should work
        Hope this helps
        Alex


        Originally posted by jarrodb
        I did use Alert.email(). That was a typo in my post. I just added a few lines of code below to the previousDaysDailyBars.efs that would test sending an Alert.email(). It doesn't send the email, but when I manually enter an alert the email gets sent Any ideas?



        /************************************************** ****************************************
        Copyright © eSignal, a division of Interactive Data Corporation. 2005. All rights reserved.
        This sample eSignal Formula Script (EFS) may be modified and saved under a new filename;
        however, eSignal is no longer responsible for the functionality once modified.
        eSignal reserves the right to modify and overwrite this EFS file with each new release.
        @version 3.0 by Alexis Montenegro for eSignal
        ************************************************** *****************************************/

        function preMain() {
        setPriceStudy(true);
        setStudyTitle("PreviousDayDailyBars");
        setCursorLabelName("PD-O", 0); // Open
        setCursorLabelName("PD-H", 1); // High
        setCursorLabelName("PD-L", 2); // Low
        setCursorLabelName("PD-C", 3); // Close

        setDefaultBarStyle(PS_SOLID, 0); // Open
        setDefaultBarStyle(PS_SOLID, 1); // High
        setDefaultBarStyle(PS_SOLID, 2); // Low
        setDefaultBarStyle(PS_SOLID, 3); // Close

        setDefaultBarFgColor(Color.red, 0); // Open
        setDefaultBarFgColor(Color.black, 1); // High
        setDefaultBarFgColor(Color.black, 2); // Low
        setDefaultBarFgColor(Color.blue, 3); // Close

        setDefaultBarThickness(2, 0); // Open
        setDefaultBarThickness(4, 1); // High
        setDefaultBarThickness(4, 2); // Low
        setDefaultBarThickness(2, 3); // Close

        setPlotType(PLOTTYPE_FLATLINES, 0); // Open
        setPlotType(PLOTTYPE_FLATLINES, 1); // High
        setPlotType(PLOTTYPE_FLATLINES, 2); // Low
        setPlotType(PLOTTYPE_FLATLINES, 3); // Close
        }

        var bInit = false;
        var xOpen = null;
        var xHigh = null;
        var xLow = null;
        var xClose = null;
        var currentPrice = null;
        var alertTriggered = false;
        function main() {

        if(isMonthly() || isWeekly() || isDaily())
        return;

        if(bInit == false){
        xOpen = open(inv("D"));
        xHigh = high(inv("D"));
        xLow = low(inv("D"));
        xClose = close(inv("D"));
        bInit = true;
        }

        var vOpen = xOpen.getValue(-1);
        var vHigh = xHigh.getValue(-1);
        var vLow = xLow.getValue(-1);
        var vClose = xClose.getValue(-1);
        if(vOpen == null || vHigh == null || vLow == null || vClose == null)
        return;

        /*JUST ADDED CODE BELOW TO TEST IF IT WOULD SEND EMAIL*/
        currentPrice = getMostRecentTrade();
        if (alertTriggered == false)
        {
        debugPrint(currentPrice);
        Alert.email(currentPrice);
        alertTriggered = true;
        }

        return new Array (vOpen,vHigh,vLow,vClose);
        }

        Comment


        • #5
          Thanks alex. One more question. Does it reload this code everytime a new bar is printed? I have the alertTriggered variable that is set to true once alert goes off because i don't want to receive more than one alert. This forces me to reload the EFS to restart the alert process. Once i set alertTriggered to true, will it stay true once a new bar is printed? If so, how would i get it to keep the value of alertTrigggered?

          Comment


          • #6
            jarrodb
            Yoiu can reset the alertTriggered flag back to false at every new bar by adding the following code at the beginning of the main function
            PHP Code:
            if(getBarState()==BARSTATE_NEWBAR){
                
            alertTriggered false;

            This way the flag gets reset [without the need to reload the script] and if the condition evaluates to true it will trigger the alert once only on that bar
            Alex


            Originally posted by jarrodb
            Thanks alex. One more question. Does it reload this code everytime a new bar is printed? I have the alertTriggered variable that is set to true once alert goes off because i don't want to receive more than one alert. This forces me to reload the EFS to restart the alert process. Once i set alertTriggered to true, will it stay true once a new bar is printed? If so, how would i get it to keep the value of alertTrigggered?

            Comment


            • #7
              The probelm with that is that if that the same alert will be triggered every bar if the condition is met. I want the alert to trigger once and then require me to reload the script or do "something" to reset it other wise i will keep getting alerts for the same condition each time a new bar prints. any ideas?? Is there a way to make that variable a global?

              Comment


              • #8
                jarrodb
                The alertTriggered variable is already a global variable as it is declared outside of the main function.
                There are several ways to accomplish what you want. One way would be to define a condition that evaluates to true only on the first bar and not on the subsequent bars. For example
                if(current_AvgA > current_AvgB && previous_AvgA < previous_AvgB
                is true only on the first bar in which average A is above average B whereas
                if(current_AvgA > current_AvgB)
                is true on every bar in which average A is above average B.
                Another way would be to reset the alertTriggered variable to false only when the condition is no longer true or when some other condition occurs
                If you run a search through this forum you will find many scripts and/or code examples that trigger alerts based on a variety of conditions.
                Alex


                Originally posted by jarrodb
                The probelm with that is that if that the same alert will be triggered every bar if the condition is met. I want the alert to trigger once and then require me to reload the script or do "something" to reset it other wise i will keep getting alerts for the same condition each time a new bar prints. any ideas?? Is there a way to make that variable a global?

                Comment

                Working...
                X