Announcement

Collapse
No announcement yet.

EFS Help required

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

  • EFS Help required

    Hi Folks I would appreciate some help with EFS formulas.
    I am trying to get a histogram or line type non price study of the difference
    between two 14 bar momentum numbers based off a HLC/3. The current 14 bar
    momentum number is then subtracted from the 14 bar momentum
    number of three bars previous. I include my attempt to solve the EFS
    but I am doing something wrong and need assistance if possible. I would like
    to be able to change some of the variables such as price and number of bars.
    Here after follows my attempt at the EFS script but it has errors that need
    correction
    Regards Kevan

    var vMOM = null;

    function preMain() {
    setStudyTitle("name here");
    setCursorLabelName("Momentum");
    setDefaultBarFgColor(Color.blue);
    setPlotType(PLOTTYPE_HISTOGRAM);

    var fp1 = new FunctionParameter("MOMLength",
    FunctionParameter.NUMBER);
    fp1.setLowerLimit(1);
    fp1.setDefault(14); //Edit this value to set a new default

    var fp2 = new FunctionParameter("MOMSource",
    FunctionParameter.STRING);
    fp2.setName("MOMSource");
    fp2.setDefault("HLC/3"); //Edit this value to set a new default

    }

    function main(MOMLength, MOMSource) {
    if (vMOM == null) vMOM = new MOMStudy(MOMLength, MOMSource);

    var vNow = vMOM(0);
    if(vNow == null)
    return;

    var vThen = vMOM(-3)
    if(vThen == null)
    return;

    return (vNow - vThen);
    }

  • #2
    Here is your solution..

    You are not calling the momentum study values properly.

    Look at the last few lines of my code in comparison to yours..

    PHP Code:
    var vMOM null;

    function 
    preMain() {
    setStudyTitle("name here");
    setCursorLabelName("Momentum");
    setDefaultBarFgColor(Color.blue);
    setPlotType(PLOTTYPE_HISTOGRAM);

    var 
    fp1 = new FunctionParameter("MOMLength"
    FunctionParameter.NUMBER);
    fp1.setLowerLimit(1);
    fp1.setDefault(14); //Edit this value to set a new default

    var fp2 = new FunctionParameter("MOMSource"
    FunctionParameter.STRING);
    fp2.setName("MOMSource");
    fp2.setDefault("HLC/3"); //Edit this value to set a new default

    }

    function 
    main(MOMLengthMOMSource) {
    if (
    vMOM == nullvMOM = new MOMStudy(MOMLengthMOMSource);

    var 
    vNow vMOM.getValue(MOMStudy.MOM,0),
    if(
    vNow == null)
    return;

    var 
    vThen vMOM.getValue(MOMStudy.MOM,-3);
    if(
    vThen == null)
    return;

    return (
    vNow vThen);

    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Re: Here is your solution..

      MANY MANY THANKS Doji3333 I have the indicator finally up and working like a charm after many frustrating nights you have helped me a lot and I am very grateful to you.
      Regards KEVANV


      Originally posted by Doji3333
      You are not calling the momentum study values properly.

      Look at the last few lines of my code in comparison to yours..

      PHP Code:
      var vMOM null;

      function 
      preMain() {
      setStudyTitle("name here");
      setCursorLabelName("Momentum");
      setDefaultBarFgColor(Color.blue);
      setPlotType(PLOTTYPE_HISTOGRAM);

      var 
      fp1 = new FunctionParameter("MOMLength"
      FunctionParameter.NUMBER);
      fp1.setLowerLimit(1);
      fp1.setDefault(14); //Edit this value to set a new default

      var fp2 = new FunctionParameter("MOMSource"
      FunctionParameter.STRING);
      fp2.setName("MOMSource");
      fp2.setDefault("HLC/3"); //Edit this value to set a new default

      }

      function 
      main(MOMLengthMOMSource) {
      if (
      vMOM == nullvMOM = new MOMStudy(MOMLengthMOMSource);

      var 
      vNow vMOM.getValue(MOMStudy.MOM,0),
      if(
      vNow == null)
      return;

      var 
      vThen vMOM.getValue(MOMStudy.MOM,-3);
      if(
      vThen == null)
      return;

      return (
      vNow vThen);

      Comment

      Working...
      X