PureBytes Links
Trading Reference Links
|
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/&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.
------------------------ 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/
|