Hello everyone, I haven't found this exact topic on the forum yet, so I'm creating a new post. If this question has already been answered, feel free to point me in the right direction.
I'm backtesting some small cap penny stocks on 30 min bars and some of them have very low volume. The best I can tell is that a BUY quantity is only valid for a single bar, not like a broker where a limit order keeps getting filled until the total requested volume is reached. Is that correct?
It seems that if I want to fill 1% of equity and there is not enough volume to do so on a single bar, the only way to I can figure out to be able to check position size vs. amount of equity for the next bar's purchase is with a low-level CBT looping across all the bars. Is there a more efficient way, or am I missing something? I'm backtesting across 1000 symbols, 30 min bars and about 2 years of historical data.
@empottasch Thank you for the quick response!! Yes, I specifically have the Disable trade size limit turned off and % of entry bar volume set at 30% (I have played around with different percentages, but I want to be conservative) to produce a more realistic backtest. I originally had the box checked and % set to zero and I received amazing, unrealistic results.
I'm just trying to confirm that a BUY and the BUY quantity is only valid on the first bar it executes on, or not as I'm newer to AFL.
if I understand you correctly the backtester does not consider filling the entire order in later bars. It only considers those bars where the Buy array is 1. In the basic setup.
I guess you could program it in such a way that the order is filled in total in later bars, if the volume and price permits it to be filled. But indeed that would require more complex coding imo.
I had found that page previously, and almost started using the final example with the for/next loop + if/then trees. I have two questions to help me understand better:
#1 Is this method of looping is more or less efficient than doing something similar in low level CBT? Each security in my backtest gets weighted based on filters, so some might be 1% of equity, others 2%, other 0.2%, so my "SetPositionSize( 50, spsPercentOfEquity)"; statement would have to be inside the if/then statements.
#2 Just to CONFIRM as I am newer to AFL, sigScaleIn will STOP SCALING in by itself when I get to the SetPositionSize(1, spsPercentOfEquity)? Or do I need to custom calculate each incremental add?
FInally, warning received regarding illiquid stocks, thank you!