Announcement

Collapse
No announcement yet.

Alerts!

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

  • Alerts!

    Hi,

    The code here give an alert when the market is open but it the alert continue to pop on each tick.

    Any suggestion that let the alert trigger only one time would be very much apprecaited.

    Thank you,
    Safa


    function preMain(){
    setPriceStudy(true);
    setStudyTitle("marketisopen");
    setShowCursorLabel(false);
    }

    function main(){
    if (getBarState() == BARSTATE_NEWBAR) {

    BarHr = getHour();
    BarMin = getMinute();
    cBarTimeInt =BarHr*100+BarMin*1;

    if( cBarTimeInt ==830 ) {
    Alert.addToList(getSymbol(), "Market is now open!", Color.lime, Color.black );
    }

    return null
    }
    }

  • #2
    Here is a minor revision to your code..

    function preMain(){
    setPriceStudy(true);
    setStudyTitle("marketisopen");
    setShowCursorLabel(false);
    }

    var AlertTriggered = false;

    function main(){
    if (getBarState() == BARSTATE_NEWBAR) {

    BarHr = getHour();
    BarMin = getMinute();
    cBarTimeInt = (BarHr*100)+BarMin;

    if ((cBarTimeInt ==630) && (AlertTriggered == false)) {
    AlertTriggered = false;
    }

    if ((cBarTimeInt ==830) && (AlertTriggered == false)) {
    Alert.addToList(getSymbol(), "Market is now open!", Color.lime, Color.black );
    AlertTriggered = true;
    }

    return null
    }
    }
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      minor correction...

      function preMain(){
      setPriceStudy(true);
      setStudyTitle("marketisopen");
      setShowCursorLabel(false);
      }

      var AlertTriggered = false;

      function main(){
      if (getBarState() == BARSTATE_NEWBAR) {

      BarHr = getHour();
      BarMin = getMinute();
      cBarTimeInt = (BarHr*100)+BarMin;

      if ((cBarTimeInt ==630) && (AlertTriggered == true)) {
      AlertTriggered = false;
      }

      if ((cBarTimeInt ==830) && (AlertTriggered == false)) {
      Alert.addToList(getSymbol(), "Market is now open!", Color.lime, Color.black );
      AlertTriggered = true;
      }

      return null
      }
      }
      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Brad:

        Thank you for the modification of this code.

        Safa

        Comment

        Working...
        X