TradersStudio®

  • Home
  • Store
  • Products
    • TradersStudio®® Turbo 800% faster
    • TradersStudio®® Turbo Upgrade
    • TradersStudio®® Professional
    • Trend Harmony
  • Free Demo
  • Why TradersStudio®
  • Blog
  • Tutorials
  • Traders Resources
    • Equity Curve Feedback
    • Stock and ETF Trading Systems
    • Walk Forward Testing in TradersStudio®®
  • Contact Us

Keeping Trades in Sync: A Unique Feature of TradersStudio®

November 8, 2014 by

TradersStudio incorporates a wide variety of unique features that are not seen in other backtesting platforms. In previous posts we have discussed how some of those features can help you in system design and testing. We now turn to another unique feature of TradersStudio: the ability to sync trades. We will explain what this means, show you how to implement this feature in your systems, and also give you an example system that utilizes this feature successfully.

The concept of syncing trades was an important addition to TradersStudio and one that took a significant amount of time and effort to develop correctly. In essence, the concept is relatively simple. Suppose that we have a system that buys when a certain condition, let’s call this “buycond”, is met and then sells when “sellcond” is met. Similarly, we then go short on “sellcond” and re-buy on “buycond”. Now, let’s suppose we entered the market with this criteria on January 15, 2013. We then see that “buycond” is true for that trading day. Typically our system would issue a buy order. However, what if that condition had already occurred? What if on January 10, 2013 “buycond” was also true. Had we entered the market earlier, we would have had the signal on the 10th, not on the 15th. Therefore we shouldn’t actually buy on the 15th, we should instead wait and go short whenever “sellcond” is met.

Other possibilities can cause this as well. For example, when volatility is extremely elevated it may be the case that our margin calculations do not even allow us to buy one contract even though a buy signal was generated. When volatility decreases, then that buy signal may be triggered again. We don’t actually want to take that buy signal, however, because had we had the money we would have traded the one prior. Put another way, we want to avoid a case where we have duplicate buy or sell conditions – i.e. we want to make sure our trades are always in sync as we have backtested.

Naturally, this concept would be very difficult to implement programmatically for every single system. Consider the time and effort that would be required to put in all the various flags that would be required. Fortunately, TradersStudio has a function that can solve all these issues with just a few lines of code.

Consider the following Keltner breakout system in TradersStudio code:

Sub KeltnerBandBKSimple(SLen,BandMult,RFiltLB,RFiltMult)
Dim MAAve As BarArray
Dim StdVal As BarArray
Dim virprofit As BarArray
MAAve=Average(Close,SLen,0)
StdVal=Average(Range,SLen,0)
If Close>MAAve+BandMult*StdVal And RangeMAAve Then ExitShort("SX","SE",1,0,Market,Day)
'***********************************************************************
marketbreakdown2()
'**********************************************************************
End Sub

The abbreviated results are as follows:

Performance Summary: All Trades
Total Net Profit $532,337.73 Open Position P/L $22,273.78
Gross Profit $1,337,324.85 Gross Loss ($804,987.12)
Total # of trades 481 Percent Profitable 34.51%
Number winning trades 166 Number Losing Trades 315
Largest winning trade $86,490.00 Largest Losing Trade ($31,990.00)
Average winning trade $8,056.17 Average Losing Trade ($2,555.51)
Ratio avg win/avg loss 3.15 Avg Trade (win & loss) $1,106.73
Max consec. winners 7 Max consec. losers 18
Avg # bars in winners 103 Avg # bars in losers 29
Max intraday drawdown ($93,782.93) Max # contracts held 1
Profit Factor 1.66 Yearly return on accoun 40.57%
Account size required $93,782.93

Note that this system isn’t a perfect system by any means. During periods of low volatility, we have higher drawdowns. During high volatility however, we can size up significantly and achieve excellent results. You can download the full TradersStudio report here. Note that the drawdown is close to $100,000.

Suppose we were implementing this system and wanted to make sure that the buys and sells were in sync – that is that we only took the first buy signal or the first sell signal and ignored secondary ones. The sync function in TradersStudio uses the virtual buy/sell channel (as we have discussed in this previous blog post). As such, we need to make a slight modification to our Keltner breakout system.

Sub KeltnerBandBKSimple(SLen,BandMult,RFiltLB,RFiltMult)
Dim MAAve As BarArray
Dim StdVal As BarArray
Dim virprofit As BarArray
MAAve=Average(Close,SLen,0)
StdVal=Average(Range,SLen,0)
If Close>MAAve+BandMult*StdVal And RangeMAAve Then ExitShort("SX","SE",1,0,Market,Day)

' Begin modification
If Close>MAAve+BandMult*StdVal And RangeMAAve Then VirtualExitShort("SX","SE",1,0,Market,Day)
marketvar("VirPos")=VirMarketPositionplus("")
marketvar("VirNetProfit")=VirtualNetProfit
marketvar("VirOpenPosProfit")=VirOpenPositionProfit
' End modification

'***********************************************************************
marketbreakdown2()
'**********************************************************************
End Sub

Then we would want our trade plan to be as follows.

' TradersStudio(r) (c) 2006-2007 all rights reserved
Sub DynMarginPlanSimple(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
TradePlan.Session(S).Market(M).ExitNumUnits=TradePlan.Session(S).Market(M).NumContractsHeld
Next
Next
End Sub

This shows us the basic process of calculating how many units we wish to buy with our system. It also shows us how to use the Sync technology to ensure that duplicate trades are not made.

The abbreviated results are as follows:

Performance Summary: All Trades ($250k Size System)
Total Net Profit $694,786.76 Open Position P/L $97,934.69
Gross Profit $2,440,610.21 Gross Loss ($1,745,823.45)
Total # of trades 476 Percent Profitable 34.24%
Number winning trades 163 Number Losing Trades 313
Largest winning trade $205,560.00 Largest Losing Trade ($22,697.50)
Average winning trade $14,973.07 Average Losing Trade ($5,577.71)
Ratio avg win/avg loss 2.68 Avg Trade (win & loss) $1,459.64
Max consec. winners 7 Max consec. losers 18
Avg # bars in winners 103 Avg # bars in losers 29
Max intraday drawdown ($257,439.96) Max # contracts held 12
Profit Factor 1.40 Yearly return on account 22.66%
Account size required $257,439.96

The system itself still has high drawdowns. You can download the full TradersStudio reports for an account size of $250,000 and for an account size of $1 million. But, unlike the system before, we have both implemented dynamic margin and ensured that our trades would be completely in-sync.

In fact, if we compare these trade reports to the simple Keltner system above, we will see an immediate difference. The simple system has the following line to start the system:

SE EN_REV.CSV 5/15/2000 1 3878.00 6/20/2000 SX 1 4389.50 ($10,330.00)

To start, we entered in “mid-trade” and wound up losing $10k on it. The system with dynamic margin and sync technology does not have this trade.

When developing your own systems in TradersStudio, please look at the sync technology that we have implemented. It can often help you keep your strategies as well as trading signals clean and profitable. Over the years TradersStudio has evolved to contain a plethora of features not found in other trading packages. In the coming posts we will continue to show you these features to enable you to become the most profitable trader you can be! nike air max damen nike air max damen

Featured Product

TradersStudio® Turbo
$499.00

Site Menu

  • Home
  • Store
  • Products
    • TradersStudio®® Turbo 800% faster
    • TradersStudio®® Turbo Upgrade
    • TradersStudio®® Professional
    • Trend Harmony
  • Free Demo
  • Why TradersStudio®
  • Blog
  • Tutorials
  • Traders Resources
    • Equity Curve Feedback
    • Stock and ETF Trading Systems
    • Walk Forward Testing in TradersStudio®®
  • Contact Us

Copyright © 2014-2015 TradersStudio, Inc. All rights reserved. TradersStudio® is a registered trademark of TradersStudio, Inc.

No portion of this site may be copied without the express permission of the author.