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

RE: [amibroker] Re: PREV



PureBytes Links

Trading Reference Links

Hi Stan,
I attach AFL code below that should do the trick.
Cheers,
Gordon Sutherland

_SECTION_BEGIN("Countback Line");
 /* 	Stephane Carrasset's Countback Line (CBL) popularized by Daryl Guppy
		Refer to AmiBroker Yahoo Forum posting 30th December 2004*/

nR=2;
Cbl[nR]=Null;
bCBL=False;

    for( i=nR; i < BarCount; i++)
    {
        if( (Low[i-2]<Low[i-1]) && (Low[i-1]<Low[i]) )
        {
            Cbl[i] = Low[i-2];
            bCBL = True;
        }
        else if (bCBL)
        {
            if (Low[i] < Cbl[i-1])
            {
                Cbl[i] = Cbl[i-1];
                bCBL = False;
            }
            else
            {
                n = nR;
                minval[i] = Low[i];
                breakloop= False;
                for (j = 1; NOT(breakloop) && j <= i; j++)
                {
                    if (Low[i-j] < minval[i])
                    {
                        if (n>1)
                        {
                            minval[i] = Low[i-j];
                            n--;
                        }
                        else
                        {
                            Cbl[i] = Low[i-j];
                            breakloop=True;
                        }
                    }
                }
                if (Cbl[i] < Cbl[i-1])
                Cbl[i] = Cbl[i-1];
            }
        }
        else
        {
            Cbl[i] = Cbl[i-1];
        }
    if (Cbl[i]==0)
    Cbl[i] = Cbl[i-1];
    }

Plot(Cbl,"",colorDarkGreen,1);
Plot(C,"",-1,64);
_SECTION_END();


-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Stan Graham
Sent: Thursday, 3 July 2008 4:19 a.m.
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: PREV

Thank you Tomasz I used PREV and the function seems to work OK, 
except the line drawn on the chart doesn't seem correct, guess I got 
it wrong. I'm trying to duplicate Guppys CountBack function, has 
anyone already done this? I would realy appreciate seeing how to do 
it! The MetaStock code is public and is as follows"

HighDays := Input("Enter # days to cover last HIGH for CBL calc'n:", 
3, 55, 13); 

If(HIGH < HHV(HIGH, HighDays), {then ...} PREV, {previous CBLhi, 
else...} 
If(Ref(L,-2) < Ref(L,-1) AND Ref(L,-2) < L AND Ref(L,-1) < L, 
{then ...} Ref(L,-2), {2nd day back low, else...} 
If((Ref(L,-3)< Ref(L,-2) AND Ref(L,-3) < Ref(L,-1) AND Ref(L,-3) < L) 
AND (Ref(L,-2)< L 
 OR Ref(L,-1) < L), {then ... } Ref(L,-3), {3rd day back low, 
else...} 
If((Ref(L,-4)< Ref(L,-3) AND Ref(L,-4) < Ref(L,-2) AND Ref(L,-4) < Ref
(L,-1) AND Ref(L,-4) < L) AND (Ref(L,-3)< L 
 OR Ref(L,-2) < L 
 OR Ref(L,-1) < L), {then... } Ref(L,-4), {4th day back low, else...} 
If((Ref(L,-5)< Ref(L,-4) AND Ref(L,-5) < Ref(L,-3) AND Ref(L,-5) < Ref
(L,-2) AND Ref(L,-5) < Ref(L,-1) AND Ref(L,-5) < L) AND (Ref(L,-4)
<L   
 OR Ref(L,-3) < L 
 OR Ref(L,-2) < L 
 OR Ref(L,-1) < L), {then ...} Ref(L,-5), {5th day back low, else...} 
PREV )))))

Hope someone can help, thank you.
StanG



--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> 
wrote:
>
> Hello,
> 
> The archive search reveals many posts about the same subject,
> including last one from May 28, 2008:
> http://finance.groups.yahoo.com/group/amibroker/message/124603
> 
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "Stan Graham" <asahi3@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Tuesday, July 01, 2008 8:00 PM
> Subject: [amibroker] PREV
> 
> 
> > Need help! Any one any idea how to replace the PREV function when 
> > transposing a Metastock formula to AmiBroker? Would appreciate 
any 
> > help, thank ypou.
> > StanG
> > 
> > 
> > ------------------------------------
> > 
> > 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> > 
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > Yahoo! Groups Links
> > 
> > 
> >
>



------------------------------------

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links






------------------------------------

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/