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

[amibroker] Re: Item count...



PureBytes Links

Trading Reference Links

Apparently, my comprehension of static variables is a bit short of the
mark...I have done the following...

I created a separate .afl file with...
  StaticVarSet("BuyCnt",0);
  StaticVarSet("SellCnt",0);

In the original file, I added...
 #include_once "C:\Program
   Files\AmiBroker\Formulas\Custom\Test001_StaticSet.afl"; 

Changed the increment coding to...
(CntBuys isn't initialized in code...)
  if (Buy[BCnt])
  {
  	PrevSig=BarsSince(Sell);
  	CntBuys=StaticVarGet("BuyCnt");
  	CntBuys++;
  	StaticVarSet("BuyCnt",CntBuys);
  	IIf(Close>Ref(Close,-1),UpFlag=1,DnFlag=0);
  }

The BuyCnt variable increments to '1' and that value is repeated for
every line in the 'addcolumn' table.  

Thanks you for your assistance...Don




--- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@xxx> wrote:
>
> use static variables so that they are not reset.
> 
> See "StaticVarSet() function in help
> 
> 
> ----- Original Message ----- 
> From: "dj9866" <johnston.dc@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Tuesday, November 06, 2007 1:09 PM
> Subject: [amibroker] Item count...
> 
> 
> > 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
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>




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/