Announcement

Collapse
No announcement yet.

Day()

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

  • #16
    Hi ratherBgolfing,

    You are most welcome, sorry for the delay in my response. Regarding your efs:


    you have the global eMA5 set to null; I did not - Good programming practice has you declare the global variable and set to null. The declaration of the variable to a global variable is essential. Setting to null is optional. If you look at the majority of the code written by the premier coders on the forum (e.g. Jason and Alex), you will see that they set these variables to null, then they check for null, and if so, they assign the global variable to the built-in study. This test for null can prevent inadvertant reassignment of the variable, which can lead to inefficiencies.

    you set: eMA5 = ema(5);
    I set: var e5 = new MAStudy(5,0,"Close",MAStudy.EXPONENTIAL);
    - I was using the efs2 format, you were using the original format associated with efs1. The appropriate way to obtain data once the MASttudy has been declared, using the methods associated with efs1, is e5.getValue(MAStudy.MA), not e5.getValue(0). If my memory is correct, you had to populate an array to access historical values, so you could never query for the (-3) value. They were not readily available like they are using the efs2 methodology. My recommendation is to stay with the efs2 format, it is much easier and more flexible.


    myVar = e5.getValue(-3);
    drawText(myVar, BelowBar2); // this gets error "Parameter 1 drawText function is invalid"
    - when you queried the historical variable in this way, it was undefined.

    drawText(myVar[3], BelowBar2); // this gets error : "myVar has no properties" - when you queried myVar[3], you were treating myVar as an array, when it was not, thus the message that the variable had no properties.

    As to the code I originally posted on the slope, I suspect it was working for you. In that code, I was only printing the variables when they were null. Otherwise, if not null, I was using them to calculate the slope and returning the slope variable from the function, subsequently returning the slope variable to the chart.

    I also massaged the snippet you posted using efs2, it is attached.

    I hope this helps.
    Attached Files

    Comment


    • #17
      I think this question got skipped over...

      What is the reason you use -3?

      Comment


      • #18
        Steve,

        Thanks again. You really have gone above and beyond duty. I appreciate it, including the explanation/lesson.

        I did not know I was using efs1 format. That explains a lot. In fact I have been having the same problem elsewhere using that format. Good to know for the future.

        Bgolf

        Comment


        • #19
          Buzz

          The -3 is purely arbitrary. Could be -5, -10 or -50...any number prior to the current bar in order to test if the current bar MA is higher or lower than the previous bar. I chose -3 for my current application as I wanted the most immediate info when the MA was likely turning.

          Bgolf

          Comment


          • #20
            Originally posted by ratherBgolfing
            Steve,

            Thanks again. You really have gone above and beyond duty. I appreciate it, including the explanation/lesson.

            I did not know I was using efs1 format. That explains a lot. In fact I have been having the same problem elsewhere using that format. Good to know for the future.

            Bgolf
            Hi Bgolf,

            You are most welcome again as well. I enjoyed helping you figure this out.

            Comment

            Working...
            X