Page 1 of 1

Congestion areas

Posted: Thu Sep 06, 2007 5:58 pm
by Lynx
I have been trying to code an indicator that plots two lines within certain caracteristics on the chart but it has proven to be a bit out of my league. Gave it a try for some time now but failed. I was wondering if anyone is interested in tackiling it. The idea behind this is to find small consolidation areas that happen naturally in the chart. I dont think the code i have come up with will work but will include it. I failed miserably at figuring out the logic behind this occurences to code it. Im putting some examples of the occurences as well with two horizontal lines to depict them. So far the rules I have to find them is that each line is requiered to be touched by at least two bars and is usually two to eight bars in length. Hope this helps explain it. I will include the code I have come up with but so far it does not work. Any ideas, suggestions or attempts at it are welcomed.










[code]
Inputs:
MaximumLength(5);


Vars:
HighestHigh(0),
LowestLow(0),
counterh(0),
counterl(0),
hightop(false),
lowbottom(false);

hightop = false;
lowbottom = false;
counterh = 0;
counterl = 0;

HighestHigh = highest(high[1],Maximumlength);

LowestLow = lowest(low[1],Maximumlength);



if low[1] = lowestlow then counterl = counterl + 1;
if low[2] = lowestlow then counterl = counterl + 1;
if low[3] = lowestlow then counterl = counterl + 1;
if low[4] = lowestlow then counterl = counterl + 1;
if low[5] = lowestlow then counterl = counterl + 1;
if low[6] = lowestlow then counterl = counterl + 1;
if low[7] = lowestlow then counterl = counterl + 1;
if low[8] = lowestlow then counterl = counterl + 1;


if low[1] = highesthigh then counterh = counterh + 1;
if low[2] = highesthigh then counterh = counterh + 1;
if low[3] = highesthigh then counterh = counterh + 1;
if low[4] = highesthigh then counterh = counterh + 1;
if low[5] = highesthigh then counterh = counterh + 1;
if low[6] = highesthigh then counterh = counterh + 1;
if low[7] = highesthigh then counterh = counterh + 1;
if low[8] = highesthigh then counterh = counterh + 1;



if counterl >1 then begin
hightop = true;
end;
If counterh >1 then begin
lowbottom = true;
end;


If close < highesthigh and close > lowestlow then
plot1(highesthigh,"HighBar",cyan)
else
noplot(1);
If close < highesthigh and close > lowestlow then
plot2(lowestlow,"LowBar",yellow)
else
noplot(1);

Posted: Thu Sep 06, 2007 6:42 pm
by zeller4
I'm trying something similar in Esignal using TRO dynamic S/R since they show tightening ranges when the S or R dots adjust (pull back) and levelling off areas when they go flat. I'm not very far along yet myself but will be hoping to show something for it within a couple weeks.
I hope you have good success.
kz

Posted: Thu Sep 06, 2007 7:41 pm
by TheRumpledOne
Try using Low <= lowest low and high > lowest low in your test for low.

Try using High >= Highest High and Low < Highest High in your test for High.

That may work a little better.

Posted: Thu Sep 13, 2007 2:27 pm
by Lynx
Thanks for your reply, tried it but still does not work. Do you have any more suggestions to try? Thanks, really appreciate it.

Good trading.

Posted: Sat Sep 15, 2007 12:36 am
by TheRumpledOne
Lynx wrote:Thanks for your reply, tried it but still does not work. Do you have any more suggestions to try? Thanks, really appreciate it.

Good trading.


Post the revised code and a screenshot so we can see what it is doing.

Posted: Thu Sep 20, 2007 4:02 pm
by kay
This one is from the Conway/Behle book

Indikator

Code: Select all

Inputs: RectangleLength(4),
      RangeLength(12),
      RangeFactor(1),
      RangeRatioLimit(.3);

Vars:    RectangleHigh(0),
      RectangleLow(0),
      UpperLine(-1),
      LowerLine(-1);



RectangleHigh = Highest (High, RectangleLength);
RectangleLow  = Lowest (Low, RectangleLength);
If AcmeRectangular(RectangleLength, RangeLength, RangeFactor, RangeRatioLimit) Then begin
   UpperLine = TL_New(Date [RectangleLength-1], Time [RectangleLength-1], RectangleHigh, Date [0], Time [0], RectangleHigh);
   If Upperline >= 0 then begin
      If GetBackGroundColor = Black then
         TL_SetColor(Upperline, Yellow)
      else
         TL_SetColor(Upperline, Black);
      TL_SetSize(Upperline,1);
   End;
   Lowerline =TL_New(Date [RectangleLength-1], Time [RectangleLength-1], RectangleLow, Date [0], Time [0], RectangleLow);
   If Lowerline >= 0 then begin
      If GetBackGroundColor = Black then
         TL_SetColor(Upperline, Yellow)
      else
         TL_SetColor(Upperline, Black);
      TL_SetSize(Upperline,1);
   End;
End;



and the function AcmeRectangular

Code: Select all

Inputs: RectangleLength(numeric),
      RangeLength(Numeric),
      RangeFactor(Numeric),
      RangeRatio(Numeric);

Vars:    ATR(0.0),
      VLength(30),
      RectangleHigh(0),
      RectangleLow(0),
      RectangleHeight(0),
      RangeHigh(0),
      RangeLow(0),
      RangeHeight(0);

AcmeRectangular = False;
ATR = Average (Range, VLength);

RectangleHigh = Highest (High, RectangleLength);
RectangleLow  = Lowest (Low, RectangleLength);
RectangleHeight = RectangleHigh-RectangleLow;

RangeHigh = Highest (High, RangeLength) [RectangleLength];
RangeLow = Lowest  (Low, RangeLength) [RectangleLength];
RangeHeight = RangeHigh-RangeLow;

If RectangleHeight >0 and RangeHeight>0 then
   If (RectangleHeight/RangeHeight) <= RangeRatio and
   RectangleHeight <=RangeFactor  * ATR then
      AcmeRectangular = True;



Posted: Thu Sep 20, 2007 4:35 pm
by Lynx
I had not seen this thread in a couple of days, I will try to post some screenshots of the revised code.

Kay:
The function does not verify, the function returns a true/false value and when i try to verify it it says that it expects a numeric expression. Any help?

Posted: Fri Sep 21, 2007 11:40 am
by kay
At the editor rigth click to properties -> Return Type: boolean(true/false).

You can find another code at Clyde Lees yahoo groups, called Find_Coils.ELS which also searchs for congestion zones based on Ross.
http://finance.groups.yahoo.com/group/swingmachine/