Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Does anyone know of a good way to do position sizing? I've heard a number of different ways to gauge the matter from the turtles pdf to a number of articles on the web. But I wanted so feed back from the group.
Secondly how can do it in a metastock backtest?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
From the MACDH divergence kit documentation found at:
http://www.metastocktool...om/MACDH/MACDHdiverg.htm
---8<--------------------------------------------------------------
Variable position sizing
================
The variable position sizing indicator displays a suggested position size value to normalize trade risk to specified % limit.
It takes the risk based on the SmartStop initial stop, and calculates an appropriate trade position size.
Variable position sizing involves decreasing trade size on riskier (higher volatility) trades, and increasing it on safer (lower volatility) trades. The result is that trade risk should theoretically (severe price slippage may alter risk) remain the same for all trades.
Should variable position sizing theoretically result in a similar total profit when compared to a fixed-position size strategy? After all, what we lose on those big (now smaller) spectacular wins, we can gain from smaller (spectacular) losses and (now bigger) wins on the larger, safer trades.
In reality, the final result between these two strategies can be quite different.
By normalizing the total risk with risk-based variable position sizing, the result is a *smoother equity curve*.
This results in less overall capital risk, and thus increases the trader's confidence and ability to place a larger proportion of his working capital into his trading strategy.
And larger trades in turn equates to larger profits for the same (or lower) amount of original risk.
Below is an example of how variable position sizing can be applied to non-leveraged trades:
StdEq$ (standard trade size): total capital / maximum number
of open trades / 2;
AvgLoss%: Average Acceptable Loss %;
Risk%: (Entry Price - (Volatility based Stoploss
+ Slippage)) / Entry Price x 100;
Variable Position Size: StdEq$ x AvgLoss% / Risk%.
Example for a safer (less-volatile) trade:
StdEq$ = $100,000 / 10 trades; ($10,000)
AvgLoss% = 8; (8%)
EntryPrice = $10.00;
Stop = $9.50;
Expected exit price slippage = $0.05;
Risk% = ($10.00 - ($9.50 - $0.05)) / $10.00 x 100; (5.5%)
Variable Position Size = $10,000 x 8 / 5.5. ($14,545)
Example for a riskier (volatile) trade:
StdEq$ = $100,000 / 10 trades; ($10,000)
AvgLoss% = 8; (8%)
EntryPrice = $2.00;
Stop = $1.70;
Expected exit price slippage = $0.02;
Risk% = ($2.00 - ($1.70 - $0.02)) / $2.00 x 100; (16%)
Variable Position Size = $10,000 x 8 / 16. ($5,000)
By normalizing maximum trade risk (to 8% in both examples above),
a trader can manage overall capital risk in a more predictable manner.
---8<--------------------------------------------------------------
To answer the second question, variable position sizing can be used in Trade Equitity indicators & explorations, such as the ones developed by Roy:
http://www.metastocktools.com/#roy
http://www.metastocktips.co.nz
jose '-)
http://www.metastocktools.com
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Jose,
Thanks a ton for the quality information first off. Secondly I have tried to encode your system into an exploration format but I was wondering is there a way to ref the results of colA and ColB to be used in ColC? This way I could omit the formula call out used in the Stop. I don't want to use the formula call out again because the formula is being used already in ColA and ColB and both use the PREV function. So my exploration already take a while to run.
I look over Ron formula but I have a hard time following all the code. I'll give it another look tonight thou.
LE:=HHV(H - 2*ATR(5),10);{For Long}
SE:=LLV(L + 2*ATR(5),10);{For Short}
StdEq:=5000; {total capital / maximum number of open trades / 2}
AvgLoss:=8; {Average Acceptable Loss %}
EntryPrice:=Close;
Stop:=If(fml("")=-1,SE,LE);
slippage:=0.10;
RiskPercent:=(EntryPrice-(Stop-slippage))/EntryPrice*100;
VarPosSize:=(StdEq*AvgLoss)/RiskPercent;
Shares:=VarPosSize/Close;
Shares;
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Dieselpr, you could try using the GlobalVar.dll to save and reference indicator output values in your exploration columns, but it would probably be easier (and more reliable) if you got rid of the PREV functions in the original code.
jose '-)
http://www.metastocktools.com
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Hey Jose,
Sorry but whats the GlobalVar.dll?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Jose,
Thanks again the code looks the same as the metastock code but it doesn't appear to be affected by the 20 varible limit correct?
Also, I don't see how you call/ref the GV.dll by the looks of Roy formulas.
Did Mark make some kind of simple guide to this GV.dll? I'm not sure how its using the PC RAM or is it doing it automaically? I don't have metastock here in front of me now.
I'll investigate the matter more when I get home.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
dieselpr wrote:Thanks again the code looks the same as the metastock code but it doesn't appear to be affected by the 20 varible limit correct?
The RAM-based GV.dll variables still need to written/read from within MS formula code, so the 20 variable limit per indicator still applies. Not to say that you cannot code several GV indicators and keep hundreds of variables stored in volatile RAM.
ExtFml( "GV.Clear") - clears all variables stored in RAM.
ExtFml( "GV.SetVar", Variable Name, Expression) - writes variables to RAM
ExtFml( "GV.GetVar", Variable Name) - reads stored variables in RAM
Roy has several applications for this dll - more information on it available at MSTT:
http://www.metastocktips.co.nz
jose '-)
http://www.metastocktools.com
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
Jose,
If I run an exploration and I use for example this call out for a MACD Buy signal-
ExtFml( "GV.SetVar", MACDBuy, Cross(MACD(),Mov(MACD(),9,E)))
My MACDBuy is now set in memory correct?
Now if I reboot the PC is the MACDBuy still in memory or do I need to re-run the exploration?
I'm asking this because you said that-
ExtFml( "GV.Clear") - clears all variables stored in RAM.
Is this the only way to clear the stored varibles out of RAM?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Dieselpr, all variables (set by GV.dll in RAM) are cleared when MetaStock is closed.
The GV.Clear function is seldom used, but would be useful if one needs to clear all variables in the current MetaStock session.
jose '-)
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 4/27/2005(UTC) Posts: 130
|
I see now Jose,
So I would need to encode my exploration in colC this way
LE:=HHV(H - 2*ATR(5),10);{For Long}
SE:=LLV(L + 2*ATR(5),10);{For Short}
StdEq:=5000; {total capital / maximum number of open trades / 2}
AvgLoss:=8; {Average Acceptable Loss %}
EntryPrice:=Close;
Sell:=ExtFml("GV.GetVar",PosSizeSell);
Stop:=If(Sell=-1,SE,LE);
slippage:=0.10;
RiskPercent:=(EntryPrice-(Stop-slippage))/EntryPrice*100;
VarPosSize:=(StdEq*AvgLoss)/RiskPercent;
Shares:=VarPosSize/Close;
Shares;
ExtFml("GV.Clear"); {Reset Varibles}
Then I will need to encode ColB using the ExtFml( "GV.SetVar", PosSizeSell, myformule here) correct?
Metastock does read code in the exploration column by column right?
ColA then ColB then ColC etc. etc.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
dieselpr wrote:Metastock does read code in the exploration column by column right?
ColA then ColB then ColC etc. etc.
Yes, from left to right column for each data bar, from bar 1 to last, from 1st security to last one, all in that order.
dieselpr wrote:Then I will need to encode ColB using the ExtFml( "GV.SetVar", PosSizeSell, myformule here) correct?
Correct.
I'll let you work out the rest now. ;)
jose '-)
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.