Here is what I'm trying to create:
A Price Study of....
3 times a WeightedMA of the TrueRange with a len 21
Where the "True Range" is the greater of one of the following:
• The difference between today’s high and today’s low
• The difference between today’s high and yesterday’s close,
or
• The difference between today’s low and yesterday’s close.
For reference, this is Andrew Abraham's "volitility Indicator" from his article in S&C volume 16:9 (425-427) in 1998 I think, if that helps.
After doing several searches, I have found that my major problem seems to be the inability of EFS to do a MAStudy on a user defined variable. I understand that I must make an array of my variable "vhighest". Not sure how to populate it.
Below is my very first EFS code I've ever written.
---------------------------
function preMain() {
setPriceStudy(true);
setStudyTitle("TTT");
setCursorLabelName("TTT");
}
function main(vMALength) {
if (vMALength == null){
vMALength = 21;
}
var vtodayshigh = call("getTodayOHLC.efs", "High");
var vtodayslow = call("getTodayOHLC.efs", "Low");
var vyesterdaysclose = call("getPrevOHLC.efs", "Close");
var vtodayshighlow = Math.abs(vtodayshigh - vtodayslow);
var vtodayshighclose = Math.abs(vtodayshigh - vyesterdaysclose);
var vtodayslowclose = Math.abs(vtodayslow - vyesterdaysclose);
var vhigher = Math.max(vtodayshighlow, vtodayshighclose);
var vhighest = Math.max(vhigher, vtodayslowclose);
var study2 = new MAStudy(vMALength,0,vhighest,MAStudy.MA,MAStudy.WE IGHTED);
var vTTT = study2.getValue(MAStudy.MA);
if(vTTT == null) {
return;
}
return (vTTT * 3);
}
---------------------------------
Thank you for any help you can provide!
Jim Fisk
A Price Study of....
3 times a WeightedMA of the TrueRange with a len 21
Where the "True Range" is the greater of one of the following:
• The difference between today’s high and today’s low
• The difference between today’s high and yesterday’s close,
or
• The difference between today’s low and yesterday’s close.
For reference, this is Andrew Abraham's "volitility Indicator" from his article in S&C volume 16:9 (425-427) in 1998 I think, if that helps.
After doing several searches, I have found that my major problem seems to be the inability of EFS to do a MAStudy on a user defined variable. I understand that I must make an array of my variable "vhighest". Not sure how to populate it.
Below is my very first EFS code I've ever written.
---------------------------
function preMain() {
setPriceStudy(true);
setStudyTitle("TTT");
setCursorLabelName("TTT");
}
function main(vMALength) {
if (vMALength == null){
vMALength = 21;
}
var vtodayshigh = call("getTodayOHLC.efs", "High");
var vtodayslow = call("getTodayOHLC.efs", "Low");
var vyesterdaysclose = call("getPrevOHLC.efs", "Close");
var vtodayshighlow = Math.abs(vtodayshigh - vtodayslow);
var vtodayshighclose = Math.abs(vtodayshigh - vyesterdaysclose);
var vtodayslowclose = Math.abs(vtodayslow - vyesterdaysclose);
var vhigher = Math.max(vtodayshighlow, vtodayshighclose);
var vhighest = Math.max(vhigher, vtodayslowclose);
var study2 = new MAStudy(vMALength,0,vhighest,MAStudy.MA,MAStudy.WE IGHTED);
var vTTT = study2.getValue(MAStudy.MA);
if(vTTT == null) {
return;
}
return (vTTT * 3);
}
---------------------------------
Thank you for any help you can provide!
Jim Fisk
Comment