this works fine for me, your problem must be something else:
PrevSig=1;//BarsSince(Sell);
CntBuys=Nz(StaticVarGet("BuyCnt"));
_TRACE("CntBuys "+CntBuys);
CntBuys++;
StaticVarSet("BuyCnt",CntBuys);
_TRACE("BuyCnt "+StaticVarGet("BuyCnt"));
IIf(Close>Ref(Close,-1),UpFlag=1,DnFlag=0);
Title = ""+CntBuys;
best regards,
herman
For tips on developing Real-Time Auto-Trading systems visit:
http://www.amibroker.org/userkb/
Tuesday, November 6, 2007, 9:50:26 PM, you wrote:
> I have a .afl file that creates/loads a static variable with a numeric
> value(initialized to zero).
> When I execute a second .afl file, I do an 'include_once' of the
> first.afl file. During execution of the second file, I do a
> 'staticvarget' and load the value into a regular variable which is
> then incremented. A 'staticvarset' is executed to load the new value
> back into the static variable.
> I thought this would work, but it doesn't. Using _Trace, I can see
> that the initial value is retrieved and incremented from the static
> variable. But, the incremented value doesn't appear to be making it
> back into the static variable. On the second pass, the same value is
> pulled and incremented.
> Guidance will be appreciated.
> if (Buy[BCnt])
> {
> PrevSig=BarsSince(Sell);
> CntBuys=StaticVarGet("BuyCnt");
> _TRACE("CntBuys "+CntBuys);
> CntBuys++;
> StaticVarSet("BuyCnt",CntBuys);
> _TRACE("BuyCnt "+StaticVarGet("BuyCnt"));
> IIf(Close>Ref(Close,-1),UpFlag=1,DnFlag=0);
> }
> Debug output...
> [3556] CntBuys 0
> [3556] BuyCnt 1
> [3556] CntBuys 0
> [3556] BuyCnt 1
> [3556] CntBuys 0
> [3556] BuyCnt 1
> 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/
>
__._,_.___
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
__,_._,___
|