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

[amibroker] custom metrics question



PureBytes Links

Trading Reference Links

Can anyone get me pointed in the right direction? 

I want to be able to display information about what got me into a 
trade along with the backtest stats and add it to the AA window as 
part of the individual trades after i do a backtest scan

So if i start with this code

/* First we need to enable custom backtest procedure and 
** tell AmiBroker to use current formula 
*/ 

SetCustomBacktestProc(""); 

MaxLossPercentStop = 10; // 10% max. loss stop 

/* Now custom-backtest procedure follows */ 
if( Status("action") == actionPortfolio ) 
{ 
    bo = GetBacktesterObject(); 

    bo.Backtest(1); // run default backtest procedure 

   SumProfitPerRisk = 0; 
   NumTrades = 0; 

   // iterate through closed trades first 
   for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade
() ) 
   { 
      // risk is calculated as the maximum value we can loose per 
trade 
      // in this example we are using  max. loss stop 
      // it means we can not lose more than (MaxLoss%) of invested 
amount 
      // hence ris 

       Risk = ( MaxLossPercentStop / 100 ) * trade.GetEntryValue(); 
       RMultiple = trade.GetProfit()/Risk; 

       trade.AddCustomMetric("Initial risk $", Risk  ); 
       trade.AddCustomMetric("R-Multiple", RMultiple  ); 

       SumProfitPerRisk = SumProfitPerRisk + RMultiple; 
       NumTrades++; 
   } 

    expectancy3 = SumProfitPerRisk / NumTrades; 

    bo.AddCustomMetric( "Expectancy (per risk)", expectancy3 ); 

    bo.ListTrades(); 

} 

// your trading system here 

ApplyStop( stopTypeLoss, stopModePercent, MaxLossPercentStop ); 

fast = Optimize("fast", 12, 5, 20, 1 ); 
slow = Optimize("slow", 26, 10, 25, 1 ); 
Buy=Cross(MACD(fast,slow),Signal(fast,slow)); 
Sell=Cross(Signal(fast,slow),MACD(fast,slow));

 
And i have this signal in my  charting code for example:
MAuvchkBull=IIf(MAuv>(1.5*MAdv),1,0);
or this
EntrySignal = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) ); 

How can i call that and get it in my backtest stat info????

i tried this and get blank colums
trade.AddCustomMetric("Entry", EntrySignal  );

Please get me pointed in the right direction so i can finish this 
weekend

Thanks for any comments 




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

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

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/