Marcin provided a methodology for this. i have not tried it but will probably
do this weekend. if anyone wants to try, here is the note.
The way I see it would be to have 2 nested loops, where you go (backwards, from
the last quotation):
1) main loop iterates bar-by-bar and writes Currently processed bar's close to
a custom array.
2) then internal loop starts and picks only previous DAILY values to i-1, i-2
cells of the custom array (as far as lookback-periods are required for your
indicator).
3) once you have the necessary bars - calculate your indicator based on such
input array (wiht regular AFL function)
4) write i-th value of your indicator into the final array that you will use.
That doesn't seem to be very effective procedure (as in step 3 you will be
calling array-function - as many times as you have bars), so probably you would
need to use AddToComposite to store results of such calculations for each
symbol (otherwise the backtests could be pretty slow).
I've tried to code it now and quick test shows that it works fine for 3-day MA
(I've spot-checked it with BAR REPLAY), but please test it thoroughly.
Note that such kind of support is far outside of regular support, so you will
have to adjust the code for your needs yourself (I left _TRACE calls in case
you wanted to do some debugging) and I haven't been testing that throughly (but
at a glance it seems fine).
dn = DateNum();
bi = BarIndex();
LastBarOfTheDay = dn != Ref( dn, 1);
myDailyARRAY = Null;
finalArray = 0;
Lookback = 4;
Counter = 0;
for( i = BarCount-1; i > Lookback; i--)
{
// _TRACE("------------------------------");
// _TRACE("bar: " +NumToStr(bi[ i ],1) );
myDailyARRAY[ i ] = Close[ i ];
// _TRACE("myDailyARRAY[ i ]" +NumToStr(myDailyARRAY[ i ] ) );
// _TRACE("-----internal loop");
for( j=i; j >=0; j--)
{
// _TRACE("counter: " +NumToStr(Counter,1) );
if( LastBarOfTheDay[ j ] )
{
myDailyARRAY[ i-Counter-1 ] = Close[ j ];
Counter++;
// _TRACE("myDailyARRAY[ i-Counter ]" +NumToStr(Close[ j ] ) );
}
if( Counter > Lookback )
{
// _TRACE("-----internal loop break <<<<<");
Counter = 0;
break;
}
}
myMA = MA(myDailyARRAY, 3);
finalArray[ i ] = myMA[ i ];
}
//AddToComposite(finalArray, "~myComp_"+Name(), "X");
Filter = 1;
AddColumn( finalarray, "array");
Best regards
Marcin Gorzynski
Amibroker.com Technical Support
--- In [email protected], "murthysuresh" <mo...@...> wrote:
>
> http://finance.groups.yahoo.com/group/amibroker/message/138628
> according to ab support, its not part of thier regular support to provide an
> example on how this can be done.
>
>
> --- In [email protected], "murthysuresh" <money@> wrote:
> >
> > let me know when you find a way to do it. check my earlier posts on the
> > same issue.
> > you can only access H and L bars dailybars from intraday. You cannot access
> > any of the daily indicators intraday in your backtesting.
> >
> >
> > --- In [email protected], "nizar.mahri@" <nizar.mahri@> wrote:
> > >
> > > Hi,
> > >
> > > I currently have my system set up as below.
> > > The way its set up is as an EOD system.
> > >
> > > Now I want to modify it to have intraday entries.
> > > So as soon as todays bar meets the system entry criteria (in terms of
> > > price% change, volume, and liquidity) then enter immediately (ie. don't
> > > wait for the close).
> > >
> > > How would i do that?
> > >
> > > Thanks.
> > >
> > > Nizar.
> > >
> > > settradedelays( 1, 1, 1, 1 );
> > >
> > > LBP = Param("ATR Look Back", 10, 5, 50, 1);;
> > > Multi = Param("ATR Multiple", 2, 1, 5, 0.1);;
> > > Pr = Close;
> > > AT = ATR(LBP);
> > >
> > > Entry1 = Indicator1;
> > > Entry2 = Indicator2;
> > > Entry3 = Indicator3;
> > > Entry4 = Indicator4;
> > > Entry5 = Indicator5;
> > >
> > > Buy = Entry1 && Entry2 && Entry3 && Entry4 && Entry5;
> > > BuyPrice = Open;
> > > trailARRAY = Null;
> > > trailstop = 0;
> > > Longtriggerbar = 0;
> > >
> > > for( i = 1; i < BarCount; i++ )
> > > {
> > >
> > > if( trailstop == 0 AND Buy[ i ] )
> > > {
> > > trailstop = Pr[ i ] - Multi * AT[i];
> > > Longtriggerbar = i;
> > > }
> > > else Buy[ i ] = 0; // remove excess buy signals
> > >
> > > if( trailstop > 0 AND Low[ i ] < trailstop and i != Longtriggerbar)
> > > {
> > > Sell[ i ] = 1;
> > > SellPrice[ i ] = trailstop;
> > > trailstop = 0;
> > > }
> > >
> > > if( trailstop > 0 )
> > > {
> > > trailstop = Max( Pr[ i ] - Multi * AT [i], trailstop );
> > > trailARRAY[ i ] = trailstop;
> > > }
> > >
> > > }
> > >
> > >
> > > Plot( Close,"Price",colorBlack,styleBar);
> > > Plot( trailARRAY,"trailing stop level", colorRed );
> > >
> > > // Rank trades according to ATR if insufficient capital
> > >
> > > PositionScore = 100-ATR(10);
> > >
> > > // Divide capital into 4 positions
> > > // Plot equity chart
> > >
> > > NumPos = 4;
> > > SetOption("MaxOpenPositions",NumPos);
> > > PositionSize = -100/NumPos;
> > >
> > > Plot(C,"C",colorBlack,styleCandle);
> > > e = Equity();
> > > Plot(e,"Equity",colorGreen,styleLine | styleOwnScale);
> > >
> >
>