PureBytes Links
Trading Reference Links
|
Hmm.. Now I know where my problem is..sort of.. I was trying to
convert the wealth-lab formular over to amibroker as a test and
realized that amibroker returns an array whereas wealth returned a
number
Wealth has a function : p1 := Peak( Bar, #High, Reversal );
So I used p1=Peak( High, Reversal, Bar);
where Bar is defined in a for loop : for(bar=100;bar<barcount-
1;bar++)
However, when I run this the value of p1 is always empty. I"m not
sure if I converted right or not.
Any ideas?
The wealth code is :
function Triangle( Reversal: float; Color: integer ): boolean;
begin
var Bar: integer;
var p1, p2, t1, t2, t3, topline, bottomline: float;
var pb1, pb2, tb1, tb2, tb3, b2: integer;
Result := false;
for Bar := 100 to BarCount - 1 do
begin
{ Determine the two most recent peaks }
p1 := Peak( Bar, #High, Reversal );
pb1 := PeakBar( Bar, #High, Reversal );
p2 := Peak( pb1, #High, Reversal );
pb2 := PeakBar( pb1, #High, Reversal );
{ and the three most recent troughs }
t1 := Trough( Bar, #Low, Reversal );
tb1 := TroughBar( Bar, #Low, Reversal );
t2 := Trough( tb1, #Low, Reversal );
tb2 := TroughBar( tb1, #Low, Reversal );
t3 := Trough( tb2, #Low, Reversal );
tb3 := TroughBar( tb2, #Low, Reversal );
{ See if this particular pattern was already detected }
s := IntToStr( pb1 ) + ',' + IntToStr( pb2 ) + ',' +
IntToStr( tb1 ) + ',' + IntToStr( tb2 );
if lstTriangles.IndexOf( s ) = -1 then
begin
{ Pattern not yet detected, add it to the list }
lstTriangles.Add( s );
{ Test relative positions of peaks and troughs to indicate triangle
formation }
if ( p1 < p2 * 0.995 ) and ( t1 > t2 * 1.005 ) and ( t2 > t3 *
1.005 ) and
( pb2 > tb3 ) and ( tb2 > pb2 ) and ( pb1 > tb2 ) and ( tb1
> pb1 ) then
{ Make sure price has moved sufficient level for triangle to
reverse }
if ROC( pb2, #Close, 60 ) > 20 then
begin
{ Triangle detected - draw the triangle zig zag lines }
DrawLine( pb2, p2, tb2, t2, 0, Color, #Thick );
DrawLine( tb2, t2, pb1, p1, 0, Color, #Thick );
DrawLine( pb1, p1, tb1, t1, 0, Color, #Thick );
DrawLine( tb3, t3, pb2, p2, 0, Color, #Thick );
{ Determine convergence bar }
for b2 := tb1 to BarCount - 1 do
begin
topline := LineExtendY( pb2, p2, pb1, p1, b2 );
bottomline := LineExtendY( tb2, t2, tb1, t1, b2 );
if topline < bottomline then
begin
Dec( b2 );
Break;
end;
{ Draw convergence lines (dotted) }
DrawLine( pb2, p2, b2, topline, 0, Color, #Dotted );
DrawLine( tb2, t2, b2, bottomline, 0, Color, #Dotted );
end;
{ Return true if the pattern was detected within the last 10 bars }
if Bar > BarCount - 10 then
Result := true;
end;
end;
end;
end;
Triangle( 3, #Teal );
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|