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

[amibroker] Item count...



PureBytes Links

Trading Reference Links

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