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 [email protected], "marc.sterling" <[EMAIL PROTECTED]>
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
>


Reply via email to