Announcement

Collapse
No announcement yet.

Please Help - Study on Study

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

  • Please Help - Study on Study

    Hi All,

    Good day.

    I am not conversant in programming and I need help in writing an EFS script on a study on study involving stochastics.

    For example, a stochastics (bar=8, %K=3, %D=3) study on another stochastics (bar=10, %K=3, %D=3) study.

    Would appreciate any assistance and input.

    Thank you.

    Kind regards,
    Supra

  • #2
    Supra
    See StochasticOf_Montage.efs which was programmed by JasonK and is available here.
    Note that with EFS2 which is currently in beta it will be considerably easier to write studies on studies in particular with the Stochastic. On this subject you may want to see this thread. For example the Stochastic of Stochastic you posted would be written as var StochOfStoch = stochK(8,3,3,stochK(10,3,3))
    For more information on EFS2 see the EFS2 Development forum
    Alex

    Comment


    • #3
      Hi Alex,

      Thank you for your help.

      EFS2 sounds good, I think I'll give it a try.

      Kind regards,
      Supra

      Comment


      • #4
        Hi Alex,

        I have the Stoch on Stoch study up and running on EFS2 as per your guidance.

        However, the line is much stiffer compared to the same line in a friend's chart in Ensign.

        Please advise if you have any idea why it is so and how to make it match.

        Thank you.

        Kind regards,
        Supra

        Comment


        • #5
          Supra
          FWIW that was just an example to show how to write the Stochastic %K using Stochastic %K as the source
          For the complete syntax of the Stochastic study you may want to see the EFS2 Function Reference.pdf document which is in the Docs folder of the eSignal directory.
          Alex

          Comment


          • #6
            Hi Alex,

            Thank you for your reply.

            I will check out the EFS2 docs.

            On another issue, if I had 2 defined variables and I want to plot the difference between the 2 as a histogram, please kindly advise how do I go about it.

            Thank you for your kind assistance.

            Kind regards,
            Abel

            Comment


            • #7
              Abel
              Subtract one variable from the other. With regards to plotting as a histogram see the EFS KnowledgeBase under EFS Function Reference -> Colors, Constants & Flags -> Plot Types
              Alex

              Comment


              • #8
                Hi Alex,

                I get this error message "RangeError: invalid array length".

                Please help.

                Thank you,
                Abel

                Comment


                • #9
                  Abel
                  Without seeing the code it is impossible to tell what could be causing the error
                  Alex

                  Comment


                  • #10
                    Hi Alex,

                    Pardon my lack of knowledge.

                    Please find below the code.

                    Thank you,
                    Abel


                    //{{EFSWizard_Description
                    ////}}EFSWizard_Description 7532


                    //{{EFSWizard_Declarations
                    addBand(40, PS_DOT, 1, Color.RGB(255,125,125), "Bullish Lower");
                    addBand(60, PS_DOT, 1, Color.RGB(125,125,255), "Bearish Upper");


                    var vRSI14 = new RSIStudy(14, "Close");
                    var vEMA3_of_vRSI14 = new MAStudy(3, 0, vRSI14, RSIStudy.RSI, MAStudy.EXPONENTIAL);
                    var vEMA3_of_vEMA3_of_vRSI14 = new MAStudy(3, 0, vEMA3_of_vRSI14, MAStudy.MA, MAStudy.EXPONENTIAL);
                    var vEMA3_of_vEMA3_of_vEMA3_of_vRSI14 = new MAStudy(3, 0, vEMA3_of_vEMA3_of_vRSI14, MAStudy.MA, MAStudy.EXPONENTIAL);
                    var vSMA5_of_vEMA3_of_vEMA3_of_vEMA3_of_vRSI14 = new MAStudy(5, 3, vEMA3_of_vEMA3_of_vEMA3_of_vRSI14, MAStudy.MA, MAStudy.SIMPLE);
                    var XHist = vEMA3_of_vEMA3_of_vEMA3_of_vRSI14 - vSMA5_of_vEMA3_of_vEMA3_of_vEMA3_of_vRSI14
                    var vLastAlert = -1;

                    //}}EFSWizard_Declarations 60572


                    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(false);
                    setStudyTitle("TRSI HISTOGRAM");
                    setCursorLabelName("HIST", 0);
                    setDefaultBarStyle(PS_SOLID, 0);
                    setDefaultBarFgColor(Color.blue, 0);
                    setDefaultBarThickness(1, 0);
                    setPlotType(PLOTTYPE_HISTOGRAM, 0);
                    //}}EFSWizard_PreMain 54387

                    }

                    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
                    //}}EFSWizard_Expression_1 0

                    //}}EFSWizard_Expressions 9063


                    //{{EFSWizard_Return
                    return new Array(
                    XHist
                    );
                    //}}EFSWizard_Return 19893

                    }

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

                    //}}EFSWizard_Actions 15622

                    Comment


                    • #11
                      Abel
                      Here is the corrected code. Comments are in the script
                      Alex

                      PHP Code:
                      //{{EFSWizard_Description
                      ////}}EFSWizard_Description 7532


                      //{{EFSWizard_Declarations
                      addBand(40PS_DOT1Color.RGB(255,125,125), "Bullish Lower");
                      addBand(60PS_DOT1Color.RGB(125,125,255), "Bearish Upper");


                      var 
                      vRSI14 = new RSIStudy(14"Close");
                      var 
                      vEMA3_of_vRSI14 = new MAStudy(30vRSI14RSIStudy.RSIMAStudy.EXPONENTIAL);
                      var 
                      vEMA3_of_vEMA3_of_vRSI14 = new MAStudy(30vEMA3_of_vRSI14MAStudy.MAMAStudy.EXPONENTIAL);
                      var 
                      vEMA3_of_vEMA3_of_vEMA3_of_vRSI14 = new MAStudy(30vEMA3_of_vEMA3_of_vRSI14MAStudy.MAMAStudy.EXPONENTIAL);
                      var 
                      vSMA5_of_vEMA3_of_vEMA3_of_vEMA3_of_vRSI14 = new MAStudy(53vEMA3_of_vEMA3_of_vEMA3_of_vRSI14MAStudy.MAMAStudy.SIMPLE);
                      //var XHist = vEMA3_of_vEMA3_of_vEMA3_of_vRSI14 - vSMA5_of_vEMA3_of_vEMA3_of_vEMA3_of_vRSI14//ACM moved to main 
                      var vLastAlert = -1;

                      //}}EFSWizard_Declarations 60572


                      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(false);
                      setStudyTitle("TRSI HISTOGRAM");
                      setCursorLabelName("HIST"0);
                      setDefaultBarStyle(PS_SOLID0);
                      setDefaultBarFgColor(Color.blue0);
                      setDefaultBarThickness(10);
                      setPlotType(PLOTTYPE_HISTOGRAM0);
                      //}}EFSWizard_PreMain 54387

                      }

                      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
                      //}}EFSWizard_Expression_1 0

                      //}}EFSWizard_Expressions 9063

                      var XHist vEMA3_of_vEMA3_of_vEMA3_of_vRSI14.getValue(MAStudy.MA) - vSMA5_of_vEMA3_of_vEMA3_of_vEMA3_of_vRSI14.getValue(MAStudy.MA);

                      //{{EFSWizard_Return
                      return (XHist);//ACM modified
                      //}}EFSWizard_Return 19893

                      }

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

                      //}}EFSWizard_Actions 15622 

                      Comment


                      • #12
                        Hi Alex,

                        Thank you very much. You've been most helpful.

                        Kind regards,
                        Abel

                        Comment

                        Working...
                        X