[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Re: Divergence Indicator



PureBytes Links

Trading Reference Links

See if this does what the VT codes does:

 

"Relative Strength Index";

//pilpilonim [pilpilonim@xxxxxxxxx] "...It sure looks good in VT..."

 

SetChartOptions(1,chartShowDates);

 

RSIper = Param("RSI Periods",5,2,50,1);

RSIndex = RSI(RSIper);

 

//This will detect a trough of RSI, then detect a second trough lower than the first Trough

 

DefineTrough = RSIndex > Ref(RSIndex,-1) AND Ref(RSIndex,-1) < Ref(RSIndex,-2);

 

PrevTrough = ValueWhen(DefineTrough,Ref(RSIndex,-1),2);

ActualTrough = DefineTrough AND PrevTrough < Ref(RSIndex,-1);

 

PrevPrcTrough = ValueWhen(DefineTrough,Ref(L,-1),2);

ActualPrcTrough = DefineTrough AND PrevPrcTrough > Ref(L,-1);

 

BullishDivergence = ActualTrough AND ActualPrcTrough;

 

//This will detect a peak of RSI, then detect a second peak higher than the first peak}

 

DefinePeak = RSIndex < Ref(RSIndex,-1) AND Ref(RSIndex,-1) > Ref(RSIndex,-2);

 

PrevPeak = ValueWhen(DefinePeak,Ref(RSIndex,-1),2);

ActualPeak = DefinePeak AND PrevPeak > Ref(RSIndex,-1);

 

PrevPrcPeak = ValueWhen(DefinePeak,Ref(H,-1),2);

ActualPrcPeak = DefinePeak AND PrevPrcPeak < Ref(H,-1);

 

BearishDivergence = ActualPeak AND ActualPrcPeak;

 

Plot(C,Name(),IIf(C > O,colorGreen,colorRed),styleBar | styleThick);

Plot(H,"High",colorGrey50);

Plot(L,"Low",colorGrey50);

 

Plot(RSIndex,"RSI(" + NumToStr(RSIper,1.0) + ")",colorDarkRed,styleOwnScale,0,100);

PlotShapes(IIf(BullishDivergence,shapeCircle,shapeNone),colorGreen,0,L,0);

PlotShapes(IIf(BearishDivergence,shapeCircle,shapeNone),colorRed,0,H,0);

 

--

Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of pilpilonim
Sent: Monday, April 10, 2006 23:59
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Divergence Indicator

 

It sure looks good in VT.

Anyone please?

 

 

--- In amibroker@xxxxxxxxxxxxxxx, "ramot06" <ramot06@xxx> wrote:

>

> Hi everyone.

>

> I came acroos some quite productive divergence indicator in VT.

> Could someone take the stick and convert it to AFL?

>

> Thanks In advance.

>

>

> The code :

>

>

> {Relative Strength Index}

>

> RSIndex:= RSI(RSIper);

>

> {This will detect a trough of RSI, then detect a second

> trough lower than the first trough}

>

> DefineTrough:= if(RSIndex>ref(RSIndex,-1) and ref(RSIndex,-1)<ref

> (RSIndex,-2), 1, 0);

>

> PrevTrough:= valuewhen(2,DefineTrough,ref(RSIndex,-1));

> ActualTrough:= if(DefineTrough and PrevTrough<ref(RSIndex,-1),1,0);

>

> PrevPrcTrough:= valuewhen(2,DefineTrough,ref(L,-1));

> ActualPrcTrough:= if(DefineTrough and PrevPrcTrough>ref(L,-1),1,0);

>

> BullishDivergence:= if(ActualTrough=1 and ActualPrcTrough=1,1,0);

>

> {This will detect a peak of RSI, then detect a second

> peak higher than the first peak}

>

> DefinePeak:= if(RSIndex<ref(RSIndex,-1) and ref(RSIndex,-1)>ref

> (RSIndex,-2), 1, 0);

>

> PrevPeak:= valuewhen(2,DefinePeak,ref(RSIndex,-1));

> ActualPeak:= if(DefinePeak and PrevPeak>ref(RSIndex,-1),1,0);

>

> PrevPrcPeak:= valuewhen(2,DefinePeak,ref(H,-1));

> ActualPrcPeak:= if(DefinePeak and PrevPrcPeak<ref(H,-1),1,0);

>

> BearishDivergence:= if(ActualPeak=1 and ActualPrcPeak=1,1,0);

>

 

 

 

 

 

 

 

Please note that this group is for discussion between users only.

 

To get support from AmiBroker please send an e-mail directly to

SUPPORT {at} amibroker.com

 

For other support material please check also:

http://www.amibroker.com/support.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/

 

 

 



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS