Switching between systems using equity curve feedback

Discussion in 'Risk Management' started by Murray Ruggiero, Apr 24, 2011.

  1. Murray Ruggiero

    Murray Ruggiero ET Sponsor

    Let’s look at the following example. We have two different systems. The first one is a simple channel breakout. You can see the VirtualBuy and VirtualSell. These use the virtual backtester and will be used to turn the system on and off. The filtering is done at the tradeplan level. When MarketVar TurnOff is set that system is turned off so we exit any trades we are in. The real buy and sells are disabled at the tradeplan level.

    ' TradersStudio(r) copyright 2004-2011, All rights reserved
    Sub Virtual1(SLen)
    Dim MinMove
    Dim S As String
    MinMove=GetActiveMinMove()

    VirtualBuy("ChanBuy",1,Highest(High,SLen,0)+MinMove ,Stop,Day)
    VirtualSell("ChanSell",1,Lowest(Low,SLen,0)-MinMove,Stop,Day)

    Buy("ChanBuy",1,Highest(High,SLen,0)+MinMove ,Stop,Day)
    Sell("ChanSell",1,Lowest(Low,SLen,0)-MinMove,Stop,Day)

    S = MarketVar("TurnOff")

    If Len(S)>0 Then
    ExitLong("","",1,0,Market,Day)
    ExitShort("","",1,0,Market,Day)
    End If
    End Sub



    Here is an opening range breakout system which is the second system in our example


    ' TradersStudio(r) copyright 2004-2011, All rights reserved
    ' System which communicates with
    Sub Virtual2(Mult)
    Dim AveTr
    Dim Nxtopen
    Dim S As String

    If BarNumber<LastBar Then
    Nxtopen=NextOpen(0)
    Else
    Nxtopen=0
    End If

    If Close>Open Then
    Sell("SellBrk",1,Nxtopen-Mult*TrueRange,Stop,Day)
    VirtualSell("SellBrk",1,Nxtopen-Mult*TrueRange,Stop,Day)
    End If

    If Close<Open Then
    Buy("BuyBrk",1,Nxtopen+Mult*TrueRange,Stop,Day)
    VirtualBuy("BuyBrk",1,Nxtopen+Mult*TrueRange,Stop,Day)
    End If

    S = MarketVar("TurnOff")
    If Len(S)>0 Then
    ExitLong("","",1,0,Market,Day)
    ExitShort("","",1,0,Market,Day)
    End If
    End Sub



    Below is the virtual tradeplan. At the session level within the tradeplan we check the equity curve for both of the systems above. We turn on the system which has a higher equity curve and turn off the one with a lower equity value. When the system is turned off we set entrynumunits to 0, -1 means that we take position sizing from the session level. If we set entrynumunits to 0, we will set MarketVar(“TurnOff”) to “Exit” and this flag will be used by the systems at the session level to exit any exiting positions.

    ' TradersStudio(r) copyright 2004-2011, All rights reserved
    ' This trade plan switchs between systems. It sets variables based on Virtual trading channel
    ' to trade the system which are performing best currently.
    Sub VirtualTradePlan01()
    Dim i As Integer
    Dim S1 As TSProcessor.ISession
    Dim S2 As TSProcessor.ISession
    Dim n1 As Integer
    Dim n2

    If SessionCount <> 2 Then
    MsgBox("This trade plan must have 2 sessions")
    StopRun
    End If

    S1 = TradePlan.Session(0)
    S2 = TradePlan.Session(1)

    If S1.VirCurEquity > S2.VirCurEquity Then
    n1 = -1
    n2 = 0
    Else
    print "System 2 is the best"
    n1 = 0
    n2 = -1
    End If

    'Print S1.VirCurEquity & " / " & S2.VirCurEquity

    For i = 0 To S1.MarketCount - 1
    S1.Market(i).EntryNumUnits = n1
    Next

    For i = 0 To S2.MarketCount - 1
    S2.Market(i).EntryNumUnits = n2
    Next

    For i = 0 To S1.MarketCount - 1
    If n1=0 Then
    S1.Market(i).MarketVar("TurnOff")="Exit"
    Else
    S1.Market(i).MarketVar("TurnOff")=""
    End If
    Next

    For i = 0 To S2.MarketCount - 1
    If n2=0 Then
    S2.Market(i).MarketVar("TurnOff")="Exit"
    Else
    S2.Market(i).MarketVar("TurnOff")=""
    End If
    Next
    End Sub
     
  2. I once looked at a similar mechanical concept, and found the following issues (similar to those of a lagging indicator!):
    1) The time lag between start of drawdown and the switching off of the underperforming system; you watch lots of equity destroyed before the underperforming system gets switched off. Conversely, you miss many wining trades before an off system switches back on.
    2) “Switching Chop”; just after the underperformer is switched off, performance improves again. After a few successful trades, the off system is switched back on, and the next trades are all losers. In the end, you participate in all the losers and miss all the winners! It happened to me!
    In my view, instead of the above it is best to pick systems with win rates and drawdowns you can live with. And then just take all the set-ups. In my experience, you come out ahead.
     
    kut2k2 likes this.
  3. My experience is similar to abattia. I tested via spreadsheet rotating to the best performing strategy out of a group of 5 or so strategies. It underperformed simply holding all strategies and far underperformed picking the best strategies in sample and then holding them out of sample. I haven't given up trying to dynamically adjust my strategies or portfolio weightings at some point, but for the time being I simply diversify across my best strategies.
     
  4. Murray Ruggiero

    Murray Ruggiero ET Sponsor

    I am doing TradersStudio video's over the next few months , any interest in a equity curve feedback and trading system video
     
  5. :) Yes Please Murray
     
  6. Murray Ruggiero

    Murray Ruggiero ET Sponsor

    This old threads discussing equity curve feedback is very important. If you want to see examples of using Equity curve feedback ,click here. This is an example of using equity curve feedback to improve a system. Our next example shows how to switch between systems using equity curve feedback in TradersStudio. TradersStudio Turbo is the best tool for developing systems using advance concepts like Equity Curve Feedback.
     
  7. Murray Ruggiero

    Murray Ruggiero ET Sponsor

  8. Sergio77

    Sergio77

    Very useful. Thanks!
     
  9. Murray Ruggiero

    Murray Ruggiero ET Sponsor

    You can see how easy it is to implement this in TradersStudio.
     
  10. Sergio77

    Sergio77

    Yes, life must be easy. If I need to do everything in Python the game is lost. A trader must concentrate on trading and not on programming.
     
    #10     Mar 29, 2015