Murray
I taken the Trade Plan model I found in TS and tried to modified for my needs but it have no influence on the TradePlan.SummEquity and the order volume for new position size.
See the copy and please tell me what I made wrong for having learning effect.
Thank you very much and kind regrads
Markus
Sub Adjust_Muster_Flagship(Percent,Ceiling,Subscription,Redemption) Dim S As Integer Dim M As Integer Dim DollarPerTrade Dim StartAccount Dim objMark As TSProcessor.IMarket Dim adj Dim MoneyIn Dim MoneyOut 'adjust account on days that Subscriptions/Redemptions come in. 'with this adjustments we can calculate new position size for new orders.
If CurDateTime = LastDateTime Then MoneyIn=Subscription MoneyOut=0-Redemption If MoneyIn > 0 Then adj = Sum(MoneyIn,MoneyOut) Else adj = 0 If MoneyOut < 0 Then adj = Sum(MoneyIn,MoneyOut) Else adj = 0 End If End If TradePlan.AdjustAccount(adj) Print "Subscribtion: ", CurDateTime, " = ", MoneyIn Print "Redemption: ", CurDateTime, " = ", MoneyOut Print "Adjustment: ", CurDateTime, " = ", adj Print "NewTotalEquity: ", CurDateTime, " = ", tradeplan.SummEquity End If
If tradeplan.MarketType=0 Then If Tradeplan.SummEquity+adj MsgBox "not enough money" StopRun End If
If Tradeplan.SummEquity+adj< Tradeplan.TotalMarginForPlan Then MsgBox "Margin Call Account below minimum margin required" StopRun End If End If DollarPerTrade=(tradeplan.SummEquity+adj)*(Percent/100)
For S = 0 To TradePlan.SessionCount - 1 TradePlan.Session(S).UnitSize = 1
For M = 0 To TradePlan.Session(S).MarketCount - 1 objMark = TradePlan.Session(S).Market(M)
If objMark.TradeRiskSet Then
If objMark.TradeRisk <> 0 Then objMark.EntryNumUnits =Min(Floor(DollarPerTrade/objMark.TradeRisk),Ceiling) Else objMark.EntryNumUnits=0 End If
objMark.ExitNumUnits = objMark.NumContractsHeld Else objMark.NumUnits = -1 ' use default End If Next Next End Sub |