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

[amibroker] Variable % Peak recognition



PureBytes Links

Trading Reference Links




is an interesting AFL question. Since Peak() built-in function 
does not accept variable percentage, 
we can take the analytic road and see the fixed and variable 
percentage effect.
An example curve <FONT 
face="Times New Roman">MA(<FONT 
size=2>RSIA(MACD<FONT 
size=2>(),5),<FONT 
size=2>25), 
[the black bold line], a fixed initial percentage 20%, 

the 
respective peak recognition yellow line,<FONT 
face=Verdana size=2> a variable percentage 
<FONT 
face="Times New Roman">from 20% to 60% and the 
respective
red 
line and the result : The variable percentage line skips minor peaks P11, P111 
and goes from P1 
<FONT 
face="Times New Roman">directly to P2. The explanation : P1 is ~68, P11 is ~54, 
less then P1-20%P1 and it is a peak for the 
fixed percentage. But, near P11, the variable percentage is 
~45 and P11 should be less than 40 to 
be recognised as a peak again.
Play with the IB code
 
F=MA(<FONT 
size=2>RSIA(MACD<FONT 
size=2>(),5),<FONT 
size=2>25);Plot<FONT 
size=2>(F,"",<FONT 
size=2>1,8<FONT 
size=2>);// 
EXAMPLE CURVE<FONT 
face="Times New Roman">
<FONT 
face="Times New Roman"> 
R=<FONT 
size=2>20;<FONT 
face="Times New Roman">// THE FIXED PERCENTAGE<FONT 
face=Verdana size=2>
COEFP=1-R/<FONT 
size=2>100<FONT 
face="Times New Roman">;
COND1=Ref(<FONT 
size=2>Ref(F,-1<FONT 
size=2>)==HHV(F,<FONT 
size=2>3),1<FONT face=Verdana 
size=2>);
PeakVALUE=ValueWhen<FONT face=Verdana 
size=2>(COND1,F);<FONT 
face="Times New Roman">
COND11=PeakVALUE<COEFP*Ref<FONT 
size=2>(PeakVALUE,-1) OR 
PeakVALUE>Ref(PeakVALUE,-<FONT 
size=2>1<FONT 
face="Times New Roman">);
PeakVALUE1=ValueWhen<FONT face=Verdana 
size=2>(COND11,F);<FONT 
face=Verdana size=2>
Plot(PeakVALUE1,""<FONT 
size=2>,7,<FONT 
size=2>8);<FONT 
face="Times New Roman">// FIXED % PEAK LINE
 
R=R+Cum(<FONT 
size=2>1)%40<FONT 
size=2>;Plot(R,<FONT 
size=2>"",9<FONT 
size=2>,1);<FONT face=Verdana 
size=2>// THE VARIABLE 
PERCENTAGE<FONT 
face="Times New Roman">
COEFP=1-R/<FONT 
size=2>100<FONT 
face="Times New Roman">;
COND1=Ref(<FONT 
size=2>Ref(F,-1<FONT 
size=2>)==HHV(F,<FONT 
size=2>3),1<FONT face=Verdana 
size=2>);
PeakVALUE=ValueWhen<FONT face=Verdana 
size=2>(COND1,F);<FONT 
face="Times New Roman">
COND11=PeakVALUE<COEFP*Ref<FONT 
size=2>(PeakVALUE,-1) OR 
PeakVALUE>Ref(PeakVALUE,-<FONT 
size=2>1<FONT 
face="Times New Roman">);
PeakVALUE1=ValueWhen<FONT face=Verdana 
size=2>(COND11,F);<FONT 
face=Verdana size=2>
Plot(1.02<FONT 
size=2>*PeakVALUE1,"",<FONT 
size=2>4,8<FONT 
size=2>);// 
VARIABLE % PEAK LINE
 
Dimitris 
Tsokakis
 
 
 






Yahoo! Groups Sponsor












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



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



Attachment:
peak.gif

Attachment: Description: "Description: GIF image"