Announcement

Collapse
No announcement yet.

Help with a MA Cross and EFS not plotting

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

  • Help with a MA Cross and EFS not plotting

    Hello, I have a problem with my EFS script not plotting and coloring in the background like I am trying to have it done. I followed the example that ljd888 last posted on the thread http://forum.esignalcentral.com/show...threadid=15727 but I still have no plots or for "B" or "S" when there is a MA cross over. I don't know what I'm missing here, but could someone please help?

    Currently nothing is printing in the Advanced Chart window

    Here is my EFS script that I made with the Wizard.


    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
    var vVWMA20 = new MAStudy(20, 0, "Close", MAStudy.VOLUMEWEIGHTED);
    var vSMA50 = new MAStudy(50, 0, "Close", MAStudy.SIMPLE);
    var vLastAlert = -1;
    //}}EFSWizard_Declarations


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(true);
    setStudyTitle("8MA/20MA Cross with Backround Paint - WIZARD");
    //}}EFSWizard_PreMain

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if (
    vSMA50.getValue(MAStudy.MA, -1) == null
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    Strategy.isLong() == false &&
    vEMA8.getValue(MAStudy.MA -1) < vSMA50.getValue(MAStudy.MA, -1) &&
    vEMA8.getValue(MAStudy.MA) > vSMA50.getValue(MAStudy.MA)
    ) onAction2()
    //}}EFSWizard_Expression_2

    //{{EFSWizard_Expression_3
    else if (
    Strategy.isShort() == false &&
    vEMA8.getValue(MAStudy.MA -1) > vSMA50.getValue(MAStudy.MA, -1) &&
    vEMA8.getValue(MAStudy.MA) < vSMA50.getValue(MAStudy.MA)
    ) onAction3();
    //}}EFSWizard_Expression_3

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return null;
    //}}EFSWizard_Return

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    if (vLastAlert != 2) drawTextRelative(0, BelowBar1, "B", Color.RGB(0,0,255), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 14);
    if (vLastAlert != 2) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
    Strategy.doLong("LONG", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    setBarBgColor(Color.RGB(0,255,0));
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //{{EFSWizard_Action_3
    function onAction3() {
    Strategy.doShort("SHORT", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    setBarBgColor(Color.RGB(255,0,0));
    if (vLastAlert != 3) drawTextRelative(0, AboveBar1, "S", Color.RGB(255,0,0), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 14);
    vLastAlert = 3;
    }
    //}}EFSWizard_Action_3

    //}}EFSWizard_Actions

  • #2
    Re: Help with a MA Cross and EFS not plotting

    DBBLI
    You are missing a comma in both instances of vEMA8.getValue(MAStudy.MA -1)
    which should be vEMA8.getValue(MAStudy.MA, -1)
    Once you add the comma the script should work
    Alex


    Originally posted by DBBLI
    Hello, I have a problem with my EFS script not plotting and coloring in the background like I am trying to have it done. I followed the example that ljd888 last posted on the thread http://forum.esignalcentral.com/show...threadid=15727 but I still have no plots or for "B" or "S" when there is a MA cross over. I don't know what I'm missing here, but could someone please help?

    Currently nothing is printing in the Advanced Chart window

    Here is my EFS script that I made with the Wizard.


    //{{EFSWizard_Description
    //
    // This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
    var vVWMA20 = new MAStudy(20, 0, "Close", MAStudy.VOLUMEWEIGHTED);
    var vSMA50 = new MAStudy(50, 0, "Close", MAStudy.SIMPLE);
    var vLastAlert = -1;
    //}}EFSWizard_Declarations


    function preMain() {
    /**
    * This function is called only once, before any of the bars are loaded.
    * Place any study or EFS configuration commands here.
    */
    //{{EFSWizard_PreMain
    setPriceStudy(true);
    setStudyTitle("8MA/20MA Cross with Backround Paint - WIZARD");
    //}}EFSWizard_PreMain

    }

    function main() {
    /**
    * The main() function is called once per bar on all previous bars, once per
    * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
    * in your preMain(), it is also called on every tick.
    */

    //{{EFSWizard_Expressions
    //{{EFSWizard_Expression_1
    if (
    vSMA50.getValue(MAStudy.MA, -1) == null
    ) onAction1()
    //}}EFSWizard_Expression_1

    //{{EFSWizard_Expression_2
    else if (
    Strategy.isLong() == false &&
    vEMA8.getValue(MAStudy.MA -1) < vSMA50.getValue(MAStudy.MA, -1) &&
    vEMA8.getValue(MAStudy.MA) > vSMA50.getValue(MAStudy.MA)
    ) onAction2()
    //}}EFSWizard_Expression_2

    //{{EFSWizard_Expression_3
    else if (
    Strategy.isShort() == false &&
    vEMA8.getValue(MAStudy.MA -1) > vSMA50.getValue(MAStudy.MA, -1) &&
    vEMA8.getValue(MAStudy.MA) < vSMA50.getValue(MAStudy.MA)
    ) onAction3();
    //}}EFSWizard_Expression_3

    //}}EFSWizard_Expressions


    //{{EFSWizard_Return
    return null;
    //}}EFSWizard_Return

    }

    function postMain() {
    /**
    * The postMain() function is called only once, when the EFS is no longer used for
    * the current symbol (ie, symbol change, chart closing, or application shutdown).
    */
    }

    //{{EFSWizard_Actions
    //{{EFSWizard_Action_1
    function onAction1() {
    vLastAlert = 1;
    }
    //}}EFSWizard_Action_1

    //{{EFSWizard_Action_2
    function onAction2() {
    if (vLastAlert != 2) drawTextRelative(0, BelowBar1, "B", Color.RGB(0,0,255), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 14);
    if (vLastAlert != 2) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
    Strategy.doLong("LONG", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    setBarBgColor(Color.RGB(0,255,0));
    vLastAlert = 2;
    }
    //}}EFSWizard_Action_2

    //{{EFSWizard_Action_3
    function onAction3() {
    Strategy.doShort("SHORT", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
    setBarBgColor(Color.RGB(255,0,0));
    if (vLastAlert != 3) drawTextRelative(0, AboveBar1, "S", Color.RGB(255,0,0), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 14);
    vLastAlert = 3;
    }
    //}}EFSWizard_Action_3

    //}}EFSWizard_Actions

    Comment


    • #3
      Re: Re: Help with a MA Cross and EFS not plotting

      Thank you so much Alex! That was it!

      Originally posted by Alexis C. Montenegro
      DBBLI
      You are missing a comma in both instances of vEMA8.getValue(MAStudy.MA -1)
      which should be vEMA8.getValue(MAStudy.MA, -1)
      Once you add the comma the script should work
      Alex

      Although, now I seem to be having issues with the background color. The background color keeps only coloring 1 bar not coloring all the bars until a different signal, ex "S" or "B" is triggered. Currently, here is what I have now:

      //{{EFSWizard_Description
      //
      // This formula was generated by the Alert Wizard
      //
      //}}EFSWizard_Description


      //{{EFSWizard_Declarations
      var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
      var vVWMA20 = new MAStudy(20, 0, "Close", MAStudy.VOLUMEWEIGHTED);
      var vSMA50 = new MAStudy(50, 0, "Close", MAStudy.SIMPLE);
      var vLastAlert = -1;
      //}}EFSWizard_Declarations


      function preMain() {
      /**
      * This function is called only once, before any of the bars are loaded.
      * Place any study or EFS configuration commands here.
      */
      //{{EFSWizard_PreMain
      setPriceStudy(true);
      setStudyTitle("8MA/20MA Cross with Backround Paint - WIZARD");
      setCursorLabelName("HIGH", 0);
      setCursorLabelName("LOW", 1);
      setDefaultBarStyle(PS_SOLID, 0);
      setDefaultBarStyle(PS_SOLID, 1);
      setDefaultBarFgColor(Color.black, 0);
      setDefaultBarFgColor(Color.black, 1);
      setDefaultBarThickness(3, 0);
      setDefaultBarThickness(3, 1);
      setPlotType(PLOTTYPE_LINE, 0);
      setPlotType(PLOTTYPE_LINE, 1);
      //}}EFSWizard_PreMain

      }

      function main() {
      /**
      * The main() function is called once per bar on all previous bars, once per
      * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
      * in your preMain(), it is also called on every tick.
      */

      //{{EFSWizard_Expressions
      //{{EFSWizard_Expression_1
      if (
      vSMA50.getValue(MAStudy.MA, -1) == null
      ) onAction1()
      //}}EFSWizard_Expression_1

      //{{EFSWizard_Expression_2
      else if (
      Strategy.isLong() == false &&
      vEMA8.getValue(MAStudy.MA, -1) < vSMA50.getValue(MAStudy.MA, -1) &&
      vEMA8.getValue(MAStudy.MA) > vSMA50.getValue(MAStudy.MA)
      ) onAction2()
      //}}EFSWizard_Expression_2

      //{{EFSWizard_Expression_3
      else if (
      Strategy.isShort() == false &&
      vEMA8.getValue(MAStudy.MA, -1) > vSMA50.getValue(MAStudy.MA, -1) &&
      vEMA8.getValue(MAStudy.MA) < vSMA50.getValue(MAStudy.MA)
      ) onAction3()
      //}}EFSWizard_Expression_3

      //{{EFSWizard_Expression_4
      else if (
      Strategy.isLong() == true &&
      vEMA8.getValue(MAStudy.MA) > vVWMA20.getValue(MAStudy.MA)
      ) onAction4()
      //}}EFSWizard_Expression_4

      //{{EFSWizard_Expression_5
      else if (
      Strategy.isShort() == true &&
      vEMA8.getValue(MAStudy.MA) < vVWMA20.getValue(MAStudy.MA)
      ) onAction5();
      //}}EFSWizard_Expression_5

      //}}EFSWizard_Expressions


      //{{EFSWizard_Return
      return new Array(
      high(),
      low()
      );
      //}}EFSWizard_Return

      }

      function postMain() {
      /**
      * The postMain() function is called only once, when the EFS is no longer used for
      * the current symbol (ie, symbol change, chart closing, or application shutdown).
      */
      }

      //{{EFSWizard_Actions
      //{{EFSWizard_Action_1
      function onAction1() {
      vLastAlert = 1;
      }
      //}}EFSWizard_Action_1

      //{{EFSWizard_Action_2
      function onAction2() {
      if (vLastAlert != 2) drawTextRelative(0, BelowBar1, "B", Color.RGB(0,0,255), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 14);
      if (vLastAlert != 2) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
      Strategy.doLong("LONG", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      setBarBgColor(Color.RGB(0,192,36));
      vLastAlert = 2;
      }
      //}}EFSWizard_Action_2

      //{{EFSWizard_Action_3
      function onAction3() {
      Strategy.doShort("SHORT", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
      if (vLastAlert != 3) drawTextRelative(0, AboveBar1, "S", Color.RGB(255,0,0), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 14);
      if (vLastAlert != 3) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\hoot1.wav");
      setBarBgColor(Color.RGB(255,0,0));
      vLastAlert = 3;
      }
      //}}EFSWizard_Action_3

      //{{EFSWizard_Action_4
      function onAction4() {
      if (vLastAlert != 4) drawTextRelative(0, AboveBar1, "TP", Color.RGB(0,128,18), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 11);
      vLastAlert = 4;
      }
      //}}EFSWizard_Action_4

      //{{EFSWizard_Action_5
      function onAction5() {
      if (vLastAlert != 5) drawTextRelative(0, AboveBar1, "TP", Color.RGB(255,0,0), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 11);
      vLastAlert = 5;
      }
      //}}EFSWizard_Action_5

      //}}EFSWizard_Actions

      Comment


      • #4
        Re: Re: Re: Help with a MA Cross and EFS not plotting

        DBBLI
        The reason the background color is applied only to one bar is because your conditions are set to identify the crossover point which occurs only on one bar [specifically the first one]
        If you want to color all the bars when one average is above or below the other [or alternatively when the strategy is long or short] then you need to add further conditions to check for those states which in turn apply the background color to all the other bars
        Alex


        Originally posted by DBBLI
        Thank you so much Alex! That was it!




        Although, now I seem to be having issues with the background color. The background color keeps only coloring 1 bar not coloring all the bars until a different signal, ex "S" or "B" is triggered. Currently, here is what I have now:

        //{{EFSWizard_Description
        //
        // This formula was generated by the Alert Wizard
        //
        //}}EFSWizard_Description


        //{{EFSWizard_Declarations
        var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
        var vVWMA20 = new MAStudy(20, 0, "Close", MAStudy.VOLUMEWEIGHTED);
        var vSMA50 = new MAStudy(50, 0, "Close", MAStudy.SIMPLE);
        var vLastAlert = -1;
        //}}EFSWizard_Declarations


        function preMain() {
        /**
        * This function is called only once, before any of the bars are loaded.
        * Place any study or EFS configuration commands here.
        */
        //{{EFSWizard_PreMain
        setPriceStudy(true);
        setStudyTitle("8MA/20MA Cross with Backround Paint - WIZARD");
        setCursorLabelName("HIGH", 0);
        setCursorLabelName("LOW", 1);
        setDefaultBarStyle(PS_SOLID, 0);
        setDefaultBarStyle(PS_SOLID, 1);
        setDefaultBarFgColor(Color.black, 0);
        setDefaultBarFgColor(Color.black, 1);
        setDefaultBarThickness(3, 0);
        setDefaultBarThickness(3, 1);
        setPlotType(PLOTTYPE_LINE, 0);
        setPlotType(PLOTTYPE_LINE, 1);
        //}}EFSWizard_PreMain

        }

        function main() {
        /**
        * The main() function is called once per bar on all previous bars, once per
        * each incoming completed bar, and if you don't have 'setComputeOnClose(true)'
        * in your preMain(), it is also called on every tick.
        */

        //{{EFSWizard_Expressions
        //{{EFSWizard_Expression_1
        if (
        vSMA50.getValue(MAStudy.MA, -1) == null
        ) onAction1()
        //}}EFSWizard_Expression_1

        //{{EFSWizard_Expression_2
        else if (
        Strategy.isLong() == false &&
        vEMA8.getValue(MAStudy.MA, -1) < vSMA50.getValue(MAStudy.MA, -1) &&
        vEMA8.getValue(MAStudy.MA) > vSMA50.getValue(MAStudy.MA)
        ) onAction2()
        //}}EFSWizard_Expression_2

        //{{EFSWizard_Expression_3
        else if (
        Strategy.isShort() == false &&
        vEMA8.getValue(MAStudy.MA, -1) > vSMA50.getValue(MAStudy.MA, -1) &&
        vEMA8.getValue(MAStudy.MA) < vSMA50.getValue(MAStudy.MA)
        ) onAction3()
        //}}EFSWizard_Expression_3

        //{{EFSWizard_Expression_4
        else if (
        Strategy.isLong() == true &&
        vEMA8.getValue(MAStudy.MA) > vVWMA20.getValue(MAStudy.MA)
        ) onAction4()
        //}}EFSWizard_Expression_4

        //{{EFSWizard_Expression_5
        else if (
        Strategy.isShort() == true &&
        vEMA8.getValue(MAStudy.MA) < vVWMA20.getValue(MAStudy.MA)
        ) onAction5();
        //}}EFSWizard_Expression_5

        //}}EFSWizard_Expressions


        //{{EFSWizard_Return
        return new Array(
        high(),
        low()
        );
        //}}EFSWizard_Return

        }

        function postMain() {
        /**
        * The postMain() function is called only once, when the EFS is no longer used for
        * the current symbol (ie, symbol change, chart closing, or application shutdown).
        */
        }

        //{{EFSWizard_Actions
        //{{EFSWizard_Action_1
        function onAction1() {
        vLastAlert = 1;
        }
        //}}EFSWizard_Action_1

        //{{EFSWizard_Action_2
        function onAction2() {
        if (vLastAlert != 2) drawTextRelative(0, BelowBar1, "B", Color.RGB(0,0,255), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 14);
        if (vLastAlert != 2) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\Ding.wav");
        Strategy.doLong("LONG", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
        setBarBgColor(Color.RGB(0,192,36));
        vLastAlert = 2;
        }
        //}}EFSWizard_Action_2

        //{{EFSWizard_Action_3
        function onAction3() {
        Strategy.doShort("SHORT", Strategy.CLOSE, Strategy.THISBAR, Strategy.DEFAULT, 0);
        if (vLastAlert != 3) drawTextRelative(0, AboveBar1, "S", Color.RGB(255,0,0), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 14);
        if (vLastAlert != 3) Alert.playSound("C:\\Program Files\\eSignal\\Sounds\\hoot1.wav");
        setBarBgColor(Color.RGB(255,0,0));
        vLastAlert = 3;
        }
        //}}EFSWizard_Action_3

        //{{EFSWizard_Action_4
        function onAction4() {
        if (vLastAlert != 4) drawTextRelative(0, AboveBar1, "TP", Color.RGB(0,128,18), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 11);
        vLastAlert = 4;
        }
        //}}EFSWizard_Action_4

        //{{EFSWizard_Action_5
        function onAction5() {
        if (vLastAlert != 5) drawTextRelative(0, AboveBar1, "TP", Color.RGB(255,0,0), Color.RGB(255,255,0), Text.PRESET | Text.BOLD, "Arial", 11);
        vLastAlert = 5;
        }
        //}}EFSWizard_Action_5

        //}}EFSWizard_Actions

        Comment

        Working...
        X