Top to bottom Here’s the code for our entire trade plan, integrating adaptive f into the mix. Sub AdaptiveFTradePlanAugArt(steps,F_TradeWindowSize,ScaleF,Ceiling) Dim S As Integer Dim M As Integer Dim DollarPerTrade Dim StartAccount Dim OptF Dim BigLoser Dim objMark As TSProcessor.IMarket If tradeplan.MarketType = 0 Then If Tradeplan.SummEquity < tradeplan.MarginForOneLot Then MsgBox “not enough money” StopRun End If ‘If Tradeplan.SummEquity< Tradeplan.TotalMarginForPlan Then ‘MsgBox “Margin Call Account below minimum margin required” ‘StopRun End If DollarPerTrade = tradeplan.SummEquity/tradeplan.MarketCount 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) OptF=CalcOptimalF_TPVir(steps,F_TradeWindowSize, TradePlan.Session(S).Market(M),BigLoser) If OptF>.60 Then OptF=.60 End If If BarNumber>500 Then If OptF>steps Then objMark.EntryNumUnits = Min(Max(DollarPerTrade/(Abs(BigLoser)/(OptF*ScaleF)),1),Ceiling) Else objMark.EntryNumUnits=1 End If Else objMark.EntryNumUnits = 1 End If objMark.ExitNumUnits = objMark.NumContractsHeld Next End Sub