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

Re: [amibroker] Item count...



PureBytes Links

Trading Reference Links

Hi --

You might also look at the AddToComposite function.  There is an excellent document describing ATC written by Herman  van den Bergen:
http://www.amibroker.org/3rdparty/IntroToAtc.pdf

Also go to the AmiBroker Users Knowledge Base and search for ATC:
http://www.amibroker.org/userkb/

Thanks,
Howard
www.quantitativetradingsystems.com


 

On 11/6/07, dj9866 <johnston.dc@xxxxxxxxxxx> wrote:

As the following scan executes, I would like to have two
counters...BuyCnt and SellCnt tracking the number of buy/sell flags,
so that I can generate a ratio of flags. I have tried a number of
ways, with the last one being to use the 'while' statement and
clearing the counters prior to the 'while'. Didn't gain anything...it
seems that the counters are still being reset every time a new symbol
is scanned. Will appreciate any assistance. Thank you.

BuyCnt=0;
SellCnt=0;
PassCnt=1;
while(PassCnt>=1)
{
PassCnt--;
PrevSig=0;
UpFlag=0;
DnFlag=0;
BCnt=BarCount-1;

period = Param( "RSI Period", 13, 1, 100, 1 );
MAperiod = Param( "MA Period", 5, 1, 100, 1 );
StDevperiod = Param( "StDev Period", 8, 1, 100, 1 );
upday=IIf(C>Ref(C,-1),C-Ref(C,-1),0);
downday=IIf(Ref(C,-1)> C,Ref(C,-1)-C,0);
Stda=MA(StDev(C,StDevperiod),MAperiod);
V1=StDev(C,StDevperiod)/Stda;
TD=int(period/V1);
Su=Sum(upday,TD);
Sd=Sum(downday,TD);
M1=(Su-Sd);
M2=abs(Su+Sd);
DMI=50*(M1+M2)/M2;
xs=Param("Smoothing",3,1,10,1);
xs1=Param("Trigger Line",5,1,10,1);
Buy=Cross(EMA(DMI,xs),MA(DMI,xs1));
Sell=Cross(MA(DMI,xs1),EMA(DMI,xs));

if (Buy[BCnt])
{
PrevSig=BarsSince(Sell);
BuyCnt++;
IIf(Close>Ref(Close,-1),UpFlag=1,DnFlag=0);
}
if (Sell[BCnt])
{
PrevSig=BarsSince(Buy);
SellCnt++;
IIf(Close<Ref(Close,-1),UpFlag=0,DnFlag=1);
}

Filter = (MarketID(0)==1 OR MarketID(0)==2 OR MarketID(0)==3)
//Dow Jones,American Echange,NASDAQ AND UpFlag OR DnFlag
AND Buy AND UpFlag
OR Sell AND DnFlag
AND PrevSig>5
AND Close > 3
AND MA(V,30) > 250*1000
;
AddColumn( Close,"Close");

AddColumn(V/1000,"Vol*1000",format=6.0,colorDefault,colorDefault,width=75);

AddColumn(Buy,"Buy",format=1.0,colorDefault,IIf(Buy,colorGreen,colorDefault));
AddColumn(UpFlag,"UpFlag");

AddColumn(Sell,"Sell",format=1.0,colorDefault,IIf(Sell,colorRed,colorDefault));
AddColumn(DnFlag,"DnFlag");
AddColumn(PrevSig,"PrevSig/Days
Ago",format=3.0,colorDefault,colorDefault,width=125);
AddColumn(BuyCnt,"BuyCnt",format=3.0);
AddColumn(SellCnt,"SellCnt",format=3.0);
}


__._,_.___

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___