搜索
由繁至简的炒股秘籍股票配资送值得信赖我出资你炒股赚大钱自己操盘配资财源滚滚
查看: 17163|回复: 4

原创:从Trading Blox学习海龟交易系统

[复制链接]
发表于 2013-12-29 12:48 | 显示全部楼层

原创:从Trading Blox学习海龟交易系统

来自:MACD论坛(bbs.macd.cn) 作者:hrdeng 浏览:17163 回复:4

本帖最后由 hrdeng 于 2013-12-29 17:55 编辑

      《海龟交易法则》这本书里的图表基本上都是用Trading Blox做出来的,使用后发现通过Trading Blox中的海龟交易系统的应用,对理解《海龟交易法则》非常有帮助,而且也纠正了一些自己以为很关键,但实际并不是很重要的东西。比如,参数优化,其实在海龟系统中“参数优化”的重要性远没有“趋势”重要。



      从上面的橡胶指数测试报告来看,做多的年收益大约是15%,而做空的年收益大约是1%,相差10多倍,我想无论如何“参数优化”也不会达到这个成绩的。所以趋势对这个系统影响是最大的,但在实际操作中如何确定趋势呢?要不要做趋势的判断呢?

     《海龟交易法则》这本书认为对于期望值为正的系统,要坚定不移的按信号去做,也就是说不需要判断趋势的。
     

       最近看了他老师理察·丹尼斯的的访谈录,原文如下:
    问:假如市场出现了某种状况,你的经验与直觉告诉你应该这么做,可是交易系统却指示你做完全相反的动作,你会怎么办?
  答:假如经验与交易系统告诉我完全相反的两种作法,我什么也会不做,一直等到冲突解决之后才行动。
  问:如此说来,假如你的经验告诉你,目前是做多的时机,而你的交易系统却指示你做空,在这种情况下,是否还会做多?
  答:遇到这种情况,我可能什么也不做,而静观其变,同时我也会就这种冲突进行分析,以找出导致冲突的原因。不过,我要强调一点:从事交易,必须设想市场上最不可能发生的变化,并预作准备。        我做了近20年的交易商,不知经历了多少次“市场上最不可能发生的状况”。因此,千万不要以为市场上以前不曾出现过的变化,以后也绝不可能出现。
  问:问你的意思是说,不要太相信历史?
  答:是的。
  问:可是,你是根据历史的记录设计交易系统的,这不是和你的观念相抵触吗?
  答:看来如此,其实不然。一套优越的交易系统应该可以帮助你即时掌握市场行情的波动。假如你研究过1972年黄豆行请变动的轨迹,你可能会因此在每当黄豆上涨50美分之后出场,因为当时黄豆的涨幅从来没有超过50美分。可是,从黄豆行情后来上涨8美元的情况来看,根据历史而下的结论显然是错误的。一套优越的交易系统,应该能够让你掌握到历史以外的大部分行情变动。
  问:你是说不要让自己未来的行动受制于以往的经验?
  答:是的。市场以往变动的轨迹可以告诉你某种市况代表行情会上扬,或是代表涨幅有限,但绝不可能告诉你行情不会再上涨。
     我对他这段话的理解是,海龟系统只是一个辅助工具,用以帮助判断是否在顺势操作。所以,主要还是在于操作者,因此对趋势是有认为主观判断存在的。
  
      那么为何会出现,老师讲要判断趋势,而最好的学生却讲不需要判断趋势呢?我个人理解是背景造成的。
丹尼斯是从场内跑单开始,到后来自己操作,再到后来编制交易规则,再传授给他的学生。
         《海龟交易法则》的作者在学海龟规则的时候才20来岁,就一张白纸,所以他只学到了规则,并要求按规则执行,另外丹尼斯也讲过,他只是把重要的经验用规则表达出来,还有很多没有办法用规则来描述的,所以成了这样的差异。
         对于系统的执行《海龟交易法则》的作者是有优势的,他没有经历,不受以往思维影响,但要想自己开发系统,还是得向丹尼斯学习。所以开发系统与执行系统是有差别的,在实际交易中要注意角色的转换。

       另外一个就是资本规模对投资回报影响也是相当大的,虽然多与空差别很大。以橡胶指数为例,做多的本金加回报大约是三百万,做空的本金加回报大约是三十万,而多空都做的本金加回报则是约八百万,这样的比较足以说明对期望值为正的系统所发出的信号应该坚定不移的去执行。


     以下是参数优化的部分:


    还是橡胶指数,改变参数可以从16%到24%之间,提升幅度还是蛮大的,所以,对于系统参数的优化还是有必要去做,但是重点不要搞错了,顺应趋势是第一位,然后才来优化参数,以提高回报。
    下面是参数优化的3D图,很直观的看到各个参数的表现情况,与差异。



    当参数优化完成后,所得的参数可信度到底有多高呢?这是大家比较关心的问题,Trading Blox引用了“蒙特卡罗”模型来应用。
以下是“蒙特卡罗”的信息:
    蒙特卡罗模拟是一种随机模拟方法。以概率和统计理论方法为基础的一种计算方法。将所求解的问题同一定的概率模型相联系,用电子计算机实现统计模拟或抽样,以获得问题的近似解。为象征性地表明这一方法的概率统计特征,故借用赌城蒙特卡罗命名。又称统计模拟法、随机抽样技术。由S.M.乌拉姆和J.冯·诺伊曼在20世纪40年代为研制核武器而首先提出 。

   

经过“蒙特卡罗”模型的分析,约11%的回报率有90%的可信度。


以上抛砖引玉,请多交流,本人E文不好,软件很多参数设置不是很清楚,希望找一位E文好的朋友帮忙翻译几段,有劳了









本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
金币:
奖励:
热心:
注册时间:
2003-11-13

回复 使用道具 举报

签到天数: 4 天

发表于 2013-12-29 13:05 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
金币:
奖励:
热心:
注册时间:
2010-7-18

回复 使用道具 举报

 楼主| 发表于 2013-12-29 15:05 | 显示全部楼层
Simulation Parameters
Top  Previous  Next  
The following is a comprehensive list of the Trading Blox global Simulation Parameters, and an explanation of how each is used. The global Test Parameter values can be viewed and changed using the Global Parameters tab.  To reset the parameters to their default values, the following picture shows them.

Earn Interest

Set to true to enable earning interest on available cash. Set to false to disable earning interest. The rates are set in the currency rate file for your system base currency. If you are using USD as your system wide base currency, then the rates are in the USD_Rates.txt file in the Forex data directory. The Lending Rate is used when earning interest.
Earned Interest is calculated on the cash balance of the account. Money used to purchase stocks is deducted from this cash balance. Money used as margin for futures trading is not deducted from the cash balance since many brokers will allow T-Bills for margin requirements allowing traders to earn interest on the money that is used for margin.

Slippage

The frictional cost of trading has two components: commissions, and slippage (sometimes also known as "skid"). In actual trading, slippage is the difference between a trade's entry or exit order price, and the price at which the trade is actually filled. In order to accurately reflect the conditions of real trading, the impact of slippage must be simulated during back testing.

Since slippage can vary dramatically from trade to trade, depending on market conditions at the time an order is executed, Trading Blox employs a slippage assessment technique that is based on market volatility.

The simulated fill price is obtained by calculating a slippage factor, which is added to (or subtracted from), the theoretical entry price.

For a long entry, the slippage factor is calculated by measuring the range from the theoretical entry price to the day's highest price, and multiplying that amount by the Slippage Percent. (For short entries, the slippage factor is calculated by measuring the range from the theoretical entry price to the low). The slippage factor is then added to, or subtracted from the theoretical entry price, to obtain the simulated fill price.


Here's how it works for a buy trade:

Slippage percent
25%

Theoretical buy order price
100

High Price (for the day)
120

Slippage Factor
(120 - 100) x 0.25 = (20 x 0.25) = 5

Simulated fill price
Order Price + Slippage Factor = (100 + 5) = 105




The distance between the high price and the order price is multiplied by the slippage factor. In this example, the difference between the high price and the order price is 20 points. The 20 points are multiplied by the 25% slippage to get an estimated slippage of 5 points. The fill price for the order will be 5 points worse than the stop order price of 100 simulating a fill at 105.



Slippage for sell orders is computed using a similar calculation using the distance between the order price and the low of the day.



In historical back testing, failing to accurately estimate slippage can lead to two types of mistakes: Underestimating frictional costs may lead you to trade a system that produces spectacular hypothetical results, but does not hold up well under real trading. Conversely, overestimating frictional costs may dissuade you from trading an otherwise good system.



It is also worth noting that the more frequently a system trades, the more profound the impact of frictional costs will be.





Minimum Slippage

Applies to Futures only. Minimum Slippage is based on a fixed currency value. This parameter works in conjunction with Slippage Percent (above).



If set to a non-zero value, this parameter ensures that some slippage cost is assessed against every trade. Trading Blox will impose Minimum Slippage only if the currency value resulting from the Slippage calculation (based on Slippage Percent, above) is less than the currency value of slippage as calculated by the Minimum Slippage parameter.



Where entry occurs at or near the high or the low of the day, the potential adverse range is practically nonexistent, so the Slippage Percent calculation would be at or near zero. In this case, Minimum Slippage can ensure that some slippage is assessed on the trade.



If Slippage Percent is set to zero, then the slippage for all trades will be the value specified by the Minimum Slippage parameter value.



Notes: Can cause fill price to be outside of daily high low range.





Max Percent Market Volume

Max Percent Market Volume determines the maximum trade size based on a percentage of the current volume. For example, if the volume is 200,000 shares and this parameter is set to 2%, this means that the maximum allowed trade size is 2% of 200,000 or 4,000 shares. If an order is placed for 6,000 shares, it will be reduced to 4,000 shares, and an entry will show in the Filtered Trade Log so that you are aware that the order size was reduced. The volume used is the 5-bar exponential moving average of the volume.





Max Margin/Equity to trade

The default is 100%, in that if a requested trade would require more than 100% of available equity in margin or cash, then the trade will be filtered. This parameter allows you to mofidy this behavior. If you enter 50 here, the system will filter trades if the new total margin required would be greater than 50% of the total available equity.





Trade Always on Tick

When this parameter is set to false, the system will trade with maximum precision. So if the system buys Gold on a stop at the moving average, which is 365.44789, then the system will buy at that exact value. Conversely it will exit the trade at an exact value as well. The trade price as listed in the trade details will only show the digits of precision of the instrument, as set in the Futures Dictionary, so the trade price would look like 36.45. But the trade profit would not match that value exactly.



When this parameter is set to true, the system will always trade on the tick. It will round up to the nearest tick for buy orders, and down for sell orders. So in the above example, if you placed an order to buy on stop at 365.44789, the system would place the order to buy at 365.45.



The fill prices would also be on tick, so a slippage of 10% could become more as the order price and then fill price gets pushed to a tick.





Smart Fill Exit (Smart Exit Fills)

When set to true, this function will only fill the exit stop/limit order closest to the open for any particular unit. This can be helpful when using multiple exit blox that place stop/limit orders. If the open is at 10, (and the high is 12 and the low is 7), and you have an exit stop at 11 and a limit order at 8, the stop exit order will be filled.





Entry Day Retracement

This is used to determine if a new position would have been stopped out on the same day as entry.



The Entry Day Retracement percent is multiplied by the distance from the high to the low of the day.This amount is then added/subtracted from the order fill price. This is the Trigger Price and if  this number is beyond the stop price, then the entry is stopped out same day.



For long entries the Trigger Price is the Fill Price - ( High - Low ) * Retracement %

For short entries the Trigger Price is the Fill Price + ( High - Low ) * Retracement %



The Trigger Price is never more than the High, or less than the Low.

The Trigger Price is never more than the close for long entries, or less than the close for short entries.



In this way, a Retracement % of zero will use the default behavior outlined below (aggressive approach). A Retracement % of 100 will use the extreme of the day (conservative approach).



In addition to the above rules, as a default:

· If the position was filled during the day (stop/limit orders), and the close is less than the stop for long entries or more than the stop for short entries, then the position is stopped out

· If the position was filled on the open of the day, and the low is less than the stop for long entries or the high is more than the stop for short entries, then the position is stopped out





Use Broker Positions

Set to true to insert the broker positions, as entered in the Broker Position Editor, into the simulation. These positions will be entered for both testing and order generation.





Ignore All Test Positions

Set to true to ignore all the test generated positions. Use this when the only positions you want in the test, or order generation, are the broker positions. Use Broker Positions must be true for Ignore All Test Positions to have an effect. Often this is used on the very first day of order generation so that you can start with a clean slate and no open positions. If you want a mix of actual positions and theoretical test positions, then leave this box unchecked.





Use Start Date Stepping

Set to true or false to enable or disable the the Increment Test Start option and the Set Test Duration Option.





Increment Test Start ( trading days )

This feature is useful for testing a system's robustness by varying the start date without running multiple tests.  This setting will use the initial test start date but will add the number of trading days (weekdays) to it.  For instance, if your original test settings are 2005-01-03 and you enter a value of 3 here, your actual trading will start on 2005-01-06.  If you step from 0 to 2, you will get results starting in 2005-01-03, 2005-01-04, 2005-01-05.



The new start date cannot be beyond the test end date set by the user.





Set Test Duration ( trading days )

This setting overrides the original test end date setting.  It is useful for testing system robustness by varying the test duration without running multiple tests. If you set this value to 100, every test regardless of start date will be 100 days. Note that the maximum test end date is still the date you entered, so be sure to leave room for both the start date stepping and the test duration so every test is the same length.



ie Test Start is 1995-01-01 Test End is 2005-01-01

Increment Test Start from 0 to 250 Step 10 (one year step 2 weeks)

Set Test Duration to 2000 (8 years)



The new test end date ( the test start plus duration ) cannot be beyond the test end date as entered by the user.





Minimum Futures Volume

This parameter applies only to futures. It establishes the minimum daily trading volume, in contracts, required to enter a futures position. It is based on a 5-day exponential moving average of the volume. This value can be viewed by using the instrument.averageVolume property when using the Builder Edition.





Commission per Contract

This parameter indicates the round-trip charge for each futures contract traded. Assuming a Commission per Contract of $12.50, buying and then subsequently selling 1,000 contracts of sugar would result in a total transaction cost of ($12.50 per contract) x (1,000 contracts) = $12,500.





Trade Futures on Lock Day

When this parameter is set to false, the simulation will not fill entry or exit orders on days when the high = low, when the trade is in the direction of the lock. The idea is that in futures this could be a lock limit day, and it would be the most conservative assumption to assume you did not get filled.



If you set this parameter to true, you will be filled on these days. This applies to futures only.



Example: With this parameter set to false, and the high equals the low, so it is considered a lock day. If you want to enter long, or exit a short position, and the close of the lock day is less than the close of yesterday, then it will be allowed. But if the close of the lock day is greater than or equal to the close of yesterday, then the fill will be denied.





Account for Contract Rolls

This parameter applies only to futures, and controls whether or not Trading Blox should account for the increased commission and slippage that would have resulted when rolling contracts when a position is held for a long period of time.



If your data includes the Delivery Month of the futures contract being used on any given day in the backadjusted data, then Trading Blox will use this to determine when to roll. It will account for a roll every time the delivery month changes.



If your data does not include the Delivery Month, Trading Blox will estimate when a roll would occur based on the number of trading months listed in the Futures Dictionary. If you actually roll less often than you have months listed, then you should reduce the list to just the roll months, for most accurate results here.



If there are 4 trading months, then Trading Blox will calculate a contract roll every 3 months. If there are 12 trading months, Trading Blox will calculate a contract roll every month. The first simulated roll will occur in 1/2 the normal roll frequency because, on average, the first contract will be entered with 1/2 its trading life left. This process is based on calendar days and works for intraday, daily, weekly, or monthly data.



Each time a simulated roll occurs, Trading Blox accounts for the roll by deducting slippage and commissions for each contract in the position. The Open Equity is moved to Close Equity. If the futures is non-USD denominated, the currency conversion for the roll date will be used to move profit from open equity to closed. So the profit is locked in at the conversion rate of the roll.





Roll Slippage (% of ATR)

This option is available when Account for Contract Rolls is set to true.



The slippage used is the roll slippage percent of the Wilder 20-day ATR (39 day non SMA primed Exponential Moving Average of the True Range). This is an unprimed value, and can be accessed by the instrument.defaultAverageTrueRange property.





Minimum Stock Volume

This parameter applies only to stocks. It establishes the minimum daily trading volume, in shares, required to enter a stock position. It is based on a 5-day exponential moving average of the volume. This value can be viewed by using the instrument.averageVolume property when using the Builder Edition.





Commission per Trade

This parameter indicates the commission charged on a per trade basis. This type of commission charge is used by some brokers for stock brokerage accounts.



Assuming a theoretical Commission per Trade of $5.00; Buying 100 shares of XYZ stock would count as one trade, and selling that same 100 shares would be a second trade, for a total transaction cost of $10.00.





Commission per Stock Share

This parameter indicates the round-trip charge for each stock share traded. This can be used in place of or in addition to the Commission per Trade. For example, assuming a Commission per Contract of $0.02, buying and then selling 1,000 shares of IBM would result in a total transaction cost of ($0.02 per share) x (1,000 contracts) = $20.00. NOTE: Most stock brokerages charge commission for each one-way trade, once for the entry, once for the exit For Trading Blox, use a Commission per Stock Share of double the per share commission charged by your broker for one-way trades.





Commission by Stock Value

Uses a percent of the stock value as the commission amount.





Convert Profit by Stock Splits

With stocks, when the data is backadjusted for stock splits, the profits made/lost are respectively smaller as the prices get smaller. Take MSFT as an example. The close on Jan 2, 1987 was $47.75, and the close on Feb 2 was $73.00. But your backadjusted data will probably show around $.17 on Jan 2 and $.25 on Feb 2. So if you bought 100 shares at the close on Jan 2 and sold at the close on Feb 3, you would have made $25.25 per share, or $2,525 total. But many simulations would show a profit of just $.08 per share, or $8 total.



If you set this parameter to true, Trading Blox will determine that the real profit for this trade was $25.25 per share. Your simulation will then be accurate even though the data has been adjusted.



Trading Blox will convert the profit on each trade by the stock split ratio between the trade entry and the trade exit, and it will also convert the volume in the data file back to the real volume amount using the stock split ratio. This volume number is only used for the AverageVolume property, which is used for the Max Percent Volume per Trade and Minimum Stock Volume global parameters. You can also access these properties as instrument.adjustedVolume, and instrument.averageVolume.



The stock split ratio is the unadjusted close / close for any given day, so be sure to include the unadjusted close in the data.



Create two MFST files in CSI, one with no adjustements, and one with stock split adjustments. If you look at the volume on 2005-01-03 for MSFT using the unadjusted data, you will see that the volume presented is 39,545,600. (Note that there is a volume multiplier of 100 in play here as well, so the number you see is actually 395456.) The stock split ratio on that day is 16, so the actual volume traded was 2,471,600. If you are trading a max percent of the day's volume, then you would want to use the adjusted volume number rather than the unadjusted number that is provided in the data file.



Likewise, if you use the example above, you want to make sure the profit on a 100 share trade reflects the actual value of that trade in 'todays' dollars. So Trading Blox converts the profit using the stock split ratio as of the trade entry.



In addition, Trading Blox needs to know when the stock split was, in relation to the dividend distribution. So if you purchased 100 shares, the stock had a 2x stock split, and then a $.50/share dividend, that is a different profit than if you purchased 100 shares, the stock had a $.50/share dividend, and then it had a 2x stock split.



This is why it's important to keep the stock splits and dividends separate. The stock splits alter the data in a geometric manner, whereas the dividends are simple unadjusted per share amounts. If you try to stuff proportionally adjusted dividend data into a stock split adjusted series, you will get the wrong P&L everytime.



So, set your CSI UA to adjust the stock data by stock splits only, be sure to include the unadjusted close, and call CSI to get the unencrypted dividend data so Trading Blox can build those files for you. CSI will provide the unencrypted dividend data to all Trading Blox customers free of charge.







Pay Dividends

Set to true to account for dividends in the test. The dividend files should be setup in the Dividends folder. The dividend file suffix can be changed in the INI file.





Pay Margin on Stocks

This parameter is for stocks only, and defines whether the system will charge margin for excess cash used when buying stocks. The values used are from the system wide base currency rate files. In the case of USD, the file is the USD_Rates.txt file in the forex data directory. The Borrow Rate is used when accounting for margin.



Margin Interest is charged every day when available cash falls below zero.





Forex Trade Size

The inter-bank forex market trades in units of 100,000 base currency. Many retail forex brokers allow trading units of smaller size. This parameter controls the unit size to allow for simulation of trading through retail forex brokers.





Account for Forex Carry

This determines whether or not to account for Forex Carry charges (see Forex Carry Calculations for details).





Use Pip-Based Slippage

Since many retail Forex brokers have fixed spreads per market and guarantee "zero slippage" fills, Trading Blox provides for this using a fixed per-market slippage which is defined by the spread in pips for each market. The spread for each market should be set to the figures your Forex broker uses or a larger number for more conservative testing. See Forex Dictionary for information on changing the Forex market spreads.



When set to TRUE, the parameter Use Pip-Based Slippage overrides the normal  Trading Bloxslippage calculations (based on a fixed amount or percentage) for the Forex markets only.





See also the tradingblox.ini file for more settings options.


金币:
奖励:
热心:
注册时间:
2003-11-13

回复 使用道具 举报

 楼主| 发表于 2013-12-29 15:08 | 显示全部楼层
以上是软件设置详细说明,请E文好的朋友帮忙翻译一下不胜感激,在线网页翻译我已经使用过了,请不要发直接网页翻译的,谢谢!
金币:
奖励:
热心:
注册时间:
2003-11-13

回复 使用道具 举报

发表于 2017-3-19 17:49 | 显示全部楼层
看来研究tb的朋友 不多。
金币:
奖励:
热心:
注册时间:
2006-5-17

回复 使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站声明:1、本站所有广告均与MACD无关;2、MACD仅提供交流平台,网友发布信息非MACD观点与意思表达,因网友发布的信息造成任何后果,均与MACD无关。
MACD俱乐部(1997-2019)官方域名:macd.cn   MACD网校(2006-2019)官方域名:macdwx.com
值班热线[9:00—17:30]:18292674919   24小时网站应急电话:18292674919
找回密码、投诉QQ:89918815 友情链接QQ:95008905 广告商务联系QQ:17017506 电话:18292674919
增值电信业务经营许可证: 陕ICP19026207号—2  陕ICP备20004035号

举报|意见反馈|Archiver|手机版|小黑屋|MACD俱乐部 ( 陕ICP备20004035号 )

GMT+8, 2024-3-28 18:59 , Processed in 0.073864 second(s), 11 queries , Redis On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表