轉帖:不錯的採用神經網路EA(自動交易系統)
國際大賽的第一名為Better所奪得
三個月結束時他的EA(自動交易系統)
把本金從$10000增加成$130 475.45
他採用的就是神經網路原理的EA
這使得用神經網路方法做EA成為不少人關注的焦點
這裡翻譯一篇採用神經網路做EA的不錯的示例文章當然附有原始碼是吸引人的地方
不過也許作者提出了研究神經網路EA的一些思考更為值得注意
作者提出了∶
1。“如果有飛機,為什麼還要教人類去飛?”
意思是研究是經網路不必從零起步。MT4裡已有了不錯的“遺傳演算法”
文中介紹瞭如何利用MT4已有的“遺傳演算法”
2。大家都說做單子最重要的是“順勢而為”,但更需要解決的是∶
“一個基於趨勢的交易系統是不能成功交易在盤整(sideways trends),
也不能識別市場的回撥(setbacks)和逆轉(reversals.,反向走勢)!”
這可是抓到不少人心中的“癢處” ,有多少人不是到了該逆勢時沒轉向而產生虧損呢?
3。訓練神經網路需要用多長的歷史資料,提出了並不是用的歷史資料越長越好,另外也不是訓練的間隔越短越好,文中提出了什麼情況下有需再訓練它。
4。示例當然僅是示例
等等。。
一個朋友看了就覺得不錯拿去發表了
這裡發表以饗這裡的朋友
下面是譯文和作者的原文
The problem is stated for this automated trading system (ATS) as follows:
(ATS)自動的(智慧的,採用神經網路的)交易系統的問題表述如下
Let's consider we have a basic trading system - BTS. It is necessary to create and teach a neural network in order it to do things that cannot be done with the BTS. This must result in creation of a trading system consisting of two combined and mutually complementary BTS and NN (neural network).
如果我們有一個(BTS, basic trading system),同時需要用建立一個神經網路系統並教會它做BTS所不能做的事,按這個思路就是要建立這樣一個交易系統∶它由互相補充(配合)的兩部分組成,BTS和NN(神經網路)。
Or, the English of this is: There is no need to discover the continents again, they were all discovered. Why to teach somebody to run fast, if we have a car, or to fly, if we have a plane?
呃,英語說,我們不需要再去發現“新大陸”,它們是已經存在的東西!進一步說,如果我們已經有了汽車,那為什麼還要教人如何跑得快?如果有飛機,為什麼還要教人類去飛?
Once we have a trend-following ATS, we just have to teach the neural network in countertrend strategy. This is necessary, because a system intended for trend-based trading cannot trade on sideways trends or recognize market setbacks or reversals. You can, of course, take two ATSes - a trend-following one and a countertrend one - and attach them to the same chart. On the other hand, you can teach a neural network to complement your existing trading system.
一旦有一個趨勢交易系統的ATS,我們僅需要教會這個神經網路如何逆勢(反趨勢)交易的策略。這一點是非常必要的,因為一個基於趨勢的交易系統是不能成功交易在盤整(sideways trends),也不能識別市場的回撥(setbacks)和逆轉(reversals.,反向走勢)!當然,你可以採用兩個ATS,一個基於“趨勢”,一個基於“反趨勢”(逆向),然後把它們掛到同一圖表上。另一個辦法是,你能教會神經網路如何與你現有的系統“互補地”協調工作!
For this purpose, we designed a two-layer neural network consisting of two perceptrons in the lower layer and one perceptron in the upper layer.
為實現這個目標,我們設計了一個兩層的神經網路,下層有兩個感知機(perceptrons)上層有一個感知機。
The output of the neural network can be in one of these three states:
這個神經網路的能輸出下列三種狀態之一
Entering the market with a long position
(Entering)市場是處在多向倉
Entering the market with a short position
(Entering)市場是處在空向倉
Indeterminate state
不確定的, (不明確的, 模糊的)狀態
Actually, the third state is the state of passing control over to the BTS, whereas in the first two states the trade signals are given by the neural network.
實際上,第三種狀態是就把控制權交給BTS,反之前兩種狀態是交易訊號由神經網路給出。
The teaching of the neural network is divided into three stages, each stage for teaching one perceptron. At any stage, the optimized BTS must be present for perceptrons to know what it can do.
神經網路的“教育”分成三步驟,每一步驟“教育”一個感知機,在任何一步驟,這個最佳化了的BTS必須存在為的是“感知機們”知道它自己能做什麼。
The sep***te teaching of perceptrons by a genetic algorithm is determined by the lack of this algorithm, namely: The amount of inputs searched in with the help of such algorithm is limited. However, each teaching stage is coherent and the neural network is not too large, so the whole optimization does not take too much time.
感知機們分別的“教育”由遺傳演算法來承擔,由於這樣的演算法的缺乏,換句話說,搜尋到的這樣的演算法有限,限制了“輸入”(引數變數)的數量(藉助這樣演算法得到的引數變數的值),然而,每一步驟的“教育”是密切配合補充的。(因此效果還是不錯),這樣這個神經網路不會太大,整個的最佳化也不會耗費太多的時間。
The very first stage, preceding the teaching of an NN, consists in optimization of the BTS.
在“教育”NN之前的一步是對BTS進行最佳化。
In order not to lose ourselves, we will record the stage number in the input of the ATS identified as "pass". Identifiers of inputs corresponding with the stage number will and in the number equal to this stage number.
為了不使我們自己也被搞糊塗了,我們將已經測試透過的ATS的輸入(引數變數)記錄上(”透過”("pass")的步驟號(stage number).,輸入s(引數變數)的識別符號將和stage number(步驟號)一致(等同)。
Thus, let's start prep***tions for optimization and teaching the NN. Let's set the initial deposit as $1000000 (in order not to create an artificial margin call during optimization) and the input to be optimized as "Balance" in Expert Advisor properties on the tab of "Testing" in the Strategy Tester, and start genetic algorithm.
這樣,我們開始對這個NN進行最佳化和“教育”的準備。存入初始保證金為$100萬(以便於在最佳化期間不產生人為的補充保證金的通知)。Input(引數變數)是按“餘額”進行最佳化,設定EA的Strategy Tester的測試的屬性tab為"Testing" 。開始執行遺傳演算法。
Let's go to the "Inputs" tab of the EA's properties and specify the volume of positions to be opened by assigning the value 1 to the identifier "lots".
在這個EA的開倉量 "lots".的值設為1 lot。
Optimization will be performed according to the model: "Open prices only (fastest method to analyze the bar just completed, only for EAs that explicitly control bar opening)", since this method is available in the ATS algorithm.
從這個ATS演算法明確地有效開始,實施最佳化,所採用覆盤模型是∶“僅用開盤價(以最快速的方法分析剛形成的柱線)”。
Stage 1 of optimization. Optimization of the BTS:
最佳化步驟1,BTS的最佳化
Set the value 1 for the input "pass".
設定為 1 為這input(引數變數)“為透過”(the input "pass")。
We will optimize only inputs that correspond with the first stage, i.e., that end in 1. Thus, we check only these inputs for optimization, and uncheck all others.
我們僅僅最佳化步驟1相關的那些inputs(引數變數),即,尾標為 1 的引數變數,於是,我們僅僅測試最佳化有關的inputs而不測試其他的變數引數
tp1 - TakeProfit of the BTS. It is optimized with the values within the range of 10 to 100, step 1
tp1,BTS的所取的止盈值(TakeProfit)。在step 1,最佳化的值的範圍在10到100,
sl1 - StopLoss of the BTS. It is optimized with the values within the range of 10 to 100, step 1
sl1,BTS的所取的止損值(StopLoss)。在step 1,最佳化的值的範圍在10到100 。
p1 - period of CCI used in the BTS. It is optimized with the values within the range of 3 to 100, step 1
pl, 用於BTS的CCI的週期值。在step 1 ,最佳化的值的範圍在 3到100
Stage 2. Teaching the perceptron responsible for short positions:
步驟 2 ,“教育負責管“開空倉”(short positions)的感知機
Set the value 2 (according to the stage number) for the input "pass".
根據步驟的步驟號,設定(input,引數變數) 的"pass"的值為 2。
Uncheck the inputs checked for optimization in the previous stage. Just in case, save in a file the inputs obtained at the previous stage.
不測試那些已經測試過的最佳化了的以前步驟的inputs.(變數引數)。以防萬一,儲存以前步驟獲得的inputs(變數引數值)到一個檔案中去
Check the inputs for optimization according to our rule: their identifiers must end in 2:
根據我們的規則,必須是測試那些是在尾標為 2的inputs(變數引數)。
x12, x22, x32, x42 - weight numbers of the perceptron that recognizes short positions. It is optimized with the values within the range of 0 to 200, step 1
x12, x22, x32, x42 是識別並開空倉的感知機的權重,它們的值在step 1時被最佳化在範圍0 to 200
tp2 - TakeProfit of positions opened by the perceptron. It is optimized with the values within the range of 10 to 100, step 1
tp2 (TakeProfit) 是感知機所開的倉的止盈值,它們的值在step 1時被最佳化在範圍10 to 100。
sl2 - StopLoss of positions opened by the perceptron. It is optimized with the values within the range of 10 to 100, step 1
sl2 (StopLos) 在 step 1它是感知機所開的倉的止損值,被最佳化值的範圍在 10 to 100
p2 - the period of the values of price difference to be analyzed by the perceptron. It is optimized with the values within the range of 3 to 100, step 1.
p2 感知機所分析的價格差的週期值 (iiCCI()函式的一個引數∶period - Averaging period for calculation),在step 1 它的值所最佳化的範圍在3 to 100
Let's start teaching it using optimization with a genetic algorithm. The obtained results are given below:
現在,開始用遺傳演算法來最佳化“教育”NN(讓它“學習”市場),獲得的結果如下∶
Stage 3. Teaching the perceptron responsible for long positions:
步驟 3 “教育”負責開多倉的感知機(“學習”市場)。
Set the value 3 (according to the stage number) for the input "pass".
設定值 3 (根據步驟的步驟號)說明這些input(變數引數)已經“透過”(the input "pass")
Uncheck the inputs checked for optimization in the previous stage. Just in case, save in a file the inputs obtained at the previous stage.
同樣,不測試,那些已經測試過的最佳化了的,以前步驟的inputs.(變數引數值),以防萬一,儲存以前步驟獲得的inputs.(變數引數值) 到一個檔案中去
Check the inputs for optimization according to our rule: their identifiers must end in 3:
根據我們的規則,最佳化測試的inputs(變數引數值)必須是尾標為3的那些變數引數。
x13, x23, x33, x43 - weight numbers of the perceptron that recognizes long positions. It is optimized with the values within the range of 0 to 200, step 1.
x13, x23, x33, x43是識別多倉的感知機的權重,它們的值在step 1時被最佳化時得到的範圍在0 to 200
tp3 - TakeProfit of positions opened by the perceptron. It is optimized with the values within the range of 10 to 100, step 1
tp 3 (TakeProfit) 是感知機所開的倉的“止盈值”,它的值在step 1時被最佳化時的範圍是在10 to 100。
sl3 - StopLoss of positions opened by the perceptron. It is optimized with the values within the range of 10 to 100, step 1
sl3 (StopLoss) 是感知機所開的倉的“止盈值”,它們的值在step 1時被最佳化為範圍是10 to 100。
p3 - the period of the values of price difference to be analyzed by the perceptron . It is optimized with the values within the range of 3 to 100, step 1.
p3 --感知機所分析的價差的週期值。它在步驟 1 最佳化時得到的值的範圍是 3 to 100 。
Let's start teaching it using optimization with a genetic algorithm. The obtained results are given below:
啟動採用遺傳演算法的最佳化來“教育”NN,所獲得的結果如下∶
Stage 4 (final). Teaching the first layer, i.e., teaching the perceptron that is in the upper layer:
步驟 4 (最終步驟) “教育”第一層,即“教育”在上層的感知機。
Set the value 4 (according to the stage number) for the input "pass".
根據步驟的步驟號,設定值4 為輸入透過(for the input "pass")
Uncheck the inputs checked for optimization in the previous stage. Just in case, save in a file the inputs obtained at the previous stage.
不測試那些在之前步驟已經測試過的最佳化了的“輸入” (inputs) (意思是∶已經在之前步驟最佳化過的變數的引數值就不再最佳化它們了)。以防萬一,將之前步驟獲得的這些變數的引數值存到一個檔案中去。
Check the inputs for optimization according to our rule: their identifiers must end in 4:
根據我們的規則,只測試最佳化識別符號最後位是4的那些inputs(變數的引數值)
x14, x24, x34, x44 - weight numbers of the perceptron of the first layer. It is optimized with the values within the range of 0 to 200, step 1.
x14, x24, x34, x44 是第一層感知機引數的權重值。在步驟 1 時它們被最佳化的值的範圍在0 io 200 。
p4 - the period of the values of price difference to be analyzed by the perceptron. It is optimized with the values within the range of 3 to 100, step 1.
p4 被感知機分析的價差的值的週期。在步驟 1 它的值的範圍被最佳化在 3 to 100 。
Let's start teaching it using optimization with a genetic algorithm. The obtained results are given below:
採用遺傳演算法來最佳化,啟動“教育”來教它“學習”。所獲得結果如下∶
That's all, the neural network has been taught.
這就是全部,神經網路已經被“教育”了。
The ATS has one more non-optimizable input, mn - Magic Number. It is the identifier of positions for a trading system not to mix its orders with the orders opened manually or by other ATSes. The value of the magic number must be unique and not coincide with the magic numbers of positions that have not been opened by this specific Expert Advisor.
這個ATS有一個不能被最佳化的input(引數) mn-- Magic Number.(魔法號)它是一個交易系統它所開的倉位的識別符,為的是不和手動開倉或其他ATSes開的倉位混淆。這個Magic Number的值必須是唯一的並且和這個特別的ea尚未開倉的magic numbers不一致。
P.S.
The size of the initial deposit is found as the doubled absolute drawdown, i.e., we consider some safety resources for it.
出於保證有一些安全保險的考慮,初始保證金的金額設定是考慮為絕對最大回落的兩倍
The EA given in the source codes is not optimized.
這個ea的原始碼沒有最佳化。
If you need to replace the built-in BTS with the algorithm of another trading system, you must modify the contents of the function basicTradingSystem().
如果你需要置換嵌入另一個交易系統演算法的BTS,你必須修改BTS功能的內部。
In order not to enter the initial and the final values and the values of steps for optimization, you can take the ready file combo.set, place it in the folder tester MT4, and upload to the EA's properties in Tester.
以便於不輸入最佳化時的初值,終值和步長,你可採用已備好的combo.set檔案,把它放置到MT4的 tester 目錄並載入這個ea的屬性(properties)到Strategy Tester。
Re-optimization of the EA is to be performed at a weekend, i.e., on Saturday or on Sunday, but only if the results of the preceding week were unprofitable. The presence of losses means that the market has changed, and the re-optimization is necessary. The presence of profits means that the ATS does not need any re-optimization and recognizes market patterns quite well.
這個ea的再最佳化可在週末進行,即週六和週日,但僅在前面一週的結果是不盈利的。虧損的出現意味著市場已經改變,於是需要重新最佳化,若是仍然獲利意味著這個ATS不需要重新最佳化,它對市場目前的模型的識別繼續有效!
5 comments
Subscribe to discussion
sstef wrote:
backtests seems ok, how about forward tests ?
Try independet without me. You all have for original forward and other tests: open source, tester, head and hands.
reply 08.03.2008 08:57 Reshetov
thanks a lot Reshetov,
very simple but very powerful, i have never think about this idea,
backtests seems ok, how about forward tests ?
reply 07.03.2008 23:42 sstef
tws0124 wrote:
What is the number of pass?
Try test for pass value of 1, 2, 3 and 4
What is best of the best, that use (right solution: pass = 4)
reply 07.03.2008 10:45 Reshetov
All the optimization is completed, now I use it by live account, What is the number of pass?
Sorry,bad English...
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/205798/viewspace-1019306/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 模糊神經網路系統1神經網路
- 自動駕駛汽車測試新方法 DeepTest:可自動測試深度神經網路駕駛系統自動駕駛神經網路
- Sugeno型(TS型)模糊推理系統及自適應神經網路的模糊推理系統(anfis)應用神經網路
- Piper: 快速、本地化的神經網路文字轉語音系統神經網路
- [譯] 除錯神經網路的清單除錯神經網路
- 【自己動手寫神經網路】---人人都可以學的神經網路書神經網路
- 從傳統的神經元網路轉變到深度學習網路深度學習
- 如何除錯神經網路引數除錯神經網路
- 神經網路啟用函式=生物轉換器?神經網路函式
- 利用進化方法自動生成神經網路:深度進化網路DENSER神經網路
- 自適應模糊神經網路的設計神經網路
- 4種除錯深度神經網路的方法除錯神經網路
- 神經網路:numpy實現神經網路框架神經網路框架
- 如何應對訓練的神經網路不工作?神經網路
- 神經網路神經網路
- 【深度學習篇】--神經網路中的卷積神經網路深度學習神經網路卷積
- 百行程式碼構建神經網路黑白圖片自動上色系統行程神經網路
- 神經網路的直觀解釋(轉載)神經網路
- 一文了解推薦系統中的圖神經網路神經網路
- 神經網路的啟用函式總結神經網路函式
- 神經網路中使用的啟用函式神經網路函式
- LSTM神經網路神經網路
- 8、神經網路神經網路
- BP神經網路神經網路
- 模糊神經網路神經網路
- 【轉帖】兒童服暈車藥影響神經系統 6招緩解孩子暈車
- 聊聊從腦神經到神經網路神經網路
- 關於ORACLE自動統計CBO統計資訊[轉帖]Oracle
- 圖神經網路GNN 庫,液體神經網路LNN/LFM神經網路GNN
- 比特幣自動交易軟體_套利交易系統比特幣
- 優惠網路影片教育交易系統
- 為什麼說BP神經網路就是人工神經網路的一種?神經網路
- 用一個畫素攻陷神經網路神經網路
- 卷積神經網路-啟用函式卷積神經網路函式
- 網路管理員指南 -11.網路檔案系統NFS -4>自動mount(轉)NFS
- 用神經網路測量訓練集的半衰期神經網路
- Tensorflow中神經網路的啟用函式神經網路函式
- 神經網路篇——從程式碼出發理解BP神經網路神經網路