Announcement

Collapse
No announcement yet.

Try to color 50 SMA

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

  • Try to color 50 SMA

    Hi,

    I am having problem how to write this efs codes.

    I want to color the 50 sma up slope = lime and 50 sma down slope = red.

    I ran the codes and it returned: line 34 TypeError: vsma has no properties.

    Having gone through the efs knowledge base but still could not be able to figure it out.

    Any help is greatly appreciated!

    Ted608

    Enclosed is the efs.
    Attached Files

  • #2
    Re: Try to color 50 SMA

    Ted608
    There are several errors in your script.
    The first one is that the name assigned to the FunctionParameter in line 18 ie. "vsma" is the same as that of the variable used for the moving average. You need to change that to something unique such as for example "Length". Once you have done that you will also need to change the name used in the arguments of the main function and as the parameter for the sma() function (see this article in the EFS KnowledgeBase for a complete set of examples on the use of the FunctionParameter Object)
    Also you are not properly initializing the sma() function in line 30 of your script
    The operator used in the conditional statement if(vsma = null) is an assignement operator ie = instead of a comparison operator ie == (for more information on JavaScript operators see this article in the EFS KnowledgeBase)
    Secondly you do not need to use the new constructor with the efs2 functions ie sma(), ema(), etc. That is necessary only with the legacy functions ie MAStudy()
    In that same line you are initializing a vsmaStudy() which is not an existing function instead of sma() eg vsma = sma(yourParameter). You can find a complete set of examples on the use of the moving average functuions in this article of the EFS KnowledgeBase
    Lastly in your return statement you need to retrieve the value of the series object eg return vsma.getValue(0) using the getValue() method of the Series Object.
    Alex


    Originally posted by Ted608
    Hi,

    I am having problem how to write this efs codes.

    I want to color the 50 sma up slope = lime and 50 sma down slope = red.

    I ran the codes and it returned: line 34 TypeError: vsma has no properties.

    Having gone through the efs knowledge base but still could not be able to figure it out.

    Any help is greatly appreciated!

    Ted608

    Enclosed is the efs.

    Comment


    • #3
      Thank you ...

      Hi Alexis,

      Thank you so much for your quick reply and for being a great instructor.

      I have corrected the codes as guided.
      I have tested it and it works wonderfully.
      Attached below is the new efs in case someone may need it.

      Ted608
      Attached Files

      Comment


      • #4
        Re: Thank you ...

        Ted608
        You are most welcome and thank you for the kind words
        Alex


        Originally posted by Ted608
        Hi Alexis,

        Thank you so much for your quick reply and for being a great instructor.

        I have corrected the codes as guided.
        I have tested it and it works wonderfully.
        Attached below is the new efs in case someone may need it.

        Ted608

        Comment

        Working...
        X