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

[amibroker] Re: Divergence Indicator



PureBytes Links

Trading Reference Links

Hi Terry ,

I can't see the screenshot. Maybe it is because I do see all the 
posts over the forum and dont get them directly to my e-mail.

If you can send me the screenshot , I would appreciate it.

Thanks
Pilpilonim


--- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxx> wrote:
>
> Pilpilonim,
> 
>  
> 
> The earlier conversion to your VT divergence indicator I posted 
seems to
> have problems with the direct translation. There were Ref(xxx,-1)
> statements that shouldn't have been there. Also, to get the 
indicator to
> fall on the actual day of the peak or valley in the variable
> "DefineTrough", I had to use ref(xxxx, 1) which is forward looking 
by 1
> day. Try this version instead. It shows you the various peaks and
> troughs for RSI and Price so you can decide if it's really doing 
the
> job.
> 
>  
> 
> I still wonder, after reading the code in detail, if this is doing 
what
> is expected. It finds peaks and valleys in the RSI levels, then it 
finds
> matching peaks and valleys in the High and Low prices. When it 
finds an
> RSI Trough matched to a Price trough it declares this a Bullish
> Divergence. I'm under the impression a divergence is when two 
indicators
> go in different directions.
> 
>  
> 
> Last point, it doesn't correctly find all the peaks and troughs. 
See
> screen shot with circled peak. It found the Price peak, but not 
the RSI
> peak. (Screen shot below.)
> 
>  
> 
> "Relative Strength Index";
> 
> //pilpilonim [pilpilonim@xxx] "...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 = Ref(RSIndex > Ref(RSIndex,-1) AND Ref(RSIndex,-1) <
> Ref(RSIndex,-2),1);
> 
> PrevTrough = ValueWhen(DefineTrough,RSIndex,2); //Finds the RSI of 
the
> previous RSI trough
> 
> ActualTrough = DefineTrough AND PrevTrough > RSIndex;
> 
>  
> 
> PrevPrcTrough = ValueWhen(DefineTrough,L,2); //Finds the Low of the
> previous RSI trough
> 
> ActualPrcTrough = DefineTrough AND PrevPrcTrough > L;
> 
>  
> 
> BullishDivergence = ActualTrough AND ActualPrcTrough;
> 
>  
> 
> //This will detect a peak of RSI, then detect a second peak higher 
than
> the first peak}
> 
>  
> 
> DefinePeak = Ref(RSIndex < Ref(RSIndex,-1) AND Ref(RSIndex,-1) >
> Ref(RSIndex,-2),1);
> 
> PrevPeak = ValueWhen(DefinePeak,RSIndex,2);
> 
> ActualPeak = DefinePeak AND PrevPeak > Ref(RSIndex,-1);
> 
>  
> 
> PrevPrcPeak = ValueWhen(DefinePeak,H,2);
> 
> ActualPrcPeak = DefinePeak AND PrevPrcPeak < H;
> 
>  
> 
> BearishDivergence = ActualPeak AND ActualPrcPeak;
> 
>  
> 
> Plot(C,Name(),IIf(C > O,colorGreen,colorRed),styleBar | 
styleThick);
> 
> //Plot(H,"High",colorGrey50);
> 
> //Plot(L,"Low",colorGrey50);
> 
>  
> 
> Plot(RSIndex,"\nRSI(" + 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);
> 
>  
> 
> Plot(DefineTrough
> ,"",colorDarkRed,styleHistogram|styleNoLabel|styleOwnScale,0,6); //
To
> highlight inside red
> 
> Plot(DefineTrough
> ,"",colorRed,styleHistogram|styleNoLabel|styleOwnScale,0,2);
> 
> Plot(PrevTrough ,"\nprev Trough
> RSI",colorRed,styleDashed|styleOwnScale);
> 
> Plot(ActualTrough
> ,"",colorRed,styleThick|styleArea|styleNoLabel|styleOwnScale,0,6);
> 
> Plot(ActualPrcTrough
> ,"",colorDarkRed,styleThick|styleArea|styleNoLabel|styleOwnScale,-
1,5);
> 
>  
> 
> Plot(-DefinePeak
> ,"",colorGreen,styleHistogram|styleNoLabel|styleOwnScale,-
6,0); //To
> highlight inside brightgreen
> 
> Plot(-DefinePeak
> ,"",colorBrightGreen,styleHistogram|styleNoLabel|styleOwnScale,-
2,0);
> 
> Plot(-PrevPeak ,"\nprev Peak 
RSI",colorGreen,styleDashed|styleOwnScale);
> 
> Plot(-ActualPeak
> ,"",colorBrightGreen,styleThick|styleArea|styleNoLabel|styleOwnScal
e,-6,
> 0);
> 
> Plot(-ActualPrcPeak
> ,"",colorGreen,styleThick|styleArea|styleNoLabel|styleOwnScale,-
5,1);
> 
>  
> 
> _N(Title = EncodeColor(colorRed) + "Red bars = RSI trough | "  +
> EncodeColor(colorDarkRed) + "Dark red bars = Price trough | " +
> 
> EncodeColor(colorBrightGreen) + "Bright green bars = RSI peak | " +
> EncodeColor(colorGreen) + "Green bars = Price Peak\n {{VALUES}}");
> 
>  
> 
> 
> 
>  --
> 
> Terry
>








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/