Announcement

Collapse
No announcement yet.

creating a pop up alert

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

  • creating a pop up alert

    I am trying to create a pop up alert when certain criteria are met. My code is not working and I wonder if you can look at or recommend some code that does work.

    How do I send you code to look at?

    newbee

    TAG

  • #2
    Alert test code

    Here is the code I am trying to develop to pop up a window. What am I missing? Am I on the right track here?

    var versionString = "1.00";
    /****
    * Alert Test v1.00 ATT 1.00.efs
    */
    var barNum = 0;
    var alertCount = 0;

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Alert Test ver " + versionString);
    }

    // Main
    function main() {
    barNum = getCurrentBarCount();
    if (barNum < 20 || alertCount > 3) return;
    if (sma(6) > sma(14)) {
    line = "Test Alert \n";
    line += "\ t SMA(6): " + sma(6) + "\n";
    line += "\t SMA(14): " + sma(14) + "\n";
    line += "\t BarNum: " + barNum;
    Alert.addToList( getSymbol(), line, Color.black, Color.white);
    debugPrintln("\n---\n" + line);
    alertCount++;
    }
    }

    Comment


    • #3
      TAG
      The reason you are not getting any popup alerts on historical bars [while the script is loading] is because the Alert.xxx functions execute only on bar index 0 (or bar index -1 when setComputeOnClose() is used)
      Alex

      Comment

      Working...
      X