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.
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.
Comment