i have a formula that i reused form the lib. Basically, it plots the NR7. However it plots the WR7(Widest range in 7 bars) only at the end of the bar.
How do i change it so that the plotting of the text happens as soon as it detects WR7
How do i change it so that the plotting of the text happens as soon as it detects WR7
PHP Code:
function preMain() {
setPriceStudy(true);
setStudyTitle("NR7");
}
function main() {
var nState = getBarState();
if (nState == BARSTATE_NEWBAR) {
var widest_bar_index = "";
var narrowest_bar_index = "";
var narrowest_width = 500000;
var widest_width = 0;
for (var i = 8; i >= 1; i--) {
var width_of_bar = high(-i) - low(-i);
if (width_of_bar < narrowest_width) {
narrowest_width = width_of_bar;
narrowest_bar_index = i;
} else if (width_of_bar > widest_width) {
widest_width = width_of_bar;
widest_bar_index = i;
}
}
var symbol = getSymbol();
if (narrowest_bar_index == 1) {
// last bar was an NR7
//var this_hour = getHour(1);
//var this_minute = getMinute(1);
//if ((this_hour >= 10 && this_hour < 16) || (this_hour == 9 && this_minute > 30)) {
drawTextRelative( -1, AboveBar1, "N", Color.green, null, Text.PRESET | Text.BOLD, null, 12);
// debugPrintln(symbol + " NR7 in last bar: " + this_hour + ":" + this_minute + " (" + narrowest_width + ")");
//}
//} else {
//var this_hour = getHour(-narrowest_bar_index);
//var this_minute = getMinute(-narrowest_bar_index);
//debugPrintln(symbol + " NR7 in bar: " + this_hour + ":" + this_minute + " (" + narrowest_width + ")");
}
if (widest_bar_index == 1) {
// last bar was an WR7
//var this_hour = getHour(-1);
//var this_minute = getMinute(-1);
//if ((this_hour >= 10 && this_hour < 16) || (this_hour == 9 && this_minute > 30)) {
drawTextRelative( -1, AboveBar1, "H", Color.red, null, Text.PRESET | Text.BOLD, null, 12);
// debugPrintln(symbol + " WR7 in last bar: " + this_hour + ":" + this_minute + " (" + widest_width + ")");
//}
//} else {
// var this_hour = getHour(-widest_bar_index);
//var this_minute = getMinute(-widest_bar_index);
//debugPrintln(symbol + " WR7 in bar: " + this_hour + ":" + this_minute + " (" + widest_width + ")");
}
}
}
Comment