Announcement

Collapse
No announcement yet.

efs question?

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

  • efs question?

    How do I call the values (r1,r2,pp,s1,s2) from the pivot point efs formula for use in a custom efs i am trying to develop?

    Any help would be greatly appreciated.

    thanks,

    tom

  • #2
    Tom
    The enclosed efs uses callFunction() to call the values from PivotPointAll.efs.
    Alex

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Call Pivots");
    }

    function 
    main() {

        var 
    aPivots null;

        
    aPivots callFunction("/Pivots/PivotPointAll.efs","main");
     
        if(
    aPivots == null) return;

        var 
    r2 aPivots[0]; 
        var 
    r1 aPivots[1];
        var 
    pp aPivots[2];
        var 
    s1 aPivots[3];
        var 
    s2 aPivots[4];

        return new Array (
    r2,r1,pp,s1,s2);

    Comment


    • #3
      still having problems

      thanks, the call function works great, but i can't seem to get it to work in conjunction with my program.

      could the problem be the combination of using the call function inside the main function with the newbar_state?

      -tom

      //here's my code so far:

      var vEMA5 = new MAStudy(5,0,"Close",MAStudy.EXPONENTIAl);
      var vEMA13 = new MAStudy(13,0,"Close",MAStudy.EXPONENTIAl);

      var vLastAlert = 0;
      var vt1 = 930;
      var vt2 = 1555;

      var vPosition = null;
      var vLastPosition = null;

      function preMain () {
      setPriceStudy(true);
      setStudyTitle("Fire Fox Pro");
      setShowCursorLabel(true);
      }

      function main() {

      var aPivots = null;

      aPivots = callFunction("/Pivots/PivotPointAll.efs","main");

      if(aPivots == null) return;

      var vR2 = aPivots[0];
      var vR1 = aPivots[1];
      var vPP = aPivots[2];
      var vS1 = aPivots[3];
      var vS2 = aPivots[4];

      return new Array (vR2,vR1,vPP,vS1,vS2);

      var vState = getBarState();

      if(vState == BARSTATE_NEWBAR){
      vLastPosition = vPosition;
      }

      var vLong = vEMA5.getValue(MAStudy.MA) > vEMA13.getValue(MAStudy.MA) && vEMA5.getValue(MAStudy.MA) >= vPP &&
      close() <= vPP + 0.1 && vt1 <= (getHour()*100)+getMinute() <= vt2 && close() > open();
      var vShort = vEMA5.getValue(MAStudy.MA) < vEMA13.getValue(MAStudy.MA) && vEMA5.getValue(MAStudy.MA) <= vPP &&
      close() >= vPP -0.1 && vt1 <= (getHour()*100)+getMinute() <= vt2 && close() > open();

      var vSell = vPosition == "long" && ((vEMA5.getValue(MAStudy.MA) < vEMA13.getValue(MAStudy.MA)) || (close() < vPP - 0.1))
      var vCover = vPosition == "short" && ((vEMA5.getValue(MAStudy.MA) > vEMA13.getValue(MAStudy.MA)) || (close() > vPP + 0.1))

      //Entry Long
      if(vLong == true && vLastPosition != "long") onAction1();

      //Entry Short
      if(vShort == true && vLastPosition != "short") onAction2();

      //Exit Long
      if(vSell == true && vPosition == "long") onAction3();

      //Exit Short
      if(vCover == true && vPosition == "short") onAction4();

      //Close Time
      if(vPosition == "long" && (getHour(-1)*100) >= vt2) {
      onAction3();
      } else if (vPosition == "short" && (getHour(-1)*100) >= vt2) {
      onAction4();
      }

      //NEWBAR ALERTS
      if (vState == BARSTATE_NEWBAR) {
      if (vLong == true && (getHour(-1)*100)+getMinute(-1) > vt1) {
      Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Warning.wav");
      Alert.addToList(getSymbol(), "Buy Signal", Color.RGB(0,0,0), Color.RGB(0,255,0));
      } else if (vShort == true && (getHour(-1)*100)+getMinute(-1) > vt1) {
      Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Train.wav");
      Alert.addToList(getSymbol(), "Sell Signal", Color.RGB(0,0,0), Color.RGB(195,0,0));
      } else {
      Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
      Alert.addToList(getSymbol(), "Exit Signal", Color.RGB(0,0,0), Color.RGB(195,0,0));
      }
      }


      //background colors
      if (vLong == true) {
      setBarBgColor(Color.RGB(233,255,233));
      } else if (vShort == true) {
      setBarBgColor(Color.RGB(255,233,233));
      } else {
      setBarBgColor(Color.RGB(192,192,192));
      }

      return;
      }

      //{{Action_1
      function onAction1() {
      if (getCurrentBarIndex() != 0) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      vPosition = "long";
      }


      //{{Action_2
      function onAction2() {
      if (getCurrentBarIndex() != 0) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      vPosition = "short";
      }


      //{{Action_3_EXIT_LONG
      function onAction3() {
      if (getCurrentBarIndex() != 0) Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      vPosition = null;
      }


      //{{Action_4_EXIT_SHORT
      function onAction4() {
      if (getCurrentBarIndex() != 0) Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      vPosition = null;
      }
      Last edited by XLYTH; 08-03-2004, 04:38 PM.

      Comment


      • #4
        Tom
        In transferring my script into yours you also copied return new Array (vR2,vR1,vPP,vS1,vS2); which should not be there.
        Also if you are only using vPP in your efs then you can comment out (or delete) the other variables (ie vR1, vS1, etc).
        Anyhow to verify if you are retrieving vPP insert a debugPrintln(vPP); where appropriate and check the Formula Output Window.
        Alex

        Originally posted by XLYTH
        thanks, the call function works great, but i can't seem to get it to work in conjunction with my program.

        could the problem be the combination of using the call function inside the main function with the newbar_state?

        -tom

        //here's my code so far:

        var vEMA5 = new MAStudy(5,0,"Close",MAStudy.EXPONENTIAl);
        var vEMA13 = new MAStudy(13,0,"Close",MAStudy.EXPONENTIAl);

        var vLastAlert = 0;
        var vt1 = 930;
        var vt2 = 1555;

        var vPosition = null;
        var vLastPosition = null;

        function preMain () {
        setPriceStudy(true);
        setStudyTitle("Fire Fox Pro");
        setShowCursorLabel(true);
        }

        function main() {

        var aPivots = null;

        aPivots = callFunction("/Pivots/PivotPointAll.efs","main");

        if(aPivots == null) return;

        var vR2 = aPivots[0];
        var vR1 = aPivots[1];
        var vPP = aPivots[2];
        var vS1 = aPivots[3];
        var vS2 = aPivots[4];

        return new Array (vR2,vR1,vPP,vS1,vS2);

        var vState = getBarState();

        if(vState == BARSTATE_NEWBAR){
        vLastPosition = vPosition;
        }

        var vLong = vEMA5.getValue(MAStudy.MA) > vEMA13.getValue(MAStudy.MA) && vEMA5.getValue(MAStudy.MA) >= vPP &&
        close() <= vPP + 0.1 && vt1 <= (getHour()*100)+getMinute() <= vt2 && close() > open();
        var vShort = vEMA5.getValue(MAStudy.MA) < vEMA13.getValue(MAStudy.MA) && vEMA5.getValue(MAStudy.MA) <= vPP &&
        close() >= vPP -0.1 && vt1 <= (getHour()*100)+getMinute() <= vt2 && close() > open();

        var vSell = vPosition == "long" && ((vEMA5.getValue(MAStudy.MA) < vEMA13.getValue(MAStudy.MA)) || (close() < vPP - 0.1))
        var vCover = vPosition == "short" && ((vEMA5.getValue(MAStudy.MA) > vEMA13.getValue(MAStudy.MA)) || (close() > vPP + 0.1))

        //Entry Long
        if(vLong == true && vLastPosition != "long") onAction1();

        //Entry Short
        if(vShort == true && vLastPosition != "short") onAction2();

        //Exit Long
        if(vSell == true && vPosition == "long") onAction3();

        //Exit Short
        if(vCover == true && vPosition == "short") onAction4();

        //Close Time
        if(vPosition == "long" && (getHour(-1)*100) >= vt2) {
        onAction3();
        } else if (vPosition == "short" && (getHour(-1)*100) >= vt2) {
        onAction4();
        }

        //NEWBAR ALERTS
        if (vState == BARSTATE_NEWBAR) {
        if (vLong == true && (getHour(-1)*100)+getMinute(-1) > vt1) {
        Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Warning.wav");
        Alert.addToList(getSymbol(), "Buy Signal", Color.RGB(0,0,0), Color.RGB(0,255,0));
        } else if (vShort == true && (getHour(-1)*100)+getMinute(-1) > vt1) {
        Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Train.wav");
        Alert.addToList(getSymbol(), "Sell Signal", Color.RGB(0,0,0), Color.RGB(195,0,0));
        } else {
        Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
        Alert.addToList(getSymbol(), "Exit Signal", Color.RGB(0,0,0), Color.RGB(195,0,0));
        }
        }


        //background colors
        if (vLong == true) {
        setBarBgColor(Color.RGB(233,255,233));
        } else if (vShort == true) {
        setBarBgColor(Color.RGB(255,233,233));
        } else {
        setBarBgColor(Color.RGB(192,192,192));
        }

        return;
        }

        //{{Action_1
        function onAction1() {
        if (getCurrentBarIndex() != 0) Strategy.doLong("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
        vPosition = "long";
        }


        //{{Action_2
        function onAction2() {
        if (getCurrentBarIndex() != 0) Strategy.doShort("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
        vPosition = "short";
        }


        //{{Action_3_EXIT_LONG
        function onAction3() {
        if (getCurrentBarIndex() != 0) Strategy.doSell("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
        vPosition = null;
        }


        //{{Action_4_EXIT_SHORT
        function onAction4() {
        if (getCurrentBarIndex() != 0) Strategy.doCover("", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
        vPosition = null;
        }

        Comment


        • #5
          Dear Alex,

          Can you take a look at the attached efs script and see what is wrong? It is a simple Turn bar script that paints the bar when 3 conditions are met:

          1. Low is lower than previous low
          2. Close is above open
          3. Close is above midpoint.

          It seems to be having trouble with the 3rd parameter...

          Thanks so much

          Veda
          Attached Files

          Comment


          • #6
            Veda
            Midpoint is (high+low)/2 not (high-low)/2 as is instead written in the efs.
            Also an && is missing in the second conditional statement.
            Alex

            Comment


            • #7
              Hi Alex,

              I have made the correction you suggest but the script gets an error message on syntax. Could you get it to work?

              Thanks

              Veda

              Comment


              • #8
                Alex,

                Ignore last pots - didn't see your comment about && missing. Works fine now

                Thanks so much

                Veda

                Comment

                Working...
                X