Announcement

Collapse
No announcement yet.

Alert only 1 Time ?!

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

  • Alert only 1 Time ?!

    var study = new MAStudy(2, 2, "OHLC/4", MAStudy.EXPONENTIAL);

    function preMain() {
    setPriceStudy(true);
    }

    function main() {
    var v = study.getValue(MAStudy.MA);

    if(v == null)
    return;


    if(close() >= v) {
    Alert.email("es geht hoch", "HOCH!");
    vLastAlert = 1;
    Alert.addToList(getSymbol(), "Es geht Aufwaerts", Color.black, Color.green );
    if(!Strategy.isLong()) {
    Strategy.doLong("Aufwaerts!", Strategy.MARKET, Strategy.THISBAR);

    }

    } else {
    Alert.email("es geht runter", "RUNTER!");
    vLastAlert = 1;
    Alert.addToList(getSymbol(), "Es geht Runter", Color.white, Color.red );
    if(!Strategy.isShort()) {
    Strategy.doShort("Abwaerts!", Strategy.MARKET, Strategy.THISBAR);
    }
    }

    if(Strategy.isLong()) {
    setBarBgColor(Color.green);
    } else if(Strategy.isShort()) {
    // setBarBgColor(Color.red);
    }


    return v;
    }
    When i run this formula i get a signal every minute ... but i want the script to give signals only at changingpoints ...

    (Buy Put , Buy Call) at this time there is Call , Call , Call, Call , Put or so...

    please help

  • #2
    erilein
    Try the enclosed revision
    As an aside you may also want to try using the Formula Wizard which can greatly simplify making efs like these.
    Alex

    PHP Code:
    var study = new MAStudy(22"OHLC/4"MAStudy.EXPONENTIAL);
    var 
    vLastAlert = -1

    function preMain() {
    setPriceStudy(true);
    }

    function 
    main() {
    var 
    study.getValue(MAStudy.MA);

    if(
    == null)
    return;


    if(
    close() >= v) {
    if(
    vLastAlert!=1)Alert.email("es geht hoch""HOCH!");
    if(
    vLastAlert!=1)Alert.addToList(getSymbol(), "Es geht Aufwaerts"Color.blackColor.green );
    vLastAlert 1;
    if(!
    Strategy.isLong()) {
    Strategy.doLong("Aufwaerts!"Strategy.CLOSEStrategy.THISBAR);

    }

    } else {
    if(
    vLastAlert!=2)Alert.email("es geht runter""RUNTER!");
    if(
    vLastAlert!=2)Alert.addToList(getSymbol(), "Es geht Runter"Color.whiteColor.red );
    vLastAlert 2;
    if(!
    Strategy.isShort()) {
    Strategy.doShort("Abwaerts!"Strategy.CLOSEStrategy.THISBAR);
    }
    }

    if(
    Strategy.isLong()) {
    setBarBgColor(Color.green);
    } else if(
    Strategy.isShort()) {
    // setBarBgColor(Color.red);
    }


    return 
    v;

    Comment


    • #3
      well... i tried to do it with the formula wizzard but i got an errormessage... so i tried it in the efs editor...

      and thanks for the script i will try it as fast as possible

      Comment

      Working...
      X