Why are my AFL Backtest Results limited to 100 Trades Per Day?

I'm backtesting a simple AFL script. I noticed that if I make the trade entry filter too loose that I hit a maximum of 2,200 trades. I'm testing against December of 2025 which had 22 Trading Days. When I look at the results I see that there are exactly 100 trades per day.

I've set Max Open Positions to 1000 in Settings and in the AFL code. I can't seem to find who or what is limiting me to 100 Trades per day.

My test code is below. In it I have commented out the different cumulativeVolume filters. To the right of them in the comment you can see how many Backtest results I got when using that cumulativeVolume filter. As my filter is looser I hit a cap of 2,200 trades. I can see there should be more than 2,200 by using Explore. The code enters all trades on the same minute.

I've searched quite a bit and haven't found anything specific to my issue.

Any ideas on how to increase the 100 trades per day limit would be greatly appreciated!

SetPositionSize(0.001, spsPercentOfEquity);
SetOption("MaxOpenPositions", 1000);
SetBacktestMode(backtestRegularRawMulti);

dn = DateNum();
minutesSincePreOpen = (Hour() * 60 + Minute()) - 240;
firstBarOfNewDay = dn != Ref(dn, -1);
cumulativeVolume = Cum(Volume) - ValueWhen(firstBarOfNewDay || BarIndex() == 0, Cum(Volume) - Volume);

//trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >   10000000; //   148
//trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >    5000000; //   277
//trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >    1000000; //   964
//trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >     950000; //   999
//trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >     750000; //  1223
  trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >     500000; //  1711
//trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >     100000; //  2200
//trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >      10000; //  2200
//trade_signal = minutesSincePreOpen == 329 && cumulativeVolume >       1000; //  2200

trade_exit = BarsSince(trade_signal) >= 90;
trade_exit = ExRem(trade_exit, trade_signal);

PositionScore = cumulativeVolume;
Buy = IIf(trade_signal, 1, 0);
BuyPrice = IIf(trade_signal, Open, 0);
Sell = IIf(trade_exit, 1, 0);
SellPrice = IIf(trade_exit, Open, 0);
Short = 0;
Cover = 0;

Filter = Buy;
AddColumn(cumulativeVolume, "Cum Vol", 1);
AddColumn(minutesSincePreOpen, "minutesSincePreOpen", 1);

For BT debugging, best to upload .APX file instead of AFL as many BT parameters are controlled from the UI settings window.

Thanks! I'm new to AmiBroker and had no idea the apx existed. The forum wont let me upload a file (I'm new), so I've copied the contents of that apx file below.

<?xml version="1.0" encoding="ISO-8859-1"?>
<AmiBroker-Analysis CompactMode="0">
<General>
<FormatVersion>1</FormatVersion>
<Symbol>OPK</Symbol>
<FormulaPath>G:\\momentum-sql\\strategies\\Formula 4.afl</FormulaPath>
<FormulaContent>SetPositionSize(0.001, spsPercentOfEquity);\r\nSetOption("MaxOpenPositions", 1000);\r\nSetBacktestMode(backtestRegularRawMulti);\r\n\r\ndn = DateNum();\r\nminutesSincePreOpen = (Hour() * 60 + Minute()) - 240;\r\nfirstBarOfNewDay = dn != Ref(dn, -1);\r\ncumulativeVolume = Cum(Volume) - ValueWhen(firstBarOfNewDay || BarIndex() == 0, Cum(Volume) - Volume);\r\n\r\n//trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;   10000000; //   148\r\n//trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;    5000000; //   277\r\n//trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;    1000000; //   964\r\n//trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;     950000; //   999\r\n//trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;     750000; //  1223\r\n//trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;     500000; //  1711\r\n  trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;     100000; //  2200\r\n//trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;      10000; //  2200\r\n//trade_signal = minutesSincePreOpen == 329 &amp;&amp; cumulativeVolume &gt;       1000; //  2200\r\n\r\ntrade_exit = BarsSince(trade_signal) &gt;= 90;\r\ntrade_exit = ExRem(trade_exit, trade_signal);\r\n\r\nPositionScore = cumulativeVolume;\r\nBuy = IIf(trade_signal, 1, 0);\r\nBuyPrice = IIf(trade_signal, Open, 0);\r\nSell = IIf(trade_exit, 1, 0);\r\nSellPrice = IIf(trade_exit, Open, 0);\r\nShort = 0;\r\nCover = 0;\r\n\r\nFilter = Buy;\r\nAddColumn(cumulativeVolume, "Cum Vol", 1);\r\nAddColumn(minutesSincePreOpen, "minutesSincePreOpen", 1);\r\n</FormulaContent>
<ApplyTo>0</ApplyTo>
<RangeType>0</RangeType>
<RangeAmount>1</RangeAmount>
<FromDate>2025-12-01 00:00:00</FromDate>
<ToDate>2025-12-31</ToDate>
<OnSelectAction>7</OnSelectAction>
<RunEvery>0</RunEvery>
<RunEveryInterval>5min</RunEveryInterval>
<IncludeFilter>
<ExcludeMode>0</ExcludeMode>
<OrSelection>0</OrSelection>
<Favourite>0</Favourite>
<Index>0</Index>
<Type0>0</Type0>
<Category0>-1</Category0>
<Type1>1</Type1>
<Category1>-1</Category1>
<Type2>2</Type2>
<Category2>-1</Category2>
<Type3>3</Type3>
<Category3>-1</Category3>
<Type4>4</Type4>
<Category4>-1</Category4>
<Type5>5</Type5>
<Category5>-1</Category5>
<Type6>6</Type6>
<Category6>-1</Category6>
</IncludeFilter>
<ExcludeFilter>
<ExcludeMode>1</ExcludeMode>
<OrSelection>0</OrSelection>
<Favourite>0</Favourite>
<Index>0</Index>
<Type0>0</Type0>
<Category0>-1</Category0>
<Type1>1</Type1>
<Category1>-1</Category1>
<Type2>2</Type2>
<Category2>-1</Category2>
<Type3>3</Type3>
<Category3>-1</Category3>
<Type4>4</Type4>
<Category4>-1</Category4>
<Type5>5</Type5>
<Category5>-1</Category5>
<Type6>6</Type6>
<Category6>-1</Category6>
</ExcludeFilter>
</General>
<BacktestSettings>
<InitialEquity>1e+07</InitialEquity>
<TradeFlags>3</TradeFlags>
<MaxLossStopMode>0</MaxLossStopMode>
<MaxLossStopValue>0</MaxLossStopValue>
<MaxLossStopAtStop>0</MaxLossStopAtStop>
<ProfitStopMode>0</ProfitStopMode>
<ProfitStopValue>0</ProfitStopValue>
<ProfitStopAtStop>0</ProfitStopAtStop>
<TrailingStopMode>0</TrailingStopMode>
<TrailingStopPeriods>0</TrailingStopPeriods>
<TrailingStopValue>0</TrailingStopValue>
<TrailingStopAtStop>0</TrailingStopAtStop>
<CommissionMode>0</CommissionMode>
<CommissionValue>0</CommissionValue>
<BuyPriceField>0</BuyPriceField>
<BuyDelay>0</BuyDelay>
<SellPriceField>0</SellPriceField>
<SellDelay>0</SellDelay>
<ShortPriceField>0</ShortPriceField>
<ShortDelay>0</ShortDelay>
<CoverPriceField>0</CoverPriceField>
<CoverDelay>0</CoverDelay>
<ReportSystemFormula>0</ReportSystemFormula>
<ReportSystemSettings>0</ReportSystemSettings>
<ReportOverallSummary>1</ReportOverallSummary>
<ReportSummary>1</ReportSummary>
<ReportTradeList>1</ReportTradeList>
<LoadRemainingQuotes>1</LoadRemainingQuotes>
<Periodicity>5</Periodicity>
<InterestRate>0</InterestRate>
<ReportOutPositions>1</ReportOutPositions>
<UseConstantPriceArrays>0</UseConstantPriceArrays>
<PointsOnlyTest>0</PointsOnlyTest>
<AllowShrinkingPosition>0</AllowShrinkingPosition>
<RangeType>0</RangeType>
<RangeLength>0</RangeLength>
<RangeFromDate>2025-12-01 00:00:00</RangeFromDate>
<RangeToDate>2025-12-31</RangeToDate>
<ApplyTo>0</ApplyTo>
<FilterQty>2</FilterQty>
<IncludeFilter>
<ExcludeMode>0</ExcludeMode>
<OrSelection>0</OrSelection>
<Favourite>0</Favourite>
<Index>0</Index>
<Type0>0</Type0>
<Category0>-1</Category0>
<Type1>1</Type1>
<Category1>-1</Category1>
<Type2>2</Type2>
<Category2>-1</Category2>
<Type3>3</Type3>
<Category3>-1</Category3>
<Type4>4</Type4>
<Category4>-1</Category4>
<Type5>5</Type5>
<Category5>-1</Category5>
<Type6>6</Type6>
<Category6>-1</Category6>
</IncludeFilter>
<ExcludeFilter>
<ExcludeMode>1</ExcludeMode>
<OrSelection>0</OrSelection>
<Favourite>0</Favourite>
<Index>0</Index>
<Type0>0</Type0>
<Category0>-1</Category0>
<Type1>1</Type1>
<Category1>-1</Category1>
<Type2>2</Type2>
<Category2>-1</Category2>
<Type3>3</Type3>
<Category3>-1</Category3>
<Type4>4</Type4>
<Category4>-1</Category4>
<Type5>5</Type5>
<Category5>-1</Category5>
<Type6>6</Type6>
<Category6>-1</Category6>
</ExcludeFilter>
<UseOptimizedEvaluation>0</UseOptimizedEvaluation>
<BacktestRangeType>0</BacktestRangeType>
<BacktestRangeLength>0</BacktestRangeLength>
<BacktestRangeFromDate>2025-12-01 00:00:00</BacktestRangeFromDate>
<BacktestRangeToDate>2025-12-31</BacktestRangeToDate>
<MarginRequirement>1</MarginRequirement>
<SameDayStops>0</SameDayStops>
<RoundLotSize>0</RoundLotSize>
<TickSize>0</TickSize>
<DrawdownPriceField>0</DrawdownPriceField>
<ReverseSignalForcesExit>1</ReverseSignalForcesExit>
<NoDefaultColumns>0</NoDefaultColumns>
<AllowSameBarExit>1</AllowSameBarExit>
<ExtensiveOptimizationWarning>1</ExtensiveOptimizationWarning>
<WaitForBackfill>0</WaitForBackfill>
<MaxRanked>4</MaxRanked>
<MaxTraded>1000</MaxTraded>
<MaxEntryRank>100</MaxEntryRank>
<PortfolioReportMode>0</PortfolioReportMode>
<MinShares>0.01</MinShares>
<SharpeRiskFreeReturn>5</SharpeRiskFreeReturn>
<PortfolioMode>0</PortfolioMode>
<PriceBoundCheck>1</PriceBoundCheck>
<AlignToReferenceSymbol>0</AlignToReferenceSymbol>
<ReferenceSymbol>^DJI</ReferenceSymbol>
<UPIRiskFreeReturn>5.4</UPIRiskFreeReturn>
<NBarStopMode>0</NBarStopMode>
<NBarStopValue>0</NBarStopValue>
<NBarStopReentryDelay>0</NBarStopReentryDelay>
<MaxLossStopReentryDelay>0</MaxLossStopReentryDelay>
<ProfitStopReentryDelay>0</ProfitStopReentryDelay>
<TrailingStopReentryDelay>0</TrailingStopReentryDelay>
<AddFutureBars>0</AddFutureBars>
<DistChartSpacing>5</DistChartSpacing>
<ProfitDistribution>1</ProfitDistribution>
<MAFEDistribution>1</MAFEDistribution>
<IndividualDetailedReports>0</IndividualDetailedReports>
<PortfolioReportTradeList>1</PortfolioReportTradeList>
<LimitTradeSizeAsPctVol>0</LimitTradeSizeAsPctVol>
<DisableSizeLimitWhenVolumeIsZero>1</DisableSizeLimitWhenVolumeIsZero>
<UsePrevBarEquityForPosSizing>0</UsePrevBarEquityForPosSizing>
<NBarStopHasPriority>0</NBarStopHasPriority>
<UseCustomBacktestProc>0</UseCustomBacktestProc>
<CustomBacktestProcFormulaPath/>
<MinPosValue>0</MinPosValue>
<MaxPosValue>0</MaxPosValue>
<ChartInterval>60</ChartInterval>
<DisableRuinStop>0</DisableRuinStop>
<OptTarget>CAR/MDD</OptTarget>
<WFMode>0</WFMode>
<GenerateReport>1</GenerateReport>
<MaxLongPos>0</MaxLongPos>
<MaxShortPos>0</MaxShortPos>
<SeparateLongShortRank>0</SeparateLongShortRank>
<TotalSymbolQty>11742</TotalSymbolQty>
<EnableUserReportCharts>1</EnableUserReportCharts>
<ChartWidth>800</ChartWidth>
<ChartHeight>480</ChartHeight>
<SettlementDelay>0</SettlementDelay>
<PortfolioReportSystemFormula>1</PortfolioReportSystemFormula>
<InterestRateSymbol/>
<MarginRate>0</MarginRate>
<IncludeBHStats>1</IncludeBHStats>
<BHSymbol>^DJI</BHSymbol>
<MCEnable>1</MCEnable>
<MCRuns>1000</MCRuns>
<MCPosSizeMethod>0</MCPosSizeMethod>
<MCPosSizeShares>100</MCPosSizeShares>
<MCPosSizeValue>1000</MCPosSizeValue>
<MCPosSizePctEquity>5</MCPosSizePctEquity>
<MCChartEquityCurves>1</MCChartEquityCurves>
<MCStrawBroomLines>0</MCStrawBroomLines>
<Scenario>0</Scenario>
<MCChartEquityScale>0</MCChartEquityScale>
<MCUseEquityChanges>0</MCUseEquityChanges>
<MCLogScaleFinalEquity>0</MCLogScaleFinalEquity>
<MCLogScaleDrawdown>0</MCLogScaleDrawdown>
<MCNegativeDrawdown>1</MCNegativeDrawdown>
<ISEnabled>1</ISEnabled>
<ISStartDate>2000-01-01</ISStartDate>
<ISEndDate>2004-01-01</ISEndDate>
<ISLastDate>2020-01-01</ISLastDate>
<ISStep>1</ISStep>
<ISStepUnit>3</ISStepUnit>
<ISAnchored>0</ISAnchored>
<ISLastUsesToday>1</ISLastUsesToday>
<OSEnabled>1</OSEnabled>
<OSStartDate>2004-01-01</OSStartDate>
<OSEndDate>2005-01-01</OSEndDate>
<OSLastDate>2021-01-01</OSLastDate>
<OSStep>1</OSStep>
<OSStepUnit>3</OSStepUnit>
<OSAnchored>0</OSAnchored>
<OSLastUsesToday>1</OSLastUsesToday>
<ExportCSVIncFormula>0</ExportCSVIncFormula>
</BacktestSettings>
</AmiBroker-Analysis>

Try your tests again and see if you missed the settings in
Portfolio tab>Limit trade size as % of entry bar volume

default is 10%, 0 means no limit


Here is a screenshot of my Portfolio tab settings.
I also tried changing the "Limit trade size as % of entry bar volume" setting to 100 and to 0.00001. In both cases the backtest results do not exceed 2,200. I've changed it back to 0 and am still getting 2,200.

how many total symbols are there under the portfolio BT?

There is a policy that it might be hitting, AmiBroker stores only (2*MaxOpenPositions) top-ranked entry signals per bar ~2K(you set 1000) but I am not certain if this it.

There are 543 unique symbols in the backtest results.
Here is a dropbox link to the csv backtest results.

I am running a licensed version of AmiBroker:
PROFESSIONAL EDITION (64-bit)
(Version 7.00.1, Build date: Dec 22 2025)

SetPositionSize(0.001, spsPercentOfEquity);
this was also suspicious, it may not be enough to trade larger stocks by $ value
(edit: ok i see you kept min shares as 0.1) which could trade more stocks

I've tested with another afl script. If I buy at different times, one trade per symbol per day, I can get more than 100 trades per day. I only hit the 100 limit when all of my entries are at the same Minute of the day.

The best I can tell, AmiBroker has an internal limit of 100 Trade Entries at the same Minute/Time, assuming 1 trade per symbol.

Can anyone prove my conclusion is incorrect?

I have never seen a β€œ100 entry signals per bar” limit documented anywhere, so I think @Tomasz would have to speak to whether or not that is the case.

No it doesn't have such limit. As always use Detailed Mode so report will tell you when and why trades are not entered.

1 Like

Hmm, I can't reproduce the behavior anymore. The only new things I did since I was able to reproduce it last were reset my entire windows machine (I usually go weeks without restarting) and run the Detailed Log. When looking at the Detailed Log I saw it getting into more than 100 trades per day. I then ran the backtest and it returned 5,207. Maybe resetting my machine fixed it? Maybe running the Detailed Log fixed it? Maybe I did something else different that fixed it? I'm at a loss. I wish I knew what caused it.

Either way, thank you so much for all the help! If I run into it again I'll try to pinpoint what fixes it for me and let you know.

Thanks!