Quote from Gyles:
Please may I ask âHow can I rebalance a portfolio so that no single trade represents too high a percentage of the account?â Thanks
Here is a tradeplan which shows how to have a system rebalance. The system does not required to be designed special for use of this tradeplan.
' TradersStudio(r) (c) 2006-2007 all rights reserved
Sub DynMarginPlanSimpleWithRebalance(Percent,Ceiling,RangeLB,DMarginMult,SDate)
Dim M As Integer
Dim S As Integer
Dim DollarsPerMarket
Dim StartAccount
Dim DollarsPerTrade
Dim DynMargin
Dim Curdate
TradePlan.Session(0).UnitSize = 1
DollarsPerMarket=Tradeplan.SummEquity/TradePlan.MarketCount
' For each session Loop though the trading plans.
For S=0 To TradePlan.SessionCount-1
For M = 0 To TradePlan.Session(S).MarketCount - 1
Curdate=TradePlan.Session(S).Market(M).Data(0,"Date",0)
DynMargin=DynamicMargin(TradePlan.Session(S).Market(M),RangeLB,DMarginMult)
If DollarsPerMarket>DynMargin And Curdate>=MigrateDate(SDate) Then
TradePlan.Session(S).Market(M).SyncSystem2(MigrateDate(SDate))
If (DollarsPerMarket*Percent/100)/ DynMargin>=1 Then
TradePlan.Session(S).Market(M).EntryNumUnits =Min(Floor((DollarsPerMarket*Percent/100)/ DynMargin),Ceiling)
Else
If (DollarsPerMarket*Percent/100)/ DynMargin>.7 Then TradePlan.Session(S).Market(M).EntryNumUnits=1
End If
Else
TradePlan.Session(S).Market(M).EntryNumUnits=0
End If
If TradePlan.Session(S).Market(M).OpenPositonProfit>.20*Tradeplan.SummEquity Then
If TradePlan.Session(S).Market(M).MarketPositionPlus("")=1 Then
TradePlan.Session(S).Market(M).TSExitlong("Rebalance","",0,ceil(TradePlan.Session(S).Market(M).NumContractsHeld/2),Market,Day)
Else
TradePlan.Session(S).Market(M).TSExitShort("Rebalance","",0,ceil(TradePlan.Session(S).Market(M).NumContractsHeld/2),Market,Day)
End If
End If
TradePlan.Session(S).Market(M).ExitNumUnits=TradePlan.Session(S).Market(M).NumContractsHeld
Next
Next
End Sub