Hi Mike, and thanks for taking the time to answer my questions and steer me in
the right direction. I have read the links you provided. I had already read a
couple of them but a more careful reading was clearly beneficial.
> I suspect that the lack of response is due to the fact that your post seems
> to span multiple areas of expertise. The scenarios of your questions suggest
> real time live trading. Yet, the questions themselves are phrased as
> backtesting.
>
Mmmm... yes, it appears I was a little clumsy in my explanations. Let me
clarify: initially, I am interested in Amibroker only as a backtesting
platform. I want to use it to develop/backtest/optimize my trading systems,
which I use for forex trading. I trade them live using a different platform
(MT4) which doesn't meet my backtesting needs anymore. For the time being I'll
keep on using it for live trading, but I clearly need something more capable
for system development.
Anyway, regarding some of my questions, I'll follow your advice and try to be
more clear and break them into smaller chunks.
> AmiBroker backtesting operates on a predefined range of fixed bars, first
> generating signals simultaneously for all bars (array manipulations dictated
> by your script), then linearly iterating over the bars to sort and process
> the signals, applying portfolio management along the way. Details of the
> second phase (sorting/applying of signals) are largely hidden from user,
> treated as a black box (though user is free to override all behavior).
>
Ok... If I understand it correctly it will work like this: I have my whole
price history stored in a number of linear arrays, each one containing a
feature of the bars (open, close, high, low...). The first element of the
"close" array (index 0) is the closing price of my oldest bar. The last element
of the "close" array (index N-1 if I have N bars) is the closing price of my
last (most recent) bar. This is clear enough.
Now I start the backtest, and my first questions.
1) We get to the first bar. All the code of my script is executed for the
prices corresponding to this bar to check whether any buy/sell conditions are
verified, etc. When we go to the next bar, my code will be executed again for
that bar. And so on and so forth. My script is executed for each new bar the
backtester runs through. Is that correct?
2) The amibroker functions in my script that don't need a specific bar index as
an input always refer to the current bar in the iteration. Correct? (I realize
there are also functions like moving averages that require to look back a
number of bars, and other like "ref" that let you access other bars, I am just
asking whether stuff like "Buy=..." always refers to the current bar).
I think that is enough for now, once I am sure I am getting this right I can
hopefully follow up with more questions ;)
Thanks again!