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

Re: FW: [amibroker] Risk compounding with gains - I cannot get round it



PureBytes Links

Trading Reference Links


I remember in the help file of amibroker, there is an example of 
volatility ( atr ) based position size like van tharp model.
copy paste of Help file:
"
You can also use more sophisticated position sizing methods. For 
example volatility-based position sizing (Van Tharp-style):

PositionSize = -2 * BuyPrice/(2*ATR(10));

That way you are investing investing 2% of PORTFOLIO equity in the 
trade adjusted by BuyPrice/2*ATR factor.
"



> Too bad! Unfortunately PositionSize= -xxx is useless to me, as I 
use a
> volatility based fixed risk model, where the risk per trade is a 
direct
> proportion of the total equity, not the Position size itself.
> 
>  
> 
> Thanks a lot for you help, in any case :-)
> 
>  
> 
> Regards,
> Claude
> 
>  
> 
>  
> 
>   _____  
> 
> From: Stephane Carrasset [mailto:nenapacwanfr@x...] 
> Sent: Friday, February 18, 2005 15:01
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: Re: FW: [amibroker] Risk compounding with gains - I cannot 
get
> round it
> 
>  
> 
> 
> yes,
> you're right, it was a bad idea to use 
> PositionSize=Foreign("~~~EQUITY", "C" )*0.2;
> it is a bad idea to use 
> PositionSize=Equity()*0.2;
> 
> so no others solution that 
> PositionSize=-20;
> 
> 
> > Hi Stephane,
> > 
> >  
> > 
> > Many thanks for your help.
> > 
> >  
> > 
> > However I suspect that the example below is picking up the 
previous 
> equity
> > line, or something like that. (can't pinpoint exactly what's 
> happening!)
> > 
> >  
> > 
> > I first run it with positionsize=-10;  works fine - several 100 
> trades
> > taken. No problems
> > 
> > I then run it with positionsize = PositionSize=Foreign
> ("~~~EQUITY", "C"
> > )*0.1;: works fine, and seems to be giving ok results 
> > 
> > BUT
> > 
> > I hit backtest again, and no trades are taken, implying that 
> positionsize =
> > 0.
> > 
> >  
> > 
> > Do you get the same thing I am getting?
> > 
> >  
> > 
> > Cheers,
> > 
> > Claude
> > 
> >  
> > 
> >  
> > 
> >   _____  
> > 
> > From: Stephane Carrasset [mailto:nenapacwanfr@x...] 
> > Sent: Thursday, February 17, 2005 21:01
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: Re: FW: [amibroker] Risk compounding with gains - I 
cannot 
> get
> > round it
> > 
> >  
> > 
> > 
> > Hi claude,
> > 
> > use 
> > PositionSize=Foreign("~~~EQUITY", "C" )*0.1; // idem as 
> PositionSize=-
> > 10;
> > 
> > for ex run this basic system and look the results.
> > I complain that Amibroker turns less and less obvious.
> > 
> > stephane
> > 
> > 
> > SetCustomBacktestProc(""); 
> > function FindEquityAtDateTime( eq, dt, Value ) 
> > { 
> >       result=0;
> >    for( i = 0; i < BarCount  ; i++ ) 
> >    { 
> >    if( dt[ i ] == Value ) 
> >       result=eq[i];
> >       }
> >    return  result ; 
> > } 
> > 
> > if( Status("action") == actionPortfolio ) 
> > { 
> >       bo = GetBacktesterObject(); 
> >       bo.Backtest(1); // run default backtest procedure 
> >       eq = Foreign("~~~EQUITY", "C" ); 
> >       dt = DateTime(); 
> > 
> >    for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade
> > () ) 
> >    { 
> >             EquityAtEntry = FindEquityAtDateTime( eq, dt, 
> > trade.EntryDateTime );
> >             trade.AddCustomMetric("Equity at entry", 
> > EquityAtEntry); 
> >    } 
> > 
> >    for( openpos = bo.GetFirstOpenPos(); openpos; openpos = 
> > bo.GetNextOpenPos() ) 
> >    { 
> >             EquityAtEntry = FindEquityAtDateTime( eq, dt, 
> > Openpos.EntryDateTime );
> >             Openpos.AddCustomMetric("Equity at entry", 
> > EquityAtEntry); 
> >    }
> >     bo.ListTrades();
> > } 
> > 
> > Buy=Cross( MACD(), Signal() );
> > Sell=Cross( Signal(), MACD() );
> > SetOption("InitialEquity", 10000);
> > 
> > //PositionSize=-10;
> > PositionSize=Foreign("~~~EQUITY", "C" )*0.1; // idem as 
> PositionSize=-
> > 10;
> > //BAD Usage is 01*Equity(0,-1) -1 is default settings of 
backtesting
> > //it returns the decimal part of equity
> > 
> > 
> > 
> > >  
> > > 
> > >   _____  
> > > 
> > > From: Claude Caruana [mailto:claude.caruana@x...] 
> > > Sent: Thursday, February 17, 2005 09:56
> > > To: 'amibroker@xxxxxxxxxxxxxxx'
> > > Subject: RE: [amibroker] Risk compounding with gains - I cannot 
> get 
> > round it
> > > 
> > >  
> > > 
> > > Hi all,
> > > 
> > >  
> > > 
> > > I'm finding real problems with implementing this so I would 
really
> > > appreciate if there is somebody out there with the answer!
> > > 
> > > The key is that I want my risk to be relative to current total 
> > equity, not
> > > position size.
> > > 
> > >  
> > > 
> > > I understand if I use 
> > > 
> > > Positionsize = -20 , then my position size is 20% of my current 
> > equity.
> > > Tried and tested - this works ok.
> > > 
> > > BUT,
> > > 
> > > If only I can assign a percentage of the current equity to a 
> > variable other
> > > than positionsize, it would solve all my problems - something 
like
> > > 
> > > CurrentEquity = XXXXX
> > > 
> > >  
> > > 
> > > Can anybody help? I would be really grateful!
> > > 
> > > Thanks,
> > > 
> > > Claude
> > > 
> > >  
> > > 
> > >  
> > > 
> > >  
> > > 
> > >   _____  
> > > 
> > > From: Claude Caruana [mailto:claudecaruana@x...] 
> > > Sent: Tuesday, February 15, 2005 23:23
> > > To: amibroker@xxxxxxxxxxxxxxx
> > > Subject: RE: [amibroker] Risk compounding with gains - problem
> > > 
> > >  
> > > 
> > > Hi again.
> > > 
> > >  
> > > 
> > > I found the problem to be that the equity() function will only 
> work 
> > if
> > > placed after the buy/sell signals.
> > > 
> > > Problem is that I need it before the buy signal in order to 
> > calculate the
> > > position size.
> > > 
> > > Anybody can indicate a way to determine the equity value before 
> the 
> > buy
> > > signal??
> > > 
> > > Thanks in advance for any input.
> > > 
> > >  
> > > 
> > > Claude
> > > 
> > >  
> > > 
> > >  
> > > 
> > >   _____  
> > > 
> > > From: Claude Caruana [mailto:claudecaruana@x...] 
> > > Sent: Tuesday, February 15, 2005 13:12
> > > To: amibroker@xxxxxxxxxxxxxxx
> > > Subject: [amibroker] Risk compounding with gains - problem
> > > 
> > >  
> > > 
> > > Hi All,
> > > 
> > >  
> > > 
> > > Can anybody help me with this? I am trying to achieve a 
position 
> > sizing
> > > technique where half the current total profit (assuming there 
is 
> a 
> > profit)
> > > is re-invested into risk. Problem is that it seems like equity
(0) 
> > is always
> > > returning 250000 and the CurrentPL variable seems to always be 
0.
> > > 
> > >  
> > > 
> > > StartCapital  = 250000;
> > > 
> > > CapitalNow    = equity(0);                             
> > > 
> > > CurrentPL     = ((CapitalNow-StartCapital)/StartCapital);
> > > 
> > >  
> > > 
> > > RiskPerTrade  = 0.001+(CurrentPL/2);            
> > > 
> > > PositionSize = ((CapitalNow*RiskPerTrade) / stopPoints) * 
> BuyPrice;
> > > 
> > > 
> > >  
> > > 
> > > What I am expecting this to do is: let us say at one point the 
> > equity goes
> > > up 2% from 250,000 to 255,000 - then:
> > > 
> > >  
> > > 
> > > Current PL         = 255000-250000/250000 = 0.02
> > > 
> > > RiskPerTrade     = 0.001+(0.02/2) = 0.011
> > > 
> > > Risk per trade now should go up from 0.001 to 0.011, but this 
> isn't
> > > happening.
> > > 
> > >  
> > > 
> > > I am aware I need to arrange this to handle losses, but I first 
> > would like
> > > to sort out this issue.
> > > 
> > >  
> > > 
> > > Should I in fact be using equity(0) to achieve this or should I 
> be 
> > using
> > > some other function?
> > > 
> > >  
> > > 
> > > Thanks in advance for any help :-)
> > > 
> > >  
> > > 
> > > Claude
> > > 
> > >  
> > > 
> > >  
> > > 
> > > 
> > > 
> > > Check AmiBroker web page at:
> > > http://www.amibroker.com/
> > > 
> > > Check group FAQ at:
> > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Check AmiBroker web page at:
> > > http://www.amibroker.com/
> > > 
> > > Check group FAQ at:
> > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Yahoo! Groups Sponsor
> > > 
> > > 
> > > 
> > > ADVERTISEMENT
> > >  
> > > 
> > 
> 
<http://us.ard.yahoo.com/SIG=129mu7tg7/M=298184.6018725.7038619.300117
> > 6/D=gr
> > > 
> > 
> 
oups/S=1705632198:HM/EXP=1108571031/A=2532114/R=2/SIG=12k45q5oa/*http:
> > /clk.a
> > > 
> > 
> 
tdmt.com/NFX/go/yhxxxnfx0020000014nfx/direct/01/&time=1108484631221203
> > > 
> > > 
> > >  
> > > 
> > <http://view.atdmt.com/NFX/view/yhxxxnfx0020000014nfx/direct/01/
> > 
> <http://view.atdmt.com/NFX/view/yhxxxnfx0020000014nfx/direct/01/
> 
<http://view.atdmt.com/NFX/view/yhxxxnfx0020000014nfx/direct/01/&time=
>
> &time=
> >
> > &time=
> > 110848
> > > 4631221203> 
> > > 
> > > 
> > >  
> > > <http://us.adserver.yahoo.com/l?
> > M=298184.6018725.7038619.3001176/D=groups/S=
> > > :HM/A=2532114/rand=307249708> 
> > > 
> > >  
> > > 
> > >   _____  
> > > 
> > > 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
> > > <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?
> subject=Unsubscribe> 
> > >   
> > > *      Your use of Yahoo! Groups is subject to the Yahoo!
> > > <http://docs.yahoo.com/info/terms/>  Terms of Service.
> > 
> > 
> > 
> > 
> > 
> > Check AmiBroker web page at:
> > http://www.amibroker.com/
> > 
> > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > 
> > 
> > 
> > 
> > 
> > 
> > Yahoo! Groups Sponsor
> > 
> > 
> > 
> > ADVERTISEMENT
> >  
> > 
> 
<http://us.ard.yahoo.com/SIG=129n26bo9/M=298184.6018725.7038619.300117
> 6/D=gr
> > 
> 
oups/S=1705632198:HM/EXP=1108735292/A=2532114/R=2/SIG=12kubiqh9/*http:
> /clk.a
> > 
> 
tdmt.com/NFX/go/yhxxxnfx0020000014nfx/direct/01/&time=1108648892438290
> > 
> > 
> >  
> > 
> <http://view.atdmt.com/NFX/view/yhxxxnfx0020000014nfx/direct/01/
> 
<http://view.atdmt.com/NFX/view/yhxxxnfx0020000014nfx/direct/01/&time=
>
> &time=
> 110864
> > 8892438290> 
> > 
> > 
> >  
> > <http://us.adserver.yahoo.com/l?
> M=298184.6018725.7038619.3001176/D=groups/S=
> > :HM/A=2532114/rand=820227807> 
> > 
> >  
> > 
> >   _____  
> > 
> > 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
> > <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?
subject=Unsubscribe> 
> >   
> > *      Your use of Yahoo! Groups is subject to the Yahoo! Terms 
of 
> Service
> > <http://docs.yahoo.com/info/terms/> .
> 
> 
> 
> 
> 
> Check AmiBroker web page at:
> http://www.amibroker.com/
> 
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.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
> <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe> 
>   
> *	Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service
> <http://docs.yahoo.com/info/terms/> .





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/