var: ID(-1),oo(0),windows_high(0),windows_low(0),direction(0),z(0);
arrays: high1[15000,2](0),low1[15000,2](0);
//recording the highand low
oo=oo+1;
high1[oo,0] = high;
high1[oo,1] = Time;
high1[oo,2] = Date;
low1[oo,0] = low;
low1[oo,1] = Time;
low1[oo,2] = Date;
//confirm high and low signal indicator
value1 = Average(high,20);
value2 = Average(low,20);
//plot the high and low chart
condition1 = close[1] > value2 and close < value2; //bear signal
condition2 = close[1] < value1 and close > value1; //bull signal
if condition1 then windows_high = 0;
if close > value1 then windows_high = windows_high+1; //calculate high windows for searching
if condition2 then windows_low = 0;
if close < value2 then windows_low = windows_low+1; //calculate low windows for searching
if windows_high = 0 and windows_high[1]<>0 then
value3 = highest(high,windows_high[1]); //find the highest price during the windows
if windows_low = 0 and windows_low[1]<>0 then
value4 = lowest(low,windows_low[1]); //find the lowest price during the windows
if windows_high = 0 and windows_high[1]<>0 then begin
for z = oo-windows_high[1] to oo begin
if high1[z,0]>value1 and high1[z,0] = value3 then begin
ID = text_new(high1[z,2],high1[z,1],high1[z,0], "HIGH");
text_setcolor(id,white);
break;
end;
end;
end;
if windows_low = 0 and windows_low[1]<>0 then begin
for z = oo-windows_low[1] to oo begin
if low1[z,0]<value2 and low1[z,0] = value4 then begin
ID = text_new(low1[z,2],low1[z,1],low1[z,0], "LOW");
text_setcolor(id,white);
break;
end;
end;
end;
|