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

[amibroker] Re: Custom bactester metrics & Van Tharps per trade r multiple



PureBytes Links

Trading Reference Links

In your calculation of TradeRisk, how are the variables EntryPrice and
ExitPrice calculated?

Regards,
GP


--- In amibroker@xxxxxxxxxxxxxxx, "justinwonono" <justinwonono@xxx> wrote:
>
> // =====
> 
> 
> Hi GP,
> Thanks for your time & interest. 
> I managed to sort out the date problem, but as the trace results show
> , for some reason, I can't pick up the composite risk value even
> though data  is definitely there.
> 
> Even if i just loop through without the date matching selection, no
> data shows in the trace.
> 
> Any ideas?
> 
> Regards
> 
> justinwonono
> 
> =======
> ....
> AddToComposite(TradeRisk, "~trisk" + Name(),"C",atcFlagDefaults |
> atcFlagEnableInBacktest );
> .....
> 
> 
> SetCustomBacktestProc("");
> 
> 
> if( Status("action") == actionPortfolio )
>    {
>     _TRACE("Custom BT Start");
>     bo = GetBacktesterObject();
>     bo.Backtest(1); // run default backtest procedure
>     SumProfitPerRisk = 0;
>     NumTrades = 0;
> 
> // iterate through closed trades 
> 
>    for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
> 
>    {
> 
> // risk is calculated as the maximum value we can loose per trade
> 				
> 
>     dt = DateTime();
>     TradeRisk = 0;
>     TradeDate = DateTime();
>     Risk = 0;
>     TRisk = Foreign("~trisk_" + trade.Symbol,"C");
> 	
>     for( i = 1; i < BarCount; i++ )
>     {
>      if (  Trade.EntryDateTime == dt[i] )
>      {
> 
> //    if (TRisk[i]  > 0)
> //    {
> 
>        TradeDate = dt[i];
>        Risk = TRisk[i];
> 
> _TRACE( "Symbol = " + trade.Symbol + " : dt[" + i + "] = " + NumToStr(
> TradeDate , formatDateTime ) + " : TRisk[" + i + "] = " + TRisk[i]);
> 
> //     break;			
> //     }
> 
>       }
>      }
> 
> 
> _TRACE(" Trade.EntryDateTime = " + NumToStr( Trade.EntryDateTime,
> formatDateTime ) + " Risk = " + Risk );
> 
> 
>    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();
> 
> _TRACE("Custom BT End");
> 
> }
> 
> =======
> [3536] Custom BT Start
> [3536] Symbol = BHP : dt[1] = 13/02/2004 : TRisk[1] = {EMPTY}
> [3536]  Trade.EntryDateTime = 13/02/2004 Risk = {EMPTY}
> [3536] Symbol = SGB : dt[3] = 17/02/2004 : TRisk[3] = {EMPTY}
> [3536]  Trade.EntryDateTime = 17/02/2004 Risk = {EMPTY}
> =======
> 
> 
> 
> -- In amibroker@xxxxxxxxxxxxxxx, "gp_sydney" <gp.investment@> wrote:
> >
> > >    Risk = ValueWhen((Foreign("~trisk_" + trade.Symbol, dt )==
> > >    Trade.EntryDateTime), Foreign("~trisk_" + trade.Symbol,"C")) ;
> > 
> > In this statement, the:
> > 
> > Foreign("~trisk_" + trade.Symbol, dt)
> > 
> > part is incorrect. The second parameter to Foreign is supposed to be
> > the array type ("C", "O", etc) but you have the DateTime array.
> > 
> > Regards,
> > GP
> > 
> >
>




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 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
 
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/