




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、Good is good, but better carries it.精益求精,善益求善。一個神經(jīng)網(wǎng)絡(luò)的EA的示例-一個神經(jīng)網(wǎng)絡(luò)的EA的示例(含源碼)Combo_Right.mq4軟件簡介:去年年底結(jié)束的國際大賽的第一名為Better所奪得他采用的就是神經(jīng)網(wǎng)絡(luò)原理的EA這使得用神經(jīng)網(wǎng)絡(luò)方法做EA成為不少人關(guān)注的焦點這里翻譯一篇采用神經(jīng)網(wǎng)絡(luò)做EA的不錯的示例文章當(dāng)然附有源碼是吸引人的地方不過也許作者提出了研究神經(jīng)網(wǎng)絡(luò)EA的一些思考更為值得注意作者提出了1。“如果有飛機(jī),為什么還要教人類去飛?”意思是研究是經(jīng)網(wǎng)絡(luò)不必從零起步。MT4里已有了不錯的“遺傳算法”文中介紹了如何利用MT4已有的“遺傳算
2、法”2。大家都說做單子最重要的是“順勢而為”,但更需要解決的是“一個基于趨勢的交易系統(tǒng)是不能成功交易在盤整(sidewaystrends),也不能識別市場的回調(diào)(setbacks)和逆轉(zhuǎn)(reversals.,反向走勢)!”這可是抓到不少人心中的“癢處”,有多少人不是到了該逆勢時沒轉(zhuǎn)向而產(chǎn)生虧損呢?3。訓(xùn)練神經(jīng)網(wǎng)絡(luò)需要用多長的歷史數(shù)據(jù),提出了并不是用的歷史數(shù)據(jù)越長越好,另外也不是訓(xùn)練的間隔越短越好,文中提出了什么情況下有需再訓(xùn)練它。等等。下面是譯文和作者的源碼Theproblemisstatedforthisautomatedtradingsystem(ATS)asfollows:(ATS)自
3、動的(智能的,采用神經(jīng)網(wǎng)絡(luò)的)交易系統(tǒng)的問題表述如下Letsconsiderwehaveabasictradingsystem-BTS.ItisnecessarytocreateandteachaneuralnetworkinorderittodothingsthatcannotbedonewiththeBTS.ThismustresultincreationofatradingsystemconsistingoftwocombinedandmutuallycomplementaryBTSandNN(neuralnetwork).如果我們有一個(BTS,basictradingsystem),
4、同時需要用創(chuàng)建一個神經(jīng)網(wǎng)絡(luò)系統(tǒng)并教會它做BTS所不能做的事,按這個思路就是要創(chuàng)建這樣一個交易系統(tǒng)它由互相補(bǔ)充(配合)的兩部分組成,BTS和NN(神經(jīng)網(wǎng)絡(luò))。Or,theEnglishofthisis:Thereisnoneedtodiscoverthecontinentsagain,theywerealldiscovered.Whytoteachsomebodytorunfast,ifwehaveacar,ortofly,ifwehaveaplane?呃,英語說,我們不需要再去發(fā)現(xiàn)“新大陸”,它們是已經(jīng)存在的東西!進(jìn)一步說,如果我們已經(jīng)有了汽車,那為什么還要教人如何跑得快?如果有飛機(jī),為什么還
5、要教人類去飛?Oncewehaveatrend-followingATS,wejusthavetoteachtheneuralnetworkincountertrendstrategy.Thisisnecessary,becauseasystemintendedfortrend-basedtradingcannottradeonsidewaystrendsorrecognizemarketsetbacksorreversals.Youcan,ofcourse,taketwoATSes-atrend-followingoneandacountertrendone-andattachthemtot
6、hesamechart.Ontheotherhand,youcanteachaneuralnetworktocomplementyourexistingtradingsystem.一旦有一個趨勢交易系統(tǒng)的ATS,我們僅需要教會這個神經(jīng)網(wǎng)絡(luò)如何逆勢(反趨勢)交易的策略。這一點是非常必要的,因為一個基于趨勢的交易系統(tǒng)是不能成功交易在盤整(sidewaystrends),也不能識別市場的回調(diào)(setbacks)和逆轉(zhuǎn)(reversals.,反向走勢)!當(dāng)然,你可以采用兩個ATS,一個基于“趨勢”,一個基于“反趨勢”(逆向),然后把它們掛到同一圖表上。另一個辦法是,你能教會神經(jīng)網(wǎng)絡(luò)如何與你現(xiàn)有的系統(tǒng)“
7、互補(bǔ)地”協(xié)調(diào)工作!Forthispurpose,wedesignedatwo-layerneuralnetworkconsistingoftwoperceptronsinthelowerlayerandoneperceptronintheupperlayer.為實現(xiàn)這個目標(biāo),我們設(shè)計了一個兩層的神經(jīng)網(wǎng)絡(luò),下層有兩個感知機(jī)(perceptrons)上層有一個感知機(jī)。Theoutputoftheneuralnetworkcanbeinoneofthesethreestates:這個神經(jīng)網(wǎng)絡(luò)的能輸出下列三種狀態(tài)之一Enteringthemarketwithalongposition(Entering
8、)市場是處在多向倉Enteringthemarketwithashortposition(Entering)市場是處在空向倉Indeterminatestate不確定的,(不明確的,模糊的)狀態(tài)Actually,thethirdstateisthestateofpassingcontrolovertotheBTS,whereasinthefirsttwostatesthetradesignalsaregivenbytheneuralnetwork.實際上,第三種狀態(tài)是就把控制權(quán)交給BTS,反之前兩種狀態(tài)是交易信號由神經(jīng)網(wǎng)絡(luò)給出。Theteachingoftheneuralnetworkisdi
9、videdintothreestages,eachstageforteachingoneperceptron.Atanystage,theoptimizedBTSmustbepresentforperceptronstoknowwhatitcando.神經(jīng)網(wǎng)絡(luò)的“教育”分成三步驟,每一步驟“教育”一個感知機(jī),在任何一步驟,這個優(yōu)化了的BTS必須存在為的是“感知機(jī)們”知道它自己能做什么。Theseparateteachingofperceptronsbyageneticalgorithmisdeterminedbythelackofthisalgorithm,namely:Theamountof
10、inputssearchedinwiththehelpofsuchalgorithmislimited.However,eachteachingstageiscoherentandtheneuralnetworkisnottoolarge,sothewholeoptimizationdoesnottaketoomuchtime.感知機(jī)們分別的“教育”由遺傳算法來承擔(dān),由于這樣的算法的缺乏,換句話說,搜索到的這樣的算法有限,限制了“輸入”(參數(shù)變量)的數(shù)量(借助這樣算法得到的參數(shù)變量的值),然而,每一步驟的“教育”是密切配合補(bǔ)充的。(因此效果還是不錯),這樣這個神經(jīng)網(wǎng)絡(luò)不會太大,整個的優(yōu)化也不會
11、耗費太多的時間。Theveryfirststage,precedingtheteachingofanNN,consistsinoptimizationoftheBTS.在“教育”NN之前的一步是對BTS進(jìn)行優(yōu)化。Inordernottoloseourselves,wewillrecordthestagenumberintheinputoftheATSidentifiedaspass.Identifiersofinputscorrespondingwiththestagenumberwillandinthenumberequaltothisstagenumber.為了不使我們自己也被搞糊涂了,我
12、們將已經(jīng)測試通過的ATS的輸入(參數(shù)變量)記錄上(”通過”(pass)的步驟號(stagenumber).,輸入s(參數(shù)變量)的標(biāo)識符將和stagenumber(步驟號)一致(等同)。Thus,letsstartpreparationsforoptimizationandteachingtheNN.Letssettheinitialdepositas$1000000(inordernottocreateanartificialmargincallduringoptimization)andtheinputtobeoptimizedasBalanceinExpertAdvisorproperti
13、esonthetabofTestingintheStrategyTester,andstartgeneticalgorithm.這樣,我們開始對這個NN進(jìn)行優(yōu)化和“教育”的準(zhǔn)備。存入初始保證金為$100萬(以便于在優(yōu)化期間不產(chǎn)生人為的補(bǔ)充保證金的通知)。Input(參數(shù)變量)是按“余額”進(jìn)行優(yōu)化,設(shè)置EA的StrategyTester的測試的屬性tab為Testing。開始運行遺傳算法。LetsgototheInputstaboftheEAspropertiesandspecifythevolumeofpositionstobeopenedbyassigningthevalue1totheid
14、entifierlots.在這個EA的開倉量lots.的值設(shè)為1lot。Optimizationwillbeperformedaccordingtothemodel:Openpricesonly(fastestmethodtoanalyzethebarjustcompleted,onlyforEAsthatexplicitlycontrolbaropening),sincethismethodisavailableintheATSalgorithm.從這個ATS算法明確地有效開始,實施優(yōu)化,所采用復(fù)盤模型是“僅用開盤價(以最快速的方法分析剛形成的柱線)”。Stage1ofoptimizatio
15、n.OptimizationoftheBTS:優(yōu)化步驟1,BTS的優(yōu)化Setthevalue1fortheinputpass.設(shè)置為1為這input(參數(shù)變量)“為通過”(theinputpass)。Wewilloptimizeonlyinputsthatcorrespondwiththefirststage,i.e.,thatendin1.Thus,wecheckonlytheseinputsforoptimization,anduncheckallothers.我們僅僅優(yōu)化步驟1相關(guān)的那些inputs(參數(shù)變量),即,尾標(biāo)為1的參數(shù)變量,于是,我們僅僅測試優(yōu)化有關(guān)的inputs而不測試其他
16、的變量參數(shù)tp1-TakeProfitoftheBTS.Itisoptimizedwiththevalueswithintherangeof10to100,step1tp1,BTS的所取的止盈值(TakeProfit)。在step1,優(yōu)化的值的范圍在10到100,sl1-StopLossoftheBTS.Itisoptimizedwiththevalueswithintherangeof10to100,step1sl1,BTS的所取的止損值(StopLoss)。在step1,優(yōu)化的值的范圍在10到100。p1-periodofCCIusedintheBTS.Itisoptimizedwitht
17、hevalueswithintherangeof3to100,step1p1,用于BTS的CCI的周期值。在step1,優(yōu)化的值的范圍在3到100BelowaretheresultsoftheBTSoptimization:下面是BTS優(yōu)化的結(jié)果Stage2.Teachingtheperceptronresponsibleforshortpositions:步驟2,“教育負(fù)責(zé)管“開空倉”(shortpositions)的感知機(jī)Setthevalue2(accordingtothestagenumber)fortheinputpass.根據(jù)步驟的步驟號,設(shè)置(input,參數(shù)變量)的pass的值
18、為2。Unchecktheinputscheckedforoptimizationinthepreviousstage.Justincase,saveinafiletheinputsobtainedatthepreviousstage.不測試那些已經(jīng)測試過的優(yōu)化了的以前步驟的inputs.(變量參數(shù))。以防萬一,保存以前步驟獲得的inputs(變量參數(shù)值)到一個文件中去Checktheinputsforoptimizationaccordingtoourrule:theiridentifiersmustendin2:根據(jù)我們的規(guī)則,必須是測試那些是在尾標(biāo)為2的inputs(變量參數(shù))。x12,
19、x22,x32,x42-weightnumbersoftheperceptronthatrecognizesshortpositions.Itisoptimizedwiththevalueswithintherangeof0to200,step1x12,x22,x32,x42是識別并開空倉的感知機(jī)的權(quán)重,它們的值在step1時被優(yōu)化在范圍0to200tp2-TakeProfitofpositionsopenedbytheperceptron.Itisoptimizedwiththevalueswithintherangeof10to100,step1tp2(TakeProfit)是感知機(jī)所開的
20、倉的止盈值,它們的值在step1時被優(yōu)化在范圍10to100。sl2-StopLossofpositionsopenedbytheperceptron.Itisoptimizedwiththevalueswithintherangeof10to100,step1sl2(StopLos)在step1它是感知機(jī)所開的倉的止損值,被優(yōu)化值的范圍在10to100p2-theperiodofthevaluesofpricedifferencetobeanalyzedbytheperceptron.Itisoptimizedwiththevalueswithintherangeof3to100,step1
21、.p2感知機(jī)所分析的價格差的周期值(iiCCI()函數(shù)的一個參數(shù)period-Averagingperiodforcalculation),在step1它的值所優(yōu)化的范圍在3to100Letsstartteachingitusingoptimizationwithageneticalgorithm.Theobtainedresultsaregivenbelow:現(xiàn)在,開始用遺傳算法來優(yōu)化“教育”NN(讓它“學(xué)習(xí)”市場),獲得的結(jié)果如下Stage3.Teachingtheperceptronresponsibleforlongpositions:步驟3“教育”負(fù)責(zé)開多倉的感知機(jī)(“學(xué)習(xí)”市場)。
22、Setthevalue3(accordingtothestagenumber)fortheinputpass.設(shè)置值3(根據(jù)步驟的步驟號)說明這些input(變量參數(shù))已經(jīng)“通過”(theinputpass)Unchecktheinputscheckedforoptimizationinthepreviousstage.Justincase,saveinafiletheinputsobtainedatthepreviousstage.同樣,不測試,那些已經(jīng)測試過的優(yōu)化了的,以前步驟的inputs.(變量參數(shù)值),以防萬一,保存以前步驟獲得的inputs.(變量參數(shù)值)到一個文件中去Checkt
23、heinputsforoptimizationaccordingtoourrule:theiridentifiersmustendin3:根據(jù)我們的規(guī)則,優(yōu)化測試的inputs(變量參數(shù)值)必須是尾標(biāo)為3的那些變量參數(shù)。x13,x23,x33,x43-weightnumbersoftheperceptronthatrecognizeslongpositions.Itisoptimizedwiththevalueswithintherangeof0to200,step1.x13,x23,x33,x43是識別多倉的感知機(jī)的權(quán)重,它們的值在step1時被優(yōu)化時得到的范圍在0to200tp3-Take
24、Profitofpositionsopenedbytheperceptron.Itisoptimizedwiththevalueswithintherangeof10to100,step1tp3(TakeProfit)是感知機(jī)所開的倉的“止盈值”,它的值在step1時被優(yōu)化時的范圍是在10to100。sl3-StopLossofpositionsopenedbytheperceptron.Itisoptimizedwiththevalueswithintherangeof10to100,step1sl3(StopLoss)是感知機(jī)所開的倉的“止盈值”,它們的值在step1時被優(yōu)化為范圍是10t
25、o100。p3-theperiodofthevaluesofpricedifferencetobeanalyzedbytheperceptron.Itisoptimizedwiththevalueswithintherangeof3to100,step1.p3-感知機(jī)所分析的價差的周期值。它在步驟1優(yōu)化時得到的值的范圍是3to100。Letsstartteachingitusingoptimizationwithageneticalgorithm.Theobtainedresultsaregivenbelow:啟動采用遺傳算法的優(yōu)化來“教育”NN,所獲得的結(jié)果如下Stage4(final).T
26、eachingthefirstlayer,i.e.,teachingtheperceptronthatisintheupperlayer:步驟4(最終步驟)“教育”第一層,即“教育”在上層的感知機(jī)。Setthevalue4(accordingtothestagenumber)fortheinputpass.根據(jù)步驟的步驟號,設(shè)置值4為輸入通過(fortheinputpass)Unchecktheinputscheckedforoptimizationinthepreviousstage.Justincase,saveinafiletheinputsobtainedatthepreviousst
27、age.不測試那些在之前步驟已經(jīng)測試過的優(yōu)化了的“輸入”(inputs)(意思是已經(jīng)在之前步驟優(yōu)化過的變量的參數(shù)值就不再優(yōu)化它們了)。以防萬一,將之前步驟獲得的這些變量的參數(shù)值存到一個文件中去。Checktheinputsforoptimizationaccordingtoourrule:theiridentifiersmustendin4:根據(jù)我們的規(guī)則,只測試優(yōu)化標(biāo)識符最后位是4的那些inputs(變量的參數(shù)值)x14,x24,x34,x44-weightnumbersoftheperceptronofthefirstlayer.Itisoptimizedwiththevalueswith
28、intherangeof0to200,step1.x14,x24,x34,x44是第一層感知機(jī)參數(shù)的權(quán)重值。在步驟1時它們被優(yōu)化的值的范圍在0to200。p4-theperiodofthevaluesofpricedifferencetobeanalyzedbytheperceptron.Itisoptimizedwiththevalueswithintherangeof3to100,step1.p4被感知機(jī)分析的價差的值的周期。在步驟1它的值的范圍被優(yōu)化在3to100。Letsstartteachingitusingoptimizationwithageneticalgorithm.Theo
29、btainedresultsaregivenbelow:采用遺傳算法來優(yōu)化,啟動“教育”來教它“學(xué)習(xí)”。所獲得結(jié)果如下Thatsall,theneuralnetworkhasbeentaught.這就是全部,神經(jīng)網(wǎng)絡(luò)已經(jīng)被“教育”了。TheATShasonemorenon-optimizableinput,mn-MagicNumber.ItistheidentifierofpositionsforatradingsystemnottomixitsorderswiththeordersopenedmanuallyorbyotherATSes.Thevalueofthemagicnumbermus
30、tbeuniqueandnotcoincidewiththemagicnumbersofpositionsthathavenotbeenopenedbythisspecificExpertAdvisor.這個ATS有一個不能被優(yōu)化的input(參數(shù))mn-MagicNumber.(魔法號)它是一個交易系統(tǒng)它所開的倉位的識別符,為的是不和手動開倉或其他ATSes開的倉位混淆。這個MagicNumber的值必須是唯一的并且和這個特別的ea尚未開倉的magicnumbers不一致。P.S.Thesizeoftheinitialdepositisfoundasthedoubledabsolutedra
31、wdown,i.e.,weconsidersomesafetyresourcesforit.出于保證有一些安全保險的考慮,初始保證金的金額設(shè)置是考慮為絕對最大回落的兩倍TheEAgiveninthesourcecodesisnotoptimized.這個ea的源代碼沒有優(yōu)化。Ifyouneedtoreplacethebuilt-inBTSwiththealgorithmofanothertradingsystem,youmustmodifythecontentsofthefunctionbasicTradingSystem().如果你需要置換嵌入另一個交易系統(tǒng)算法的BTS,你必須修改BTS功能
32、的內(nèi)部。Inordernottoentertheinitialandthefinalvaluesandthevaluesofstepsforoptimization,youcantakethereadyfilecombo.set,placeitinthefoldertesterMT4,anduploadtotheEAspropertiesinTester.以便于不輸入優(yōu)化時的初值,終值和步長,你可采用已備好的combo.set文件,把它放置到MT4的tester目錄并加載這個ea的屬性(properties)到StrategyTester。Re-optimizationoftheEAistob
33、eperformedataweekend,i.e.,onSaturdayoronSunday,butonlyiftheresultsoftheprecedingweekwereunprofitable.Thepresenceoflossesmeansthatthemarkethaschanged,andthere-optimizationisnecessary.ThepresenceofprofitsmeansthattheATSdoesnotneedanyre-optimizationandrecognizesmarketpatternsquitewell.這個ea的再優(yōu)化可在周末進(jìn)行,即周
34、六和周日,但僅在前面一周的結(jié)果是不盈利的。虧損的出現(xiàn)意味著市場已經(jīng)改變,于是需要重新優(yōu)化,若是仍然獲利意味著這個ATS不需要重新優(yōu)化,它對市場目前的模型的識別繼續(xù)有效!附源代碼:/+-+/|Combo_Right.mq4|/|Copyright?2008,YuryV.Reshetov|/|/load/2-1-0-171|/+-+#propertycopyrightCopyright?2008,YuryV.Reshetov#propertylink/load/2-1-0-171/-inputparametersexterndoubletp1=50;externdoublesl1=50;exter
35、nintp1=10;externintx12=100;externintx22=100;externintx32=100;externintx42=100;externdoubletp2=50;externdoublesl2=50;externintp2=20;externintx13=100;externintx23=100;externintx33=100;externintx43=100;externdoubletp3=50;externdoublesl3=50;externintp3=20;externintx14=100;externintx24=100;externintx34=1
36、00;externintx44=100;externintp4=20;externintpass=1;externdoublelots=0.01;externintmn=888;staticintprevtime=0;staticdoublesl=10;staticdoubletp=10;/+-+/|expertstartfunction|/+-+intstart()if(Time0=prevtime)return(0);prevtime=Time0;if(!IsTradeAllowed()again();return(0);/-inttotal=OrdersTotal();for(inti=0;i0)ticket=OrderSend(Symbol(),OP_BU
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 我的社區(qū)個人工作計劃
- 內(nèi)部工程項目承包合同樣本
- 出售車庫定金合同樣本
- 公司收押金合同樣本
- 農(nóng)村房頂維修安全合同標(biāo)準(zhǔn)文本
- 農(nóng)村建房鋼材合同樣本
- 中介房產(chǎn)抵押合同標(biāo)準(zhǔn)文本
- 勞動教育貫穿計劃
- 冰箱轉(zhuǎn)讓合同標(biāo)準(zhǔn)文本
- 農(nóng)村大隊部修建合同標(biāo)準(zhǔn)文本
- 2022年電子元器件貼片及插件焊接檢驗規(guī)范
- 周口市醫(yī)療保障門診特定藥品保險申請表
- 可下載打印的公司章程
- 三年級下冊綜合實踐活動課件-水果拼盤 全國通用(共15張PPT)
- 污水池內(nèi)防腐施工方案
- 海南省省直轄縣級各縣區(qū)鄉(xiāng)鎮(zhèn)行政村村莊村名明細(xì)居民村民委員會
- 簡約喜慶元宵節(jié)介紹模板 教學(xué)課件
- 西藏林芝嘉園小區(qū)項目可研(可研發(fā))
- summary-writing-概要寫作-優(yōu)質(zhì)課件
- T∕CIC 049-2021 水泥窯用固體替代燃料
- 部編版高中語文必修下冊第八單元《單元導(dǎo)讀》教學(xué)設(shè)計
評論
0/150
提交評論