PureBytes Links
Trading Reference Links
|
<span
>Dimitris,
You are correct ... I did not make any other modifications other than
what you suggested in your prior email (sorry).
Attached is another version that takes variable arrays for IAF and <span
class=SpellE>MaxIAF. Below
are answers to your comments.
Regards,
Peter
-----Original Message-----
From: DIMITRIS TSOKAKIS [mailto:TSOKAKIS@xxxxxxxxx]
Sent: Saturday, May 03, 2003 6:22 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Var IAF Re: DIMITRIS- Question
Peter,
thank you very much for your reply.
I can not make a lot of comments on your code, see my
http://groups.yahoo.com/group/amibroker/message/39501
experimental idea.
I hope you will excuse my naive comments below.
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "bluesinvestor"
<investor@xxxx>
wrote:
> Dimitris,
>
> It does not seem to make a big difference with a variable IAF.
>
> Peter
>
> // Initialize IAF Array
> X=(DEMA(StochD(40),20)-50)/50;
> IAF=0.05*(1.1+abs(X));
this function varies [for ^NDX] from 0.055 to 0.105
It is important for the MaxAF selection
<span
>Fixed in attached version
>
> function SARafl( Cvar, Hvar, Lvar, MaxAF )
> {
> //IAF =
0.02;
// acceleration factor
> //MaxAF =
0.02; // max
acceleration
It does not make sense to me. MaxAF should be at least 10*IAF
<span
>Fixed – actually 20*IAF based on your
prior email
> <span
class=SpellE>psar = Cvar; //
initialize
> long =
1;
// assume long for initial conditions
> af = IAF[
0 ];<span
>
// init acelleration factor
I suppose here you define the initial af value
<font size=2 color=red
face="Courier New">yes<font
color=red>
> <span
class=SpellE>ep = Lvar[ 0 ];
// init extreme point
> hp = Hvar
[ 0 ];
> lp = Lvar
[ 0 ];
>
> for( i =
2; i < BarCount; i++ )
> {
> if
( long )
> {
> psar
[ i ] = psar [ i-1 ] + af * ( hp - psar [
> i-1 ] );
I suppose here you create the various psar values.
af has still it initial value ? I do not see variable <span
class=GramE>af here.
<font size=2
color=red face="Courier New">af<font
color=red> changes in other portions of the code –
it is variable
> }
> else
> {
> psar
[ i ] = psar [ i-1 ] + af * ( lp - psar [
> i-1 ] );
<span
>af still has its initial value ?
<font size=2 color=red
face="Courier New">not<font
color=red> necessarily
> }
>
> reverse
= 0;
> //check
for reversal
> if
( long )
> {
> if
( Lvar [ i ] < psar [ i ] )
> {
> long
= 0; reverse = 1; // reverse
> position to Short
> psar
[ i ] = hp;<span
> // SAR is
Hvar
> point in prev trade
> lp
= Lvar [ i ];
> //af
= IAF;
> <span
class=GramE>af = IAF[ i ];
<font size=2
color=red face="Courier New">af<font
color=red> changes here ---------^
> }
> }
> else
> {
> if
( Hvar [ i ] > psar [ i ] )
> {
> long
= 1; reverse =
1;<span
>
//reverse
> position to long
> psar
[ i ] = lp;
> hp
= Hvar [ i ];
> //af
= IAF;
> <span
class=GramE>af = IAF[ i ];
<font size=2
color=red face="Courier New">af<font
color=red> changes here ---------^
> }
> }
>
> if
( reverse == 0 )
> {
> if
( long )
> {
> if
( Hvar [ i ] > hp )
> {
> hp
= Hvar [ i ];
> //af
= af + IAF;
> af
= af + IAF[ i ];
> if(
af > MaxAF ) af = MaxAF;
> }
><span
>
> if(
Lvar[ i - 1 ] < psar[ i ] ) psar[
i
> ] = Lvar[ i - 1 ];
> if(
Lvar[ i - 2 ] < psar[ i ] ) psar[
i
> ] = Lvar[ i - 2 ];
> }
> <span
> else
> {
> if
( Lvar [ i ] < lp )
> {
> lp
= Lvar [ i ];
> //af
= af + IAF;
> af
= af + IAF[ i ];
> if(
af > MaxAF ) af = MaxAF;
> }<span
>
>
> if(
Hvar[ i - 1 ] > psar[ i ] ) psar[
i
> ] = Hvar[ i - 1 ];
> if(
Hvar[ i - 2 ] > psar[ i ] ) psar[
i
> ] = Hvar[ i - 2 ];
>
> }
> }
> }
> return
psar;
> }
>
> Plot( Close, "Price", colorBlack, styleCandle );
> Plot( SARafl(C,H,L,0.02), "SAR", colorRed, styleDots |
styleNoLine |
> styleThick );
>
> Filter=1;
> AddColumn(SAR(.02,.02),"SAR");
<span
>you use the same IAF, maxAF here
?
<font size=2 color=red
face="Courier New">just<font
color=red> for comparison … this is the built-in
SAR() function
> AddColumn(SARafl(C,H,L,0.02),"SARafl");
0.02 is very low for maxIAF
<font size=2 color=red
face="Courier New">this<font
color=red> is variable in the current code
Yahoo! Groups Sponsor
ADVERTISEMENT
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:
Function - SAR.afl
Attachment:
Description: "Description: Binary data"
|