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

[amibroker] Adding Custom Columns to backtest



PureBytes Links

Trading Reference Links

Hi all,

I'm trying to add to backtester extra columns for:
Risk amount per share  i.e. Entryprice - Maxstop level  &
R multiple profit/loss

I have an ATR 14day max loss stop hung from the Low of day of Entry.

But can't get it to work: my code:

SetCustomBacktestProc(""); 

     ATR14day = ATR(14);        (HERE IS PROBLEM, it doesn't get 
     amount = 2*ATR14day;           these values, I have no idea how)  
     stoplevel = Low - amount;

 
if( Status("action") == actionPortfolio ) 
{ 
    bo = GetBacktesterObject(); 
    bo.Backtest(1); 

   for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() ) 
   { 
      
       Risk = trade.EntryPrice() - stoplevel; 
       Rmultiple = (trade.ExitPrice() - trade.EntryPrice) / Risk; 

       trade.AddCustomMetric("Risk", Risk ); 
       trade.AddCustomMetric("R-multiple", Rmultiple  ); 
       
   } 
  
    bo.ListTrades(); 

} 

I know that putting the following up there, doens't work.
             ATR14day = ATR(14);        
             amount = 2*ATR14day;           
             stoplevel = Low - amount;

it doesn't get the values.  Does anyone get what I'm trying to do?
and if so what method do i use to get these values read and used so I
can put my calculations for "Risk" and "Rmultiple" in backtester Columns?

Any help is greatly appreciated,

best regards.




Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.28/672 - Release Date: 2/6/2007 10:22 AM