I want to display a column in a Watch List in eSignal 11.3.2532.1269 32-bit.
I want the column to display the difference between last price and the 52-Week High.
To activate this script, I right-mouse on the column heading in the Watch List then "Add Columns -> My Formulas" and select OffHigh.efs (the name of my script.)
My problem is in getting the value of the 52-Week high. I'm using the upperDonchian function.
I don't know if this a good approach or if there's a better way to accomplish this.
As is, the script outputs "Hi null" diagnostic message.
If I change line 20 to:
xHigh52Week = upperDonchian(10, inv("W"));
it works, but this is a 10-week high -- I want the 52-week high.
How can I get the 52-week high value?
I'd like to be able to get both:
- 52-week high excluding today's high
- 52-week high including today's high
these would be different if the stock is making a new high today.
Thanks in advance.
[B]
I want the column to display the difference between last price and the 52-Week High.
To activate this script, I right-mouse on the column heading in the Watch List then "Add Columns -> My Formulas" and select OffHigh.efs (the name of my script.)
My problem is in getting the value of the 52-Week high. I'm using the upperDonchian function.
I don't know if this a good approach or if there's a better way to accomplish this.
As is, the script outputs "Hi null" diagnostic message.
If I change line 20 to:
xHigh52Week = upperDonchian(10, inv("W"));
it works, but this is a 10-week high -- I want the 52-week high.
How can I get the 52-week high value?
I'd like to be able to get both:
- 52-week high excluding today's high
- 52-week high including today's high
these would be different if the stock is making a new high today.
Thanks in advance.
PHP Code:
/*
Return value of difference between last price and 52-Week High
*/
function preMain() {
setPriceStudy(true);
setStudyTitle("Off 52 Week High");
setCursorLabelName("Off Hi");
// Appearance
setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
}
var bInit = false;
var xHigh52Week = null;
function main() {
if(bInit == false) {
xHigh52Week = upperDonchian(52, inv("W"));
bInit = true;
}
// Use most recent trade as last price
var vLastPrice = getMostRecentTrade();
if (vLastPrice == null) {
// Use current close at last price
vLastPrice = close(0);
if (vLastPrice == null) {
return ("Prc Err");
}
}
if (xHigh52Week == null) {
return ("Hi Err");
}
var vHigh = xHigh52Week.getValue(0);
if (vHigh == null) {
return("Hi null");
}
var vOffHigh = vLastPrice - vHigh;
if (vOffHigh > 0) {
return("---");
}
return (vOffHigh);
}
Comment