PureBytes Links
Trading Reference Links
|
Graham,
Thanks for the reply. However, I've used both approaches and there
seems to be no difference. I still get the wrong result from the
"inWeekly" procedure call.
So I tested the general approach with some much simpler code (a couple
of MAs) and all seems to work OK. The logical conclusion therefore is
that the error has something to do with what I'm doing in the "process
some stuff" stage. Quite possible since, as I said before, it's quite
lengthy code. But quite what that problem is has got me stumped...
I'm going to have to re-build the code block-by-block to try and find
out where the problem is. What fun.
Question on your "Method 2" though. Is there any need for the 'global'
definitions inside the procedure when the variables have already been
defined as global (i.e. they were named and initialised outside and
before the procedure)? It makes no difference to my observations with
my code either way, but just curious if there is a best-practice
reason at play there?
Regards,
Andy
--- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxx> wrote:
>
> 2 ways you would need to do this as procedures do not provide any real
> output, only an action
>
> METHOD 1
>
> X =Y = 0; //initialise global variables on first pass through code
>
> procedure Test(TimeFrame)
> {
> TimeFrameSet( Timeframe );
> ...now process some stuff and allocate values to the global
> variables ...
> X = xx;
> Y = yy;
> TimeFrameRestore();
> Plot(TimeFrameExpand(X,Timeframe ,expandLast), "", colorblue);
> Plot(TimeFrameExpand(Y,Timeframe expandLast), "", colorblue);
>
> }
>
> Test(indaily);
> Test(inweekly);
>
>
>
>
> METHOD 2
>
>
> X =Y = 0; //initialise global variables on first pass through code
>
> procedure Test(TimeFrame)
> {
> Global x;
> global y;
> TimeFrameSet( Timeframe );
> ...now process some stuff and allocate values to the global
> variables ...
> X = xx;
> Y = yy;
> TimeFrameRestore();
> }
>
> //now call on the procedure in daily time frame and plot
> Test(inDaily);
> Plot(TimeFrameExpand(X,inDaily,expandLast), "", colorblue);
> Plot(TimeFrameExpand(Y,inDaily,expandLast), "", colorblue);
>
> //now call on the procedure in weekly time frame and plot
> Test(inWeekly);
> Plot(TimeFrameExpand(X,inWeekly,expandLast),"",, "", colorred);
> Plot(TimeFrameExpand(Y,inWeekly,expandLast),"",, "", colorred);
>
>
>
> --
> Cheers
> Graham
> AB-Write >< Professional AFL Writing Service
> Yes, I write AFL code to your requirements
> http://www.aflwriting.com
>
>
> On 05/12/06, andy_davidson_uk1 <AndyDavidson@xxx> wrote:
> >
> > I'm using a procedure to output several global variables. This works
> > fine normally (i.e. all variables are returned OK), but when when
I try
> > to use it in conjunction with multi-time frame analysis I run across
> > problems.
> >
> > A simplified version of the code is shown below. I would copy it
all but
> > there's a lot of lines and I'm sure the "process some stuff" bit
is all
> > working fine anyhow. The problem is that (on an EOD chart) the daily
> > plots are fine, but the expanded weekly TF plots are not. Variables X
> > and Y are unchanged by the second procedure call...i.e. they are the
> > same *values* as discovered in the daily time frame - only
expanded to a
> > weekly plot. If I switch the chart to a weekly plot I get
> > differing values for the X and Y variables, so there is no doubt that
> > this is plotting incorrectly.
> >
> > In the full code there are a lot more than just two variables returned
> > by the procedure, so I need to get this sorted to avoid getting
> > unecessarily messy.
> >
> > The basic logic looks fine to me. Grateful if someone could point out
> > what I'm missing,
> > TIA
> > Andy
> >
> > //-----------------------------
> > X =Y = 0; //initialise global variables on first pass through code
> >
> > procedure Test(TimeFrame)
> > {
> > TimeFrameSet( Timeframe );
> > ...now process some stuff and allocate values to the global
> > variables ...
> > X = xx;
> > Y = yy;
> > TimeFrameRestore();
> > }
> >
> > //now call on the procedure in daily time frame and plot
> > Test(inDaily);
> > Plot(TimeFrameExpand(X,inDaily,expandLast), "", colorblue);
> > Plot(TimeFrameExpand(Y,inDaily,expandLast), "", colorblue);
> >
> > //now call on the procedure in weekly time frame and plot
> > Test(inWeekly);
> > Plot(TimeFrameExpand(X,inWeekly,expandLast),"",, "", colorred);
> > Plot(TimeFrameExpand(Y,inWeekly,expandLast),"",, "", colorred);
> >
> > //------------------------------------
> >
> >
> >
> >
> >
> > 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
> >
> >
> >
> >
>
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.9/573 - Release Date: 12/5/2006 4:07 PM
|