Cool... it looks like the penny dropped. Everyone that starts with AFL goes through the same experience!!! Just beware that, speaking from my own experience, I thought I'd "got it a few times" and still kept going back to thinking in the iterative bar by bar way... most of the issues I hit with AFL ended up being that error in thinking.
Anyway... honestly I'm not a backtesting expert - more of a live front end expert - I use to AB to day trade real time - executing through my broker. Maybe Mike can help you there on backtesting... But knowing AFL and AB you will a good amount a flexibility as to what executed price you assign in your backtests. First port of call, the help manual, backtesting.... --- In [email protected], "pipadder" <pipad...@...> wrote: > > > > > > > > > > > In answer to your questions... it sounds like you haven't fully grasped the > > main concept of AFL yet... i.e. that it operates on arrays. > > > > Reading the rest of your post... it appears you are right. > > > For example, > > > > Buy = 1; > > > > Sets every element of the Buy array to be 1. > > Now if you said, > > > > Buy = IIf (Cross (TimeNum(), 093000), True, False); > > > > This would set every element of the Buy array (no looping required) to a > > new value based on the outcome of IIf (Cross (TimeNum(), 093000), True, > > False); (the outcome of that is an array itself - not a number). In this > > case it would set every element to zero (false) except those where the > > current time cross 09.30 am... > > > > You just need to play around with it. > > > > Aha... this example helps quite a bit. The script/program is applied > simultaneously to the whole array, not bar by bar. That was what I was > missing. > > Mmmm... the result (in purely numerical terms, not talking about speed) > should of course be the same whether the calculation is simultaneous or > looped, but the type of structure fed to the functions in the script (array > vs. single variable) is not. I guess that'll be the main difference when > programming it. Although if pretty much everything is an array in AFL, even > that should be nearly the same. > > Ok, I'll have to get used to thinking this way when coding, but now I *think* > I understand that. > > The next thing I wonder about are execution prices... if one of the arrays > taking care of order operations (buy/sell/short...) has a "1" for that bar, > at what price is the operation executed by the backtester? Always at the > closing price of the bar? > > Thanks again for your patience :). >
