Sorry if I was not clear enough. I will try to give more details. Basically I want to run an optimization on two variables, then somehow, automatically, store all values of optimized variables that correspond to a certain metric range (let's say %Winners > 60). Another AFL would then pull that range of optimized variables for a backtest.
I would use the Walk Forward feature of AmiBroker for this, except it only uses the 'best' value, not a range of values. My system requires a range of values, not just the best one. I also want to permanently store the best values. I am stuck trying to figure out how to automatically pull the optimized variables from the optimization report. The custom backtester only allows me to pull the built-in metrics. So the basic question is - how do I extract the optimized variables after an optimization is run? Do I have to write some vbscript that exports the report to csv, then opens that report, then somehow parses through that report to find the correct column and range? Or is there (hopefully) a simpler way of extracting the values? Once the values are extracted, it is then fairly easy to either write them to a file or store them in static variables. But I am aiming to store them in composite symbols, as (a) they are 'permanent' like external files and (b) my sense is that it is more efficient to pull values from a composite symbol than from an external file. As I run through optimizations across different historical periods, I want to build a number of composite symbols that contain the 'best values' of optimized variables for use in 'walk forward' backtests, and then eventual live trading. Hopefully the above is clearer now. Please let me know if not. --- In [email protected], "Mike" <sfclimb...@...> wrote: > > You would have to be a little more clear on exactly what it is you are > trying to accomplish. Though, writing to a file directly, or using > static variables might be areas to explore. > > Mike > > --- In [email protected], "ozzyapeman" <zoopfree@> wrote: > > > > Ah. Well that would explain that. Thanks. > > > > Any ideas for a possible workaround? > > > > > > > > --- In [email protected], "Mike" <sfclimbers@> wrote: > > > > > > Ozzy, > > > > > > The Stats object only contains values for built in metrics as > > > described here (scroll to bottom): > > > > > > http://www.amibroker.com/guide/a_custombacktest.html > > > > > > Mike > > > > > > --- In [email protected], "ozzyapeman" <zoopfree@> wrote: > > > > > > > > Hello, I've read Herman's excellent doc, "IntroToATC". > > > > > > > > I am trying to run an optimization, and then store the values of > the > > > > optimized variables in some composite symbols. I later want to > pull > > > > values of a certain range and input them automatically in > another > > > AFL. > > > > However, I keep getting a syntax error that the fields are not > > > > available, even though they clearly are. > > > > > > > > Hoping someone can point out my mistake, or give me some > > > suggestions on > > > > what else to try. > > > > > > > > Here is the code. Any ideas? : > > > > > > > > > > > > //-------------------------------------------------------------- > ---- > > > -- > > > > // TRADING SYSTEM > > > > //-------------------------------------------------------------- > ---- > > > -- > > > > > > > > FastMALength = Optimize("FastMALength", 10, 1, 10, > > > 1); > > > > SlowMALength = Optimize("SlowMALength", 20, 20, 50, > > > 10); > > > > > > > > FastMA = MA( C, FastMALength ); > > > > SlowMA = MA( C, SlowMALength ); > > > > Buy = Cross( FastMA, SlowMA ); > > > > Sell = Cross( SlowMA, FastMA ); > > > > > > > > > > > > > > > > //-------------------------------------------------------------- > ---- > > > -- > > > > // CUSTOM OPTIMIZATION PROCEDURE (Store opt vars in composite > > > symbols) > > > > //-------------------------------------------------------------- > ---- > > > -- > > > > > > > > SetCustomBacktestProc( "" ); > > > > > > > > if ( Status( "action" ) == actionPortfolio ) > > > > { > > > > bo = GetBacktesterObject(); > > > > > > > > // run default backtest procedure > > > > bo.Backtest( 1 ); > > > > > > > > st = bo.getperformancestats( 0 ); > > > > > > > > // iterate through closed trades first > > > > for ( trade = bo.GetFirstTrade(); trade; trade = > bo.GetNextTrade > > > () ) > > > > { > > > > FastMALength = st.getvalue( "FastMALength" ); > > > > SlowMALength = st.getvalue( "SlowMALength" ); > > > > > > > > AddToComposite( FastMALength, "~OptFastMA", "X", > 1+2+8+16+64 ); > > > > AddToComposite( SlowMALength, "~OptSlowMA", "X", > 1+2+8+16+64 ); > > > > } > > > > bo.ListTrades(); > > > > } > > > > > > > > > >
