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

Re: [amibroker] RUT AddToComposite with TC2000 data



PureBytes Links

Trading Reference Links

Just want to make sure I 'm correct in one thing.

If I define X = n at the begining of a formular then X is a static 
variable.

And if I'm using the same symbols eg x to represent variables in 
different indicators, even if the indicators may not be in use at 
one particular time on active charts , the settings in one one 
formular may interact with other forumulars containing the same 
formular. 

If I wanted to avoid this and was using a static variable within one 
indicator , I could set that by coding 

StaticVarSet( ''x'', n );

Is this correct ?

See Change 

--- In amibroker@xxxxxxxxxxxxxxx, "Herman van den Bergen" 
<psytek@xxxx> wrote:
> Great suggestion Tomasz, thanks for your input!
> 
> This will make things a lot simpler to code.
> 
> best regards,
> herman.
> 
> 
>   -----Original Message-----
>   From: Tomasz Janeczko [mailto:amibroker@x...]
>   Sent: Monday, August 09, 2004 5:31 AM
>   To: amibroker@xxxxxxxxxxxxxxx
>   Subject: Re: [amibroker] Static Variables
>   Importance: High
> 
> 
>   Herman,
> 
>   One thing: You don't need to worry about adding such complex 
coding all
> the time.
>   Instead you should use FUNCTIONS that make life easier.
>   If you want "unique static" (per indicator) you can easily have 
them using
> these two functions:
> 
>   procedure UnqStaticVarSet( name, value )
>   {
>      StaticVarSet( name + GetChartID(), value );
>   }
> 
>   function UnqStaticVarGet( name )
>   {
>     return StaticVarGet( name + GetChartID() );
>   }
> 
>   then use UnqStaticVarSet, UnqStaticVarGet in your code
> 
>   Best regards,
>   Tomasz Janeczko
>   amibroker.com
>     ----- Original Message -----
>     From: Herman van den Bergen
>     To: amibroker@xxxxxxxxxxxxxxx
>     Sent: Monday, August 09, 2004 3:28 AM
>     Subject: RE: [amibroker] Static Variables
> 
> 
>     Ara,
> 
>     You have to be careful scoping the Static Variables,
> 
>     1) If you use same name static variables in different 
indicators then
> their values can change from various sources. This is the case if 
you assign
> program derived values, for example counters ,not in the case of 
param() see
> next...
> 
>     2) If the Static variables are initialized inside the code 
with a
> Param() in EACH of the Indicators then in essence you have 
disabled the
> Global nature of the Static Variable: this is so because the 
Static variable
> is reinitialized in each Indicator separately each time the code 
is executed
> (on Refresh). This makes it immune to whatever other code does.
> 
>     3) Static variables are truly Global, in contrast to afl 
variables
> declared Global in afl, these are Global 'per' indicator. Static 
variables
> are Global per AmiBroker Instance.
> 
>     4) If you want to restrict the scope of Static variables to 
the current
> Indicator, to prevnt conflicing conditions, then you have to add a 
unique
> identifier to each code, I use something like this:
>     ChartID = NumToStr(GetChartID(),1.0,False);
>     Reset = Param("Reset Static variables",0,0,1,1);
>     StaticScope = Param("Scope (0:Local,1:Global) for
> Chart#"+ChartID,1,0,1,1);
>     if( StaticScope ) Scope = ""; else Scope = ChartID;
>     ...
>     if( IsEmpty( StaticVarGet("TickCounter"+Scope)) OR Reset)
>     StaticVarSet("TickCounter"+Scope,0);
>     TickCount = StaticVarGet("TickCounter"+Scope);
> 
>     here a tickcounter is made Local to the indicator containing 
the code to
> prevent interference with duplicate code in other indicators. This 
means i
> can count ticks from fifferent stocks while using the SAME 
indicator.
> 
>     Hope this helps,
> 
>     herman.
> 
> 
> 
> 
> 
>      -----Original Message-----
>     From: Ara Kaloustian [mailto:ara1@x...]
>     Sent: Sunday, August 08, 2004 8:46 PM
>     To: AB-Main
>     Subject: [amibroker] Static Variables
> 
> 
> 
>       I am having a hard time using static variables....
> 
>       Sometimes they work as expected ... sometimes they don't ... 
so my
> expectation must obviously be questionable.
> 
>       I am assuming Static variables can be used anywhere that 
normal Number
> and String variables can be used!
> 
>       - in assignments: StaticVarSet("Var",Value);
>       - in If Statements: if (StaticVarGet("Var") == Value) ....
>       - in iif Statement: Test = iif(StaticVarGet("Var")
> ==Value,True,False);
> 
>       Is my assumption correct?
> 
>       Thanks
> 
>       Ara
> 
> 
>       Check AmiBroker web page at:
>       http://www.amibroker.com/
> 
>       Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
> 
> 
> 
>       Check AmiBroker web page at:
>       http://www.amibroker.com/
> 
>       Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
> 
> 
> 
> 
>   Check AmiBroker web page at:
>   http://www.amibroker.com/
> 
>   Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
> 
>         Yahoo! Groups Sponsor
>               ADVERTISEMENT
> 
> 
> 
> 
> 
> -------------------------------------------------------------------
---------
> --
>   Yahoo! Groups Links
> 
>     a.. To visit your group on the web, go to:
>     http://groups.yahoo.com/group/amibroker/
> 
>     b.. To unsubscribe from this group, send an email to:
>     amibroker-unsubscribe@xxxxxxxxxxxxxxx
> 
>     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms 
of Service.



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

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