PureBytes Links
Trading Reference Links
|
Hi Dimitris,
You are right. I was really just adding it for
purposes of demonstrating how to assign global
variables within a function. Typically the variable
would be a counter or similar, and no question there
is no added value in nesting the variables for this
particular example.
I guess I should've given a better example, but too
lazy : )
Regards,
Gary
--- DIMITRIS TSOKAKIS <TSOKAKIS@xxxxxxxxx> wrote:
> Gary,
> It is more simple to have
>
> function CloseLenBarsAgo(Len)
> {
> CloseAgo = Ref(C, -Len);
> return CloseAgo;
> }
> Len=1;
> MyClose = CloseLenBarsAgo(Len);
> HighAgo = Ref(H, -Len);
> LowAgo = Ref(L, -Len);
>
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "Gary A.
> Serkhoshian"
> <serkhoshian777@xxxx> wrote:
> > Hi Dimitris,
> >
> > Thanks for looking at my code. I ran the code
> with
> > your suggestion (as listed below), but am getting
> an
> > error than Len is not initialized for HighAgo and
> > LowAgo. This is most likely due to the fact that
> Len
> > is a local variable to the function.
> >
> > Consequently, the only way to use the code as
> written
> > is to nest the HighAgo and LowAgo variables back
> in
> > the function and declare them as global for
> further
> > use.
> >
> > Regards,
> > Gary
> >
> > //Code below as suggested. Does not work due to
> Len
> > no t initialized for HighAgo and LowAgo as the
> > variable is local to the function.
> >
> > function CloseLenBarsAgo(Len)
> > {
> > CloseAgo = Ref(C, -Len);
> > return CloseAgo;
> > }
> >
> > MyClose = CloseLenBarsAgo(1);
> > HighAgo = Ref(H, -Len);
> > LowAgo = Ref(L, -Len);
> >
> > Filter = 1;
> >
> > AddColumn(C, "Close", 5.2);
> > AddColumn(MyClose, "My Close Ago", 5.2);
> > AddColumn(HighAgo, "My High Ago", 5.2);
> > AddColumn(LowAgo, "My Low Ago", 5.2);
> >
> >
> > --- DIMITRIS TSOKAKIS <TSOKAKIS@xxxx> wrote:
> > > Gary,
> > > Your code does not mean you take HiAgo or LowAgo
> > > through the function
> > > () return .
> > > It would be equivalent [and more simple] to
> write
> > >
> > > function CloseLenBarsAgo(Len)
> > > {
> > > CloseAgo = Ref(C, -Len);
> > > return CloseAgo;
> > > }
> > > HighAgo = Ref(H, -Len);
> > > LowAgo = Ref(L, -Len);
> > >
> > > There is no reason to hide HighAgo inside the
> > > {}+declare it as
> > > global, in order to have access to HighAgo.
> > > Dimitris Tsokakis
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Gary A.
> > > Serkhoshian"
> > > <serkhoshian777@xxxx> wrote:
> > > > Hi Graham,
> > > >
> > > > Actually functions can return has many
> variables
> > > as
> > > > you specify. You do this by assigning
> variables
> > > as
> > > > global. If you assign no variables as global,
> > > then
> > > > only one variable is returned.
> > > >
> > > > For example:
> > > >
> > > > function CloseLenBarsAgo(Len)
> > > > {
> > > > global HighAgo;
> > > > global LowAgo;
> > > >
> > > > CloseAgo = Ref(C, -Len);
> > > > HighAgo = Ref(H, -Len);
> > > > LowAgo = Ref(L, -Len);
> > > >
> > > > return CloseAgo;
> > > > }
> > > >
> > > > In this case, the function returns CloseAgo,
> but
> > > you
> > > > can also access the variables HighAgo and
> LowAgo
> > > as
> > > > you have defined them as global. Of course,
> in
> > > your
> > > > code you must make sure not to use those
> variable
> > > > names again since they are no longer localized
> to
> > > the
> > > > function in question.
> > > >
> > > > Regards,
> > > > Gary
> > > >
> > > > --- Graham <gkavanagh@xxxx> wrote:
> > > > > From my understanding and efforts Functions
> can
> > > only
> > > > > return a single
> > > > > variable output.
> > > > >
> > > > >
> > > > >
> > > > > Cheers,
> > > > > Graham
> > > > > http://e-wire.net.au/~eb_kavan/
> > > > >
> > > > > -----Original Message-----
> > > > > From: Herman van den Bergen
> [mailto:psytek@x...]
> > > > >
> > > > > Sent: Tuesday, May 11, 2004 5:42 AM
> > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > > Subject: RE: [amibroker] Is it possible to
> > > reference
> > > > > a custom formula?
> > > > >
> > > > >
> > > > >
> > > > > Hi Stephane,
> > > > >
> > > > >
> > > > >
> > > > > You are probably right, however #Include
> files
> > > > > cannot be nested in AB
> > > > > however since functions can be nested to
> > > unlimited
> > > > > depth, functions would
> > > > > offer the solution. I guess there are
> preferred
> > > uses
> > > > > for each :-)
> > > > >
> > > > >
> > > > >
> > > > > best regards,
> > > > >
> > > > > herman
> > > > >
> > > > > -----Original Message-----
> > > > > From: Stephane Carrasset
> > > > > [mailto:s.carrasset@x...]
> > > > > Sent: Monday, May 10, 2004 5:23 PM
> > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > > Subject: Re: [amibroker] Is it possible to
> > > reference
> > > > > a custom formula?
> > > > > Importance: High
> > > > >
> > > > > Herman, I think the #include is the function
> <=>
> > > Fml
> > > > > ( "MySingapore") of MS
> > > > >
> > > > > But I don't know ( and never try it) to
> write
> > > many #
> > > > > include in Ami
> > > > >
> > > > >
> > > > >
> > > > > Stephane
> > > > >
> > > > > ----- Original Message -----
> > > > >
> > > > > From: Herman van den Bergen
> <mailto:psytek@x...>
> > > > >
> > > > >
> > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > >
> > > > > Sent: Monday, May 10, 2004 11:07 PM
> > > > >
> > > > > Subject: RE: [amibroker] Is it possible to
> > > reference
> > > > > a custom formula?
> > > > >
> > > > >
> > > > >
> > > > > Look up functions, unlimited nesting is
> allowed.
> > > > >
> > > > >
> > > > >
> > > > > herman
> > > > >
> > > > >
> > > > >
> > > > > -----Original Message-----
> > > > > From: alan_davidson2
> > > > > [mailto:alan_davidson2@x...]
> > > > > Sent: Monday, May 10, 2004 5:26 AM
> > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > > Subject: [amibroker] Is it possible to
> reference
> > > a
> > > > > custom formula?
> > > > >
> > > > > Is it possible to reference one custom
> formula
> > > from
> > > > > within another?
> > > > >
> > > > > In Metastock this would be done by:
> > > > >
> > > > > Fml("MyFormula")
> > > > >
> > > > > and
> > > > >
> > > > > FmlVar("MyFormula","MyVariable").
> > > > >
> > > > > Regards,
> > > > > Alan
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Send BUG REPORTS to bugs@xxxx
> > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > -----------------------------------------
> > > > > Post AmiQuote-related messages ONLY to:
> > > > > amiquote@xxxxxxxxxxxxxxx
> > > > > (Web page:
> > > > >
> > >
> http://groups.yahoo.com/group/amiquote/messages/)
> > > > > --------------------------------------------
> > > > > Check group FAQ at:
> > > > >
> > > >
> > >
> >
>
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Send BUG REPORTS to bugs@xxxx
> > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > -----------------------------------------
> > > > > Post AmiQuote-related messages ONLY to:
> > > > > amiquote@xxxxxxxxxxxxxxx
> > > > > (Web page:
> > > > >
> > >
> http://groups.yahoo.com/group/amiquote/messages/)
> > > > > --------------------------------------------
> > > > > Check group FAQ at:
> > > > >
> > > >
> > >
> >
>
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > __________ NOD32 1.754 (20040509)
> Information
> > > > > __________
> > > > >
> > > > > This message was checked by NOD32 antivirus
> > > system.
> > > > > http://www.nod32.com
> > > > >
> > > > >
> > > > >
> > > > > Send BUG REPORTS to bugs@xxxx
> > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > -----------------------------------------
> > > > > Post AmiQuote-related messages ONLY to:
> > > > > amiquote@xxxxxxxxxxxxxxx
> > > > > (Web page:
> > > > >
> > >
> http://groups.yahoo.com/group/amiquote/messages/)
> > > > > --------------------------------------------
> > > > > Check group FAQ at:
> > > > >
> > > >
> > >
> >
>
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Send BUG REPORTS to bugs@xxxx
> > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > -----------------------------------------
> > > > > Post AmiQuote-related messages ONLY to:
> > > > > amiquote@xxxxxxxxxxxxxxx
> > > > > (Web page:
> > > > >
> > >
> http://groups.yahoo.com/group/amiquote/messages/)
> > > > > --------------------------------------------
> > > > > Check group FAQ at:
> > > > >
> > > >
> > >
> >
>
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Yahoo! Groups Sponsor
> > > > >
> > > > >
> > > > >
> > > > > ADVERTISEMENT
> > > > >
> > > > >
> > > >
> > >
> >
>
<http://rd.yahoo.com/SIG=12944n0dt/M=285832.4851039.5997748.1269404/D=
> > > groups
> > > > >
> > > >
> > >
> >
>
/S=1705632198:HM/EXP=1084311732/A=2105440/R=0/SIG=14dpdlr1u/*http:/w
> > > ww.house
> > > > >
> > > > holdfinance.com/ln/TrackingServlet?
> > > cmd_MediaCode=&fc=APS&mkt=000&mc=01PSYAYA
> > > > >
> 004001B220000U0300L0010000000000&dest=HOME_PAGE>
> > > > > click here
> > > > >
> > > > >
> > > > >
> > > > >
> > > > <http://us.adserver.yahoo.com/l?
> > > M=285832.4851039.5997748.1269404/D=groups/S=
> > > > > :HM/A=2105440/rand=847476230>
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > _____
> > > > >
> > > > >
> > > > > 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
> > > > >
> > > >
> > >
> >
>
<mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
> > > > >
> > > > >
> > > > >
> > > > > * Your use of Yahoo! Groups is
> subject
> > > to
> > > > > the Yahoo! Terms of
> > > > > Service <http://docs.yahoo.com/info/terms/>
> .
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > __________________________________
> > > > Do you Yahoo!?
> > > > Win a $20,000 Career Makeover at Yahoo!
> HotJobs
> > > >
> > >
> http://hotjobs.sweepstakes.yahoo.com/careermakeover
> > >
> > >
> >
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Win a $20,000 Career Makeover at Yahoo! HotJobs
> >
> http://hotjobs.sweepstakes.yahoo.com/careermakeover
>
>
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
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/
|