I am attempting to write an efs file to create a weighted moving average with a fairly long lookback period. When I do this the brute force way, however, it is so iterative that it locks up my computer trying to process the info. Is there a "canned" call I can make in the program to get a weighted moving average, or am I just stuck? Any attempts I have made with a formulaic approach take forever to process. Thanks.
Announcement
Collapse
No announcement yet.
Weighted MA
Collapse
X
-
dwain
The following code will plot a Weighted MA based on the close with a lookback period of 100
PHP Code:var vWMA100 = new MAStudy(100, 0, "Close", MAStudy.WEIGHTED);
function preMain() {
setPriceStudy(true);
setStudyTitle("weightedMA");
setCursorLabelName("wma", 0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarThickness(1, 0);
setPlotType(PLOTTYPE_LINE, 0);
}
function main() {
return vWMA100.getValue(MAStudy.MA);
}
If instead you want to be able to have a WMA where all the parameters can be modified via Edit Studies click here and download basicMA.efs.
Hope this helps
Alex
Comment
-
Thanks Alexis
I just wasn't aware that the various options for MA's could be called from the getValue.MAStudy line. I've already plugged it in and it works great. The application was to set an overnight .wav alarm for my position trading, yank me out of bed if things go bad.
Thanks again
Comment
Comment