[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Trying to store Optimized Variables using AddToComposite



PureBytes Links

Trading Reference Links

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();  
}

__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___