Announcement

Collapse
No announcement yet.

line 0: null is not a function

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

  • line 0: null is not a function

    Hi,
    I'm trying to write a new study but getting this error while adding to the chart.
    line 0: null is not a function

    Call:
    function main(gNbrLength, gColorFlat,gColorUp, gColorDn)
    {
    if(!bMainInit)
    {
    xK = 1.0/gNbrLength;
    xSrc = close();
    xPdm = efsInternal("xPdm",xSrc);
    }


    Function:
    function xPdm(xSrc) {
    return Math.max((xSrc.getValue(0) - xSrc.getValue(-1)), 0);
    }


  • #2
    Thank you for posting on the eSignal Forums. Unfortunately for us to be able to assist you you need to provide more information as to your error message. This tidbit of code just is not enough to find out what the issue is.

    Thank you

    eSignal Support

    Comment


    • #3
      Here's more code from the study:



      var fpArray = new Array();
      function preMain()
      {
      setPlotType(PLOTTYPE_INSTANTCOLORLINE);
      setPriceStudy(true);
      setStudyTitle("VMA");
      setCursorLabelName("VMA", 0);
      setDefaultBarThickness(2, 0);

      var x=0;
      fpArray[x] = new FunctionParameter("gNbrLength", FunctionParameter.NUMBER);
      with(fpArray[x++])
      {
      setName("Number of Length");
      setLowerLimit(1);
      setDefault(10);
      }
      fpArray[x] = new FunctionParameter("gColorUp", FunctionParameter.COLOR);
      with(fpArray[x++])
      {
      setName("Up Color");
      setDefault(Color.lime);
      }
      fpArray[x] = new FunctionParameter("gColorDn", FunctionParameter.COLOR);
      with (fpArray[x++])
      {
      setName("Down Color");
      setDefault(Color.red);
      }
      fpArray[x] = new FunctionParameter("gColorFlat", FunctionParameter.COLOR);
      with (fpArray[x++])
      {
      setName("Flat Color");
      setDefault(Color.blue);
      }
      }

      var bMainInit = false;
      var xSrc = null;
      var xK = null;
      var xPdm = null;
      var xMdm = null;
      var xPdms = null;
      var xMdms = null;
      var xS = null;
      var xPdi = null;
      var xMdi = null;
      var xPdiS = null;
      var xMdiS = null;
      var xD = null;
      var xS1 = null;
      var xIS = null;
      var xHhv = null;
      var xLlv = null;
      var xD1 = null;
      var xVi = null;
      var xVMA = null;

      function main(gNbrLength, gColorFlat,gColorUp, gColorDn)
      {
      if(!bMainInit)
      {
      xK = 1.0/gNbrLength;
      xSrc = close();
      xPdm = efsInternal("xPdm",xSrc);
      /*xMdm = efsInternal("xMdm",xSrc);
      xPdms = efsInternal("xPdms",xK, xPdms, xPdm);
      xMdms = efsInternal("xMdms",xK, xMdms, xMdm);
      xS = efsInternal("xS",xPdms, xMdms);
      xPdi = efsInternal("xPdi",xPdms, xS);
      xMdi = efsInternal("xMdi",xMdms, xS);
      xPdiS = efsInternal("xPdiS",xK, xPdiS, xPdi);
      xMdiS = efsInternal("xMdiS",xK, xMdiS, xMdi);
      xD = efsInternal("xD",xPdiS, xMdiS);
      xS1 = efsInternal("xS1",xPdiS, xMdiS);
      xIS = efsInternal("xIS",xK, xIS, xD, xS1);
      xHhv = efsInternal("xHhv",xIS, gNbrLength);
      xLlv = efsInternal("xLlv",xIS, gNbrLength);
      xD1 = efsInternal("xD1",xHhv, xLlv);
      xVi = efsInternal("xVi",xIS, xLlv, xD1);
      xVMA = efsInternal("xVMA",xK, xVi, xVMA, xSrc);
      */
      bMainInit = true;

      }

      return xSrc.getValue(-1);
      }

      function xVMA(xK, xVi, xVMA, xSrc)
      {
      return ((1 - xK.getValue(0)*xVi.getValue(0)) * xVMA.getValue(-1) + xK.getValue(0)*xVi.getValue(0) * xSrc.getValue(0));
      }

      function xPdm(xSrc)
      {
      return Math.max((xSrc.getValue(0) - xSrc.getValue(-1)), 0);
      }


      Click image for larger version

Name:	Screen Shot 2019-08-28 at 1.28.58 PM.png
Views:	512
Size:	12.4 KB
ID:	268367

      Comment


      • #4
        sun0781
        You are using the same name (i.e. xPdm and also all the other similarly named variables and functions) ) as a variable and function
        Replace the function name with for example xPDM and you will no longer get an error
        Alex

        P.S For future reference and as a courtesy towards others who may try to help you please post formatted code (ie in PHP tags)


        Originally posted by sun0781 View Post
        Here's more code from the study:



        var fpArray = new Array();
        function preMain()
        {
        setPlotType(PLOTTYPE_INSTANTCOLORLINE);
        setPriceStudy(true);
        setStudyTitle("VMA");
        setCursorLabelName("VMA", 0);
        setDefaultBarThickness(2, 0);

        var x=0;
        fpArray[x] = new FunctionParameter("gNbrLength", FunctionParameter.NUMBER);
        with(fpArray[x++])
        {
        setName("Number of Length");
        setLowerLimit(1);
        setDefault(10);
        }
        fpArray[x] = new FunctionParameter("gColorUp", FunctionParameter.COLOR);
        with(fpArray[x++])
        {
        setName("Up Color");
        setDefault(Color.lime);
        }
        fpArray[x] = new FunctionParameter("gColorDn", FunctionParameter.COLOR);
        with (fpArray[x++])
        {
        setName("Down Color");
        setDefault(Color.red);
        }
        fpArray[x] = new FunctionParameter("gColorFlat", FunctionParameter.COLOR);
        with (fpArray[x++])
        {
        setName("Flat Color");
        setDefault(Color.blue);
        }
        }

        var bMainInit = false;
        var xSrc = null;
        var xK = null;
        var xPdm = null;
        var xMdm = null;
        var xPdms = null;
        var xMdms = null;
        var xS = null;
        var xPdi = null;
        var xMdi = null;
        var xPdiS = null;
        var xMdiS = null;
        var xD = null;
        var xS1 = null;
        var xIS = null;
        var xHhv = null;
        var xLlv = null;
        var xD1 = null;
        var xVi = null;
        var xVMA = null;

        function main(gNbrLength, gColorFlat,gColorUp, gColorDn)
        {
        if(!bMainInit)
        {
        xK = 1.0/gNbrLength;
        xSrc = close();
        xPdm = efsInternal("xPdm",xSrc);
        /*xMdm = efsInternal("xMdm",xSrc);
        xPdms = efsInternal("xPdms",xK, xPdms, xPdm);
        xMdms = efsInternal("xMdms",xK, xMdms, xMdm);
        xS = efsInternal("xS",xPdms, xMdms);
        xPdi = efsInternal("xPdi",xPdms, xS);
        xMdi = efsInternal("xMdi",xMdms, xS);
        xPdiS = efsInternal("xPdiS",xK, xPdiS, xPdi);
        xMdiS = efsInternal("xMdiS",xK, xMdiS, xMdi);
        xD = efsInternal("xD",xPdiS, xMdiS);
        xS1 = efsInternal("xS1",xPdiS, xMdiS);
        xIS = efsInternal("xIS",xK, xIS, xD, xS1);
        xHhv = efsInternal("xHhv",xIS, gNbrLength);
        xLlv = efsInternal("xLlv",xIS, gNbrLength);
        xD1 = efsInternal("xD1",xHhv, xLlv);
        xVi = efsInternal("xVi",xIS, xLlv, xD1);
        xVMA = efsInternal("xVMA",xK, xVi, xVMA, xSrc);
        */
        bMainInit = true;

        }

        return xSrc.getValue(-1);
        }

        function xVMA(xK, xVi, xVMA, xSrc)
        {
        return ((1 - xK.getValue(0)*xVi.getValue(0)) * xVMA.getValue(-1) + xK.getValue(0)*xVi.getValue(0) * xSrc.getValue(0));
        }

        function xPdm(xSrc)
        {
        return Math.max((xSrc.getValue(0) - xSrc.getValue(-1)), 0);
        }


        Click image for larger version  Name:	Screen Shot 2019-08-28 at 1.28.58 PM.png Views:	0 Size:	12.4 KB ID:	268367

        Comment


        • #5
          Thanks, ACM, it fixed the issue.

          Comment


          • #6
            sun0781
            You are welcome
            Alex


            Originally posted by sun0781 View Post
            Thanks, ACM, it fixed the issue.

            Comment

            Working...
            X