Yes, your script will be executed multiple times, for multiple purposes. Including: chart updates, exploration, backtesting, etc. AmiBroker uses what it needs for each purpose.
You can add a _TRACE statement to your script and look at the Log window to see exactly how frequently your script is being rerun. http://www.amibroker.com/guide/afl/afl_view.php?id=222 Print the Status of "action" or "actionEx" if you want to see the reason for each execution. http://www.amibroker.com/guide/afl/afl_view.php?id=141 Mike --- In [email protected], "Ronen" <ronen.ma...@...> wrote: > > Hi Brent > > I read it again. > > Are you saying that the file gets called twice? The first time "action" does > not equal portfolio and so it skips that section and then hits the portion > that creates the trading signals. Then gets called a second time when > "action" does equal portfolio and then the 2nd phase gets executed. > > I guess that would make sense based on this part of the explanation... > "This is important as formula is executed in both scanning phase (when > trading signals are generated) and in actual portfolio backtest phase" > > > If that is so, then won't it hit the portion of code that generates the buy > and sell signals again as it moves down the script? > > Thanks for your input. > > --- In [email protected], Brenton Hill <bphill0105@> wrote: > > > > Ronen > > > > Read the link you posted properly, it explains it clearly. > > > > "In the next line we have "if" statement that enters custom backtest > > formula if the analysis engine is in actionPortfolio (2nd phase of > > portfolio backtest) stage. This is important as formula is executed in > > both scanning phase (when trading signals are generated) and in actual > > portfolio backtest phase. "if" statement allows us to enter custom > > backtest procedure part only when analysis engine is in actual > > backtesting phase." > > > > Brenton > > > > > > Ronen wrote: > > > > > > > > > Hi Mike > > > > > > Thanks for your response. I'm referring to this... > > > http://amibroker.com/guide/a_custommetrics.html > > > <http://amibroker.com/guide/a_custommetrics.html> > > > > > > If you notice, the buy and sell references in the code are listed > > > last, whereas in my example, I have it listed first which to me makes > > > more sense. > > > > > > --- In [email protected] <mailto:amibroker%40yahoogroups.com>, > > > "Mike" <sfclimbers@> wrote: > > > > > > > > What documentation are you referring to? > > > > > > > > Signals are processed first, then custom backtest code iterates bar > > > by bar to process those Signals. Phase 2 follows Phase 1, as you would > > > expect. > > > > > > > > Mike > > > > > > > > --- In [email protected] > > > <mailto:amibroker%40yahoogroups.com>, "Ronen" <ronen.marom@> wrote: > > > > > > > > > > I'm puzzled why the call and processing of the custom backtester > > > is happening before the array processing of the actual trading > > > signals? Doesn't it have to be the other way around? > > > > > > > > > > /*********************************/ > > > > > For example: > > > > > > > > > > // Phase 1 > > > > > Buy = MybuyRules; > > > > > Sell = MySellRules; > > > > > > > > > > PositionScore = MyPositionOrdering; > > > > > > > > > > > > > > > // Phase 2 > > > > > SetCustomBacktestProc(""); > > > > > > > > > > if( Status("action") == actionPortfolio ) > > > > > { > > > > > // Now do any modifications to the signals that were > > > > > // generated from the code above and/or produce additional > > > > > // statistics based on those signals. > > > > > } > > > > > > > > > > /*********************************/ > > > > > > > > > > It is strange for me to think of a "phase 2" to be called before a > > > "phase 1". But that is what is in all the documentation. I know I'm > > > missing something, can someone fill me in? > > > > > > > > > > Thanks. > > > > > > > > > > > > > > > > > > > > > > > > __________ Information from ESET Smart Security, version of virus > > > signature database 4993 (20100401) __________ > > > > > > The message was checked by ESET Smart Security. > > > > > > http://www.eset.com > > > > > > > > __________ Information from ESET Smart Security, version of virus signature > > database 4993 (20100401) __________ > > > > The message was checked by ESET Smart Security. > > > > http://www.eset.com > > >
