Announcement

Collapse
No announcement yet.

EFS for Alert with inv()

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

  • EFS for Alert with inv()

    I try to make an efs for an alert when a MA crosses the price but with interval inv(). This is what I wrote but when I put the interval on then the application crashes.
    ----------
    PHP Code:
    var vEMA34;
    var 
    vLastAlert = -1;

    function 
    preMain() {
      
        
    setPriceStudy(true);
        
    setStudyTitle("");
        
    setCursorLabelName("?"0);
        
    setDefaultBarStyle(PS_SOLID0);
        
    setDefaultBarFgColor(Color.red0);
        
    setDefaultBarThickness(10);
        
    setPlotType(PLOTTYPE_LINE0);
      
       
    }

    function 
    main() {
    vEMA34 = new MAStudy(340"Close"MAStudy.EXPONENTIALinv(1));  

    if (
    close() > vEMA34.getValue(MAStudy.MA))
        
         
    onAction1()
        else if (
    close() < vEMA34.getValue(MAStudy.MA))
         
    onAction2();
        return 
    vEMA34.getValue(MAStudy.MA);
    }

    function 
    postMain() {
    }

        function 
    onAction1() {
            if (
    vLastAlert != 1Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Alarm.wav");
            if (
    vLastAlert != 1Alert.addToList(getSymbol(), "34EMA-Cross UP"Color.blackColor.green);
            
    vLastAlert 1;
        }
       
        function 
    onAction2() {
            if (
    vLastAlert != 2Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Alarm.wav");
            if (
    vLastAlert != 2Alert.addToList(getSymbol(), "34EMA-Cross Down"Color.redColor.red);
            
    vLastAlert 2;
        } 
    .................
    I have the latest esignal 7.9.1.
    Any Ideas
    Elias

  • #2
    Elias
    That is happening because you are using inv() which is an EFS2 function with an EFS1 study. Replace
    vEMA34 = new MAStudy(34, 0, "Close", MAStudy.EXPONENTIAL, inv(1));
    with
    vEMA34 = ema(34,close(inv(1)));
    Also replace every instance of vEMA34.getValue(MAStudy.MA); with vEMA34.getValue(0);
    For information on all the EFS2 functions and their syntax refer to the EFS2 Function Reference in the
    EFS KnowledgeBase
    Alex

    Comment


    • #3
      IT WOrks fine thanks alot Alexis.



      Elias

      Comment

      Working...
      X