What I want to accomplish is the following:
1- Run the calculation in Line 10 (That works); then,
2- Calculate an EMA of line 10, in line 11; then,
3- Calculate another EMA (double smoothing) in line 12 of line 11; then,
4- Return the results in vEMAsN.
CODE SAMPLE:
1- function preMain() {
2- setPriceStudy(false);
3- setStudyTitle("Array");
4- setCursorLabelName("Array", 0);
5- setDefaultBarStyle(PS_SOLID, 0);
6- setDefaultBarFgColor(Color.navy, 0);
7- setDefaultBarThickness(1, 0);
8- setPlotType(PLOTTYPE_HISTOGRAM, 0);
}
9- function main() {
10- var vSMq = (getValue("close") - (.5 * (getValue("high") + getValue("low"))));
11- var vEMArN = new ema(20, vSMq);
12- var vEMAsN = new ema(20, vEMArN);
13- return vEMAsN;
}
The problem I have is line 12. When I run the code, the following error comes up:
Line 12; Parameter No. 2 of function ema is invalid
For some reason the EMA does not look at vEMArN and use it to calculate the final result. I believe it may be because vSMq is not in a Series, but I am not sure. If that is the case, how do I get the vSMq into a Series so an EMA() will correctly use it. Or, can I just put my math in line 10 direclty into the first EMA()? I trued that but it does not appear to work.
If anyone has any thoughts, please let me know.
Regards,
ZM
1- Run the calculation in Line 10 (That works); then,
2- Calculate an EMA of line 10, in line 11; then,
3- Calculate another EMA (double smoothing) in line 12 of line 11; then,
4- Return the results in vEMAsN.
CODE SAMPLE:
1- function preMain() {
2- setPriceStudy(false);
3- setStudyTitle("Array");
4- setCursorLabelName("Array", 0);
5- setDefaultBarStyle(PS_SOLID, 0);
6- setDefaultBarFgColor(Color.navy, 0);
7- setDefaultBarThickness(1, 0);
8- setPlotType(PLOTTYPE_HISTOGRAM, 0);
}
9- function main() {
10- var vSMq = (getValue("close") - (.5 * (getValue("high") + getValue("low"))));
11- var vEMArN = new ema(20, vSMq);
12- var vEMAsN = new ema(20, vEMArN);
13- return vEMAsN;
}
The problem I have is line 12. When I run the code, the following error comes up:
Line 12; Parameter No. 2 of function ema is invalid
For some reason the EMA does not look at vEMArN and use it to calculate the final result. I believe it may be because vSMq is not in a Series, but I am not sure. If that is the case, how do I get the vSMq into a Series so an EMA() will correctly use it. Or, can I just put my math in line 10 direclty into the first EMA()? I trued that but it does not appear to work.
If anyone has any thoughts, please let me know.
Regards,
ZM
Comment