Cybersloth
Member
Really appreciate the willingness of others to share their Thinkscript codes here. Accordingly, what follows is a Thinkscript indicator which tallies the new highs and new lows for the NASDAQ in a normalized format. The indicator is from Bryan Johnson's book, "Before the Bear Strikes", in which the code was shared in Metastock format. Here, it is translated to Thinkscript. The author normalized the highs and lows to accommodate the changing number of issues. and suggested Normalized New Lows > 40 is a bearish indication. I haven't found that particular value to be especially useful, although monitoring market breadth is unquestionably important. Hope you find the Thinkscript helpful in some manner.
Thinkscript Code:
Thinkscript Code:
Code:
input time_frame = AggregationPeriod.DAY;
#COND1
input cond1_newhighs = "$NAHGH";
input cond1_newlows = "$NALOW";
input cond1_ema_length = 260;
def cond1_source_newhighs = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond1_newhighs, period = time_frame);
def cond1_source_newlows = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond1_newlows, period = time_frame);
#COND2
input cond2_advances = "$ADVN/Q";
input cond2_declines = "$DECN/Q";
input cond2_ema_length = 260;
def cond2_source_advances = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond2_advances, period = time_frame);
def cond2_source_declines = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond2_declines, period = time_frame);
def cond2_advance_ema = movingaverage(averageType.EXPONENTIAL, cond2_source_advances, cond2_ema_length);
def cond2_decline_ema = movingaverage(averageType.EXPONENTIAL, cond2_source_declines, cond2_ema_length);
#COND3
input cond3_unchanged = "$UNCN/Q";
input cond3_ema_length = 260;
input cond3_multiplier = 3000;
def cond3_source_advances = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond3_unchanged, period = time_frame);
def cond3_ema = movingaverage(averageType.EXPONENTIAL, cond3_source_advances, cond3_ema_length);
plot normalized_newhighs = round(cond1_source_newhighs / (cond2_advance_ema + cond2_decline_ema + cond3_ema) * cond3_multiplier,2);
normalized_newhighs.definecolor("Default", color.green);
normalized_newhighs.assignvalueColor(normalized_newhighs.color("Default"));
addlabel(yes, "Normalized New Highs: " + normalized_newhighs, normalized_newhighs.color("Default"));
plot normalized_newlows = round(cond1_source_newlows / (cond2_advance_ema + cond2_decline_ema + cond3_ema) * cond3_multiplier,2);
normalized_newlows.definecolor("Default", color.red);
normalized_newlows.assignvalueColor(normalized_newlows.color("Default"));
addlabel(yes, "Normalized New Lows: " + normalized_newlows, normalized_newlows.color("Default"));
Last edited by a moderator: