PureBytes Links
Trading Reference Links
|
At 1:52 AM +0000 4/15/01, kjh129@xxxxxxxxxx wrote:
>here is what i came up with and i would appreciate it if anyone could help me just a little more... when this is put on the chart it works for the first couple of bars but then doesn't "reset" to continue to count the new highs.
>
>What i'm looking for is an indicator that will count the number of higher highs (a high higher than the prior bar but not necessarily consecutive to the last higher high) in a set number of bars.
The attached code is my best guess as to what you are looking for. You still didn't specify "new Highs since when" so I assumed you meant since the beginning of the N-bar interval. A gif picture is attached.
This is a pretty brute force method, just searching for new highs from N bars ago. There are faster ways by keeping track of things as you move forward through the bars but they take a lot more code.
Bob Fulks
{ *******************************************************************
Indicator : NewHighsLows
Last Edit : 4/15/01
Provided By : Bob Fulks
Description : This indicator plots the number of new highs and
new lows in the past "N" bars, as measured from the highs
and lows of "N"bars ago.
********************************************************************}
Input: N(20);
Vars: j(0), HHigh(0), LLow(0), NHigh(0), NLow(0);
HHigh = High[N];
LLow = Low[N];
NHigh = 0;
NLow = 0;
for j = N - 1 downto 0 begin
if High[j] > HHigh then begin
HHigh = High[j];
NHigh = NHigh + 1;
end;
if Low[j] < LLow then begin
LLow = Low[j];
NLow = NLow + 1;
end;
end;
Plot1(NHigh, "NHigh");
Plot2(-NLow, "NLow");
Plot4(0, "zero");
Attachment:
Description: "NewHiLo.gif"
|