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

[amibroker] using global variables in multi-time frame



PureBytes Links

Trading Reference Links

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);

//------------------------------------




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