File Name: PctInRange.efs
Description:
This EFS displays the Percent In Range for the current day. The value is calculated by taking the difference between the last price and the low of the day, and dividing that by the High / Low range.
Formula Parameters:
n/a
Notes:
This EFS requires getTodayOHLC1.efs in the OHLC subfolder of Formulas. If you do not have it you can find a copy at the following link http://share.esignal.com/groupconten...las&groupid=10
Download File:
PctInRange.efs
EFS Code:
Description:
This EFS displays the Percent In Range for the current day. The value is calculated by taking the difference between the last price and the low of the day, and dividing that by the High / Low range.
Formula Parameters:
n/a
Notes:
This EFS requires getTodayOHLC1.efs in the OHLC subfolder of Formulas. If you do not have it you can find a copy at the following link http://share.esignal.com/groupconten...las&groupid=10
Download File:
PctInRange.efs
EFS Code:
PHP Code:
/********************************************************************
Copyright © eSignal, 2003
Title: Percent In Range
Version: 1.1
=====================================================================
History:
1.1 - Added Color coding to %inRange button
=====================================================================
Project Description:
This EFS displays the Percent In Range for the current day. The value
is calculated by taking the difference between the last price and the
low of the day, and dividing that by the High / Low range.
/*****************************************************************************
WARNING: This EFS requires getTodayOHLC1.efs in the OHLC subfolder of Formulas
If you do not have it you can find a copy at the following link
[url]http://share.esignal.com/groupcontents.jsp?folder=Formulas&groupid=10[/url]
******************************************************************************
**********************************************************************/
function preMain() {
setPriceStudy(true);
setStudyTitle("% in Range");
setShowCursorLabel(false);
}
var HH = null; // Highest High
var LL = null; // Lowest Low
var day1 = null;
var day0 = null;
function main() {
var vPctInRange = 0.0;
if (getBarState() == BARSTATE_NEWBAR) {
day1 = day0;
}
day0 = getDay();
if (day0 != day1) { //resets data if a new day
HH = null;
LL = null;
}
if (HH == null || high() >= HH) {
HH = callFunction("/OHLC/getTodayOHLC1.efs","main","High");
if (HH == null) return;
}
if (LL == null || low() <= LL) {
LL = callFunction("/OHLC/getTodayOHLC1.efs","main","Low");
if (LL == null) return;
}
// Calc Percent in Range
vPctInRange = (close() - LL) / (HH - LL) * 100;
if (vPctInRange > 100) vPctInRange = 100;
if (vPctInRange < 0) vPctInRange = 0;
vPctInRange = (Math.round(vPctInRange * 100)) / 100 //Rounds to two decimal precision
//Display result
drawTextAbsolute( 0, 15, "%inRange: " + vPctInRange + "%", Color.black, Color.lightgrey, Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 12, "PctInRange" );
// Color Coding
if (vPctInRange > 80) {
drawTextAbsolute( 0, 15, "%inRange: " + vPctInRange + "%", Color.black, Color.lime, Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 12, "PctInRange" )
} else if (vPctInRange < 20) {
drawTextAbsolute( 0, 15, "%inRange: " + vPctInRange + "%", Color.black, Color.red, Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 12, "PctInRange" );
}
return null;
}