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

Re: [amibroker] Question for Graham > Trend Detection



PureBytes Links

Trading Reference Links

hi Steve

"PrD = C;
PrL = H/2+L/2;
PrdD = PrdL = PrdM = Param("Prd",12,2,40,1);

permax = Max(prdd,prdl);

Rs = IIf( BarIndex()<permax, 0, Rise(PrD, PrdD, PrL, PrdL) );"

see function Rise in last line abopve
I must admit not very well written, and was an early edition of the
code and an abridged version of the overall system code. So some items
might seem surplus to requirements. But it draws a coloured bar chart
if nothing else



-- 
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm


On 8/12/05, Steve <avalon-ardy@xxxxxxxxxxxxxxx> wrote:
> Hi Graham,
> I was going through the archive and I found the following code that you
> submitted for trend detection. Can you please explain where the variable "
> perd" in the function draws its value from. Or should I have another coffee
> or two and think about it :)
>  // Trend Detection
// Graham Kavanagh 11 Jan 05
// I am using version
> 4.66.2, but believe this will work with last offical version.

function
> Rise( Pd, perd, Pl, perl )
{
 MAD = DEMA(Pd,perd);
 MAL =
> LinearReg(Pl,perl);
 CondR = ROC(MAD,1)>0 AND ROC(MAL,1)>0;
 CondF =
> ROC(MAD,1)<0 AND ROC(MAL,1)<0; 
 R[0] = C[0]>(H[0]+L[0])/2;

> for(i=1;i<BarCount;i++)
 {
 if( CondR[i] )
 {
 R[i] = 1;
 }
 else
 {
 if(
> CondF[i] )
 {
 R[i] = 0;
 }
 else
 {
 R[i] = R[i-1];
 }
 }
 }
 return R;
}
> 

PrD = C;
PrL = H/2+L/2;
PrdD = PrdL = PrdM =
> Param("Prd",12,2,40,1);

permax = Max(prdd,prdl);

Rs = IIf(
> BarIndex()<permax, 0, Rise(PrD, PrdD, PrL, PrdL) );
Fs = IIf(
> BarIndex()<permax, 0, 1-Rs );

Confirm = MA(C,prdm);

function DirBar( dr,
> df )
{
B[0] = 0;

for(i=1;i<BarCount;i++)
{
 if( dr[i-1] && df[i] )
 {
 B[i]
> = 1;
 }
 else
 {
 if( df[i-1] && dr[i] )
 {
 B[i] = 1;
 }
 else
 {
 B[i] =
> B[i-1] + 1;
 }
 }
}
return B;
}

Bs = DirBar( Rs, Fs );
Direction =
> ROC(Confirm,1) > 0 AND ROC(Confirm,5) > 0;
Downward = ROC(Confirm,1) < 0 AND
> ROC(Confirm,5) < 0;

Select = Rs AND Ref(Fs,-1);
Caution = Fs AND
> Ref(Rs,-1);

Change = IIf( Rs, H/ValueWhen(Fs,L)*100, L/ValueWhen(Rs,H)*100
> );

Plot( C, "close", IIf( Rs, colorGreen, IIf( Fs, colorRed, colorBlack )),
> styleBar);

PlotShapes( shapeSmallCircle* select, colorDarkGreen, 0, H, 5
> );
PlotShapes( shapeSmallCircle* Caution, colorDarkRed, 0, L, -5
> );

GraphXSpace=10;
_N( Title = "{{NAME}} - {{INTERVAL}} {{DATE}} Trend Plot
> - "+prdd+" Day" );


Filter = Select OR Caution;
AddColumn( Select,
> "UpTurn", 1 );
AddColumn( Caution, "DownTurn", 1 );

// ---indicator
> end---
"Rise = " + Rs;
"Fall = " + Fs;
"Current Trend Bars = " + Bs;
"Trend
> Move = " + Change + " %"
>  
> 
> 
> 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 
> 
>  Visit your group "amibroker" on the web.
>   
>  To unsubscribe from this group, send an email to:
>  amibroker-unsubscribe@xxxxxxxxxxxxxxx
>   
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
>  To unsubscribe from this group, send an email to:
>  amibroker-unsubscribe@xxxxxxxxxxxxxxx
>   
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
>  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
> ________________________________
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12hbqhc56/M=362343.6886682.7839641.1493532/D=groups/S=1705632198:TM/Y=YAHOO/EXP=1123829729/A=2894354/R=0/SIG=11qvf79s7/*http://http://www.globalgiving.com/cb/cidi/c_darfur.html";>Help Sudanese refugees rebuild their lives through GlobalGiving</a>.</font>
--------------------------------------------------------------------~-> 

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/