PureBytes Links
Trading Reference Links
|
Do you mean one trade a day per symbol, or one trade a day across all
symbols?
If it's only per symbol, you could filter out all other trades in the
main AFL code. If it's across all symbols, then I think you'd have to
use the mid-level custom backtester, using a variable to track trades
each day.
For example, in the custom backtester add something like:
dn = DateNum();
newDay = dn != Ref(dn,-1);
hadTradeToday = False;
Then in the loops:
for (i = 0; i < BarCount; i++)
{
if (newDay[i])
hadTradeToday = False;
for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
{
if (sig.IsEntry() && sig.IsLong())
{
if (hadTradeToday)
sig.PosSize = 0;
else
hadTradeToday = True;
}
}
bo.ProcessTradeSignals(i);
}
This code (which is not a complete custom backtest procedure, and I
haven't tested) sets "hadTradeToday" on the very first entry of a day
and then sets the position size to zero for all subsequent entries on
the same day. The "hadTradeToday" flag is reset on the first bar of
each new day.
The code as written also assumes there aren't any other reasons within
the custom backtester for a valid entry to be rejected, otherwise
"hadTradeToday" would need to be set only when the entry was
definitely being taken.
Regards,
GP
--- In amibroker@xxxxxxxxxxxxxxx, "marc.sterling" <marc.sterling@xxx>
wrote:
>
> I have been having a bozo attack for five days - trying to code a
way to limit a trade entry to
> one per day on backtesting.
>
> I am running a back test on minute bars, I enter a trade when my
conditions are met... an
> hour os so later, the trade is stopped out as a loss when the trade
goes against me. The
> backtester then enters a second trade as the conditions are met again...
>
> I have been trying to code a way for it to enter no more than one
trade in a day - and getting
> nowhere... everything I try fails. (Serious Bozo attack)
>
> Does anybody have a simple approach to this problem. I am totally
locked out of solutions...
>
> Thanks
>
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:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|