Hello Ken,
> Take a Buy and Sell signal, and collect the closing prices of the
current symbol ONLY WHEN the buy signal is in effect.
This is what should do the following piece of code, since as far as I
know, all arrays must be the same size in AFL, null-valued cells are
inserted at the beginning (could be at the end also). I hope to have
correctly understood what you want to do : )
Best regards, Nicolas
----
if (Name()=="AA") {
Buy = Cross(MA(C,5),MA(C,12));
Sell = Cross(MA(C,15),MA(C,5));
EMPTY_VAL = -1e10;
nbBuy = 0;
// count the number of cells where Buy[i]=true and
// save corresponding closing price values.
for (i=0;i<BarCount;i++) {
if (Buy[i]==True) {
tmpArray[nbBuy] = Close[i];
nbBuy++;
}
}
// construct the resulting array which is a concatenation of "empty"
cells plus saved prices.
Cpt=0;
for (i=0;i<BarCount;i++) {
if (i<BarCount-nbBuy) {
result[i] = EMPTY_VAL;
} else {
result[i] = tmpArray[Cpt];
Cpt++;
}
}
fh = fopen( "c:\\temp\\myfile.txt", "w");
tmp = StrFormat("%g %g %g\n",nbBuy,BarCount - nbBuy,Cpt);
fputs(tmp,fh);
for (i=0;i<BarCount;i++) {
tmp = StrFormat("%g %f %f %g\n",i, Close[i], result[i],
Buy[i]);
fputs(tmp,fh);
}
fclose(fh);
}
--- In [email protected], "Ken Close" <[EMAIL PROTECTED]> wrote:
>
> Is it possible to create an array that has a different number of
bars than
> the total bars in a test period?
>
> I want to take the equity line (or price line) and "assemble" an
array of
> the close values only when a buy signal is in effect.
>
> Take a Buy and Sell signal, and collect the closing prices of the
current
> symbol ONLY WHEN the buy signal is in effect.
>
> Assume further that over a 1000 bar backtest, the Buy signal is on
for 600
> bars and the Sell signal is on for 400 bars. The total number of
bars in
> the test is 1000.
>
> How can one "stack up" the buy periods so they are "end to end"
rather than
> being interspersed with Sell periods?
>
> The resulting "During Buy" array would only have 600 bars.
>
> All I can think of (conceptually) is manipulation of bar numbers and
> addition of the bar number only when the Buy signal is on.
>
> Is any of this possible?
>
> Thanks for any comment.
>
> Ken
>
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/