Neural Networks Forecasting Profits. Neural-nätverk är state-of-the-art, utbildningsbara algoritmer som efterliknar vissa viktiga aspekter i den mänskliga hjärnans funktion. Detta ger dem en unik förmåga att träna själv, förmågan att formalisera oklassificerad information och de flesta Viktigare, förmågan att göra prognoser baserade på den historiska informationen de har till sitt förfogande. Naturliga nätverk har använts i allt större utsträckning inom en rad olika affärsapplikationer, inklusive prognoslösningar och marknadsföringslösningar. På vissa områden, såsom bedrägeri upptäckt eller riskbedömning är de De obestridliga ledarna De viktigaste områdena i vilka neurala nätverk har hittat ansökan är finansiell verksamhet, företagsplanering, handel, affärsanalys och produktunderhåll. Neurala nätverk kan tillämpas på vinst av alla typer av handlare, så om du är en näringsidkare och du har ännu inte Har introducerats i neurala nätverk, tar vi dig igenom denna metod för teknisk analys och visar hur du ska Pply det till din handel stylemon Delusions De flesta människor har aldrig hört talas om neurala nätverk och om de inte är handlare, behöver de nog inte veta vad de är. Vad är verkligen överraskande är det faktum att ett stort antal av dem som Skulle kunna dra nytta riktigt av neuralt nätverksteknik har aldrig ens hört talas om, ta det för en hög vetenskaplig idé eller tänka på den som en smal marknadsföringsgimmick. Det finns också de som stiftar alla sina förhoppningar på neurala nätverk, lejoniserar nät efter några positiva Erfarenhet med dem och om dem som en silver-bullet lösning till någon form av problem Men som alla handelsstrategi neurala nätverk är ingen snabbkorrigering som gör att du kan slå den rik på genom att klicka på en knapp eller två Faktum är att rätt förståelse Av neurala nätverk och deras syfte är avgörande för deras framgångsrika tillämpning. När det gäller handel är neurala nätverk en ny, unik metod för teknisk analys, avsedd för dem som tar ett tänkande tillvägagångssätt Deras verksamhet och är villiga att bidra lite tid och ansträngning för att få denna metod att fungera för dem. Bäst av allt, när de tillämpas korrekt kan neurala nätverk generera vinst regelbundet. Använd neurala nätverk för att avslöja möjligheter En stor missuppfattning är att många handlare misstänker Neurala nätverk för ett prognosverktyg som kan ge råd om hur man agerar i en viss marknadssituation Neurala nätverk gör inga prognoser Istället analyserar de prisdata och upptäcker möjligheter Med ett neuralt nätverk kan du fatta ett handelsbeslut baserat på grundligt analyserad Data som inte nödvändigtvis är fallet vid användning av traditionella tekniska analysmetoder. För en seriös, tänkande handlare är neurala nätverk ett nästa generations verktyg med stor potential som kan upptäcka subtila icke-linjära interdependenser och mönster som andra metoder för teknisk analys inte kan Att avslöja. Bästa nätet Precis som någon form av bra produkt eller teknik har neurala nätverk startat locka till sig al Jag som söker en växande marknad Torrenter av annonser om nästa generations programvara har översvämmade marknaden - Annonser firar den mäktigaste av alla neurala nätverksalgoritmer som någonsin skapats Även i de sällsynta fallen när reklamkrav liknar sanningen, kom ihåg Att en 10 effektivitetsökning är förmodligen det mesta du någonsin kommer att få från ett neuralt nätverk Med andra ord ger det inte mirakulösa avkastningar och oavsett hur väl det fungerar i en viss situation kommer det att finnas några datasatser och uppgiftskurser för Vilka tidigare använda algoritmer förblir överlägset Kom ihåg det är inte den algoritm som gör tricket Välberedd information om den inriktade indikatorn är den viktigaste delen av din framgång med neurala nätverk. Snabbare konvergens bättre. Många av dem som redan använder neurala nätverk Misstag tror att ju snabbare deras nät ger resultat, desto bättre är det Detta är dock en illusion Ett bra nätverk är inte bestämt b Y den takt som den ger resultat och användarna måste lära sig att hitta det bästa balansen mellan hastigheten vid vilken nätverket tränar och kvaliteten på resultaten som den producerar. Korrekt tillämpning av neurala nät Många handlare tillämpar neurala nät felaktigt eftersom de placerar för mycket Lita på programvaran som de använder alla utan att ha fått riktiga instruktioner om hur man använder det ordentligt. För att använda ett neuralt nätverk på rätt sätt och därmed vinstligt, bör en näringsidkare vara uppmärksam på alla stadier i nätverksberedningscykeln. Är näringsidkaren och inte hans eller hennes nät som ansvarar för att uppfinna en idé, formalisera denna idé, testa och förbättra den och slutligen välja rätt ögonblick att skicka bort det när det inte längre är användbart. Låt oss överväga stadierna av Den här avgörande processen i mer detalj.1 Hitta och formalisera en handelsidee En näringsidkare bör fullt ut förstå att hans eller hennes neurala nätverk inte är avsett för att uppfinna vinnande handelsideer och - koncept. Det är Avsedd för att ge den mest tillförlitliga och exakta informationen möjligt om hur effektiv din affärsidé eller - koncept är. Därför bör du komma med en original handelsidee och tydligt definiera syftet med denna idé och vad du förväntar dig att uppnå genom att använda den. Viktigaste fasen i nätverksberedningscykeln För relaterad läsning, se Lektioner från en Trader s Dagbok 2 Förbättra parametrarna i din modell Därefter bör du försöka förbättra den övergripande modellkvaliteten genom att ändra den uppsatta datasatsen och justera de olika parametrarna. Figur 1 Ange optimeringsalgoritmen och dess egenskaper.3 Avsättning av modellen när den blir föråldrad Varje neuronbaserad modell har en livslängd och kan inte användas på obestämd tid. Livslängdens livslängd beror på marknadssituationen och hur Länge marknadens ömsesidigheter som återspeglas i det förblir aktuella Men förr eller senare blir någon modell föråldrad När det händer kan du antingen r Etrain modellen använder helt ny data, dvs ersätta all data som har använts, lägg till några nya data i befintlig dataset och träna modellen igen, eller helt enkelt dra av modellen helt. Många handlare gör misstaget att följa den enklaste sökvägen - De är starka beroende av och använder det sätt på vilket deras mjukvara ger den mest användarvänliga och automatiska funktionaliteten. Det enklaste sättet är att förutse ett pris ett par barer framåt och basera ditt handelssystem på denna prognos. Andra handlare prognos prisförändring eller procentandel av priset Förändring Detta tillvägagångssätt ger sällan bättre resultat än att prognostisera priset direkt Båda de förenklade förhållningssätten misslyckas med att upptäcka och utnyttja vinstdelen av de viktigaste långsiktiga ömsesidiga beroendeförhållandena och som ett resultat blir modellen snabbt föråldrad när de globala drivkrafterna förändras. De flesta Optimal övergripande strategi för att använda neurala nätverk En framgångsrik näringsidkare kommer att fokusera och tillbringa en hel del tid på att välja styrande Inmatningsposter för hans eller hennes neurala nätverk och justering av parametrar Han eller hon kommer att spendera från åtminstone flera veckor - och ibland upp till flera månader - Använda nätverket En framgångsrik näringsidkare kommer också att justera sitt nät för förändringsförhållandena under hela sitt liv Span Eftersom varje neuralt nätverk bara kan täcka en relativt liten aspekt av marknaden, bör neurala nätverk också användas i en kommitté. Använd så många neurala nätverk som möjligt - förmågan att anställa flera på en gång är en annan fördel med denna strategi. På detta sätt, Var och en av dessa multipelnät kan vara ansvarig för en viss aspekt av marknaden, vilket ger dig en stor fördel över hela linjen. Det är dock rekommenderat att du behåller antalet nät som du använder inom intervallet 5-10. Slutligen, neurala nätverk Bör kombineras med en av de klassiska metoderna. Detta kommer att göra det möjligt för dig att bättre utnyttja de uppnådda resultaten i enlighet med dina handelspreferenser. Slutsats Du kommer att expe Rymlig verklig framgång med neurala nät, bara när du slutar leta efter det bästa nätet Det är trots allt inte viktigt att du lyckas med neurala nätverk i nätverket, men i din handelsstrategi. Därför hittar du en lönsam strategi som fungerar för dig, Du måste utveckla en stark idé om hur man skapar en kommitté för neurala nätverk och använder dem i kombination med klassiska filter och penninghanteringsregler. För relaterad läsning, kolla in Neural Trading Biological Keys To Profit och Trading Systems Coding Tutorial. Licensed User Center. Trade med Intelligence med TradingSolutions. TradingSolutions kombinerar teknisk analys med artificiell intelligens AI-teknik med neurala nätverk och genetiska algoritmer för att lära sig mönster från historiska data och optimera systemparametrar. Denna handelsprogramvara fungerar med aktier, terminer, valutor FOREX och många andra finansiella instrument. Det kan Bygga även system för amerikanska och internationella marknader. Över 300 av de mest populära tec Hnical indicators. Proven prov och kundprestanda. Industriell ledande datastöd från eSignal Interactive Brokers och många more. Proprietary Optimal Signal technology. Free Technical Support.100 Free Systems och förbyggda neurala nätverksmodeller. Fri abonnemang till Trader68 Standardautomatiserad handelsprogramvara. Används framgångsrikt i över 66 länder runt om i världen.30-dagars pengarna tillbaka-garanti. Licensed User Center. Trade med Intelligence med TradingSolutions. TradingSolutions kombinerar teknisk analys med artificiell intelligens AI-teknik med neurala nätverk och genetiska algoritmer för att lära sig mönster från historiska data och optimera Systemparametrar Denna handelsprogramvara arbetar med aktier, terminer, valutor FOREX och många andra finansiella instrument. Det kan också bygga system för amerikanska och internationella marknader. Över 300 av de mest populära tekniska indikatorerna. Provet och kundens prestanda. Industris ledande datasupport från eSignal Interaktiva Mäklare och många fler. Proprietary Optimal Signal technology. Free Technical Support.100 Free Systems och förbyggda neurala nätverksmodeller. Används framgångsrikt i över 66 länder runt om i världen. 30-dagars pengarna tillbaka-garanti. Hybrid neurala nätverks Stop-and-Reverse-strategier för Forex. Av Michael R Bryant. Neurala nätverk har använts i handelssystem i många år med varierande grad av framgång. Den främsta attraktionen är att deras olinjära struktur bättre kan fånga komplexiteten i prisrörelsen än standard, indikatorbaserade handelsregler. En av de Kritik har varit att neurala nätverksbaserade handelsstrategier tenderar att vara överpassade och därför fungerar inte bra på nya data En möjlig lösning på detta problem är att kombinera neurala nätverk med regelbaserad strategisk logik för att skapa en hybridstrategi Artikeln kommer visa hur detta kan göras med hjälp av Adaptrade Builder. In particular, den här artikeln kommer att illustrera followingbining neurala nätverk och regelbaserad logik för handel poster . En tre-segments metod kommer att användas, med det tredje segmentet som används för att validera de slutliga strategierna. Den resulterande strategiska koden för både MetaTrader 4 och TradeStation kommer att visas, och det kommer att visas att valideringsresultaten är positiva för varje plattform. Neural Networks som Trade Entry Filters. Mathematically är ett neuralt nätverk en olinjär kombination av en eller flera viktiga ingångar som genererar ett eller flera utgångsvärden. För handel används ett neuralt nätverk vanligen på ett av två sätt 1 som en förutsägelse för framtida pris Rörelse eller 2 som en indikator eller filter för handel Här kommer dess användning som indikator eller handelsfilter att betraktas. Som en indikator fungerar ett neuralt nätverk som ett ytterligare villkor eller filter som måste uppfyllas innan en handel kan matas in Ingångar till nätverket är typiskt andra tekniska indikatorer, såsom momentum, stokastik, ADX, glidande medelvärden och så vidare, samt priser och kombinationer av föregående ingångar är skalade Och det neurala nätverket är konstruerat så att utmatningen är ett värde mellan -1 och 1 Ett tillvägagångssätt är att tillåta en lång ingång om utgången är större än eller lika med ett tröskelvärde, såsom 0 5, och en kort post om Utgången är mindre än eller lika med negativet av tröskeln, t ex -0 5 Detta villkor skulle utöver eventuella befintliga inmatningsförhållanden. Om det exempelvis fanns ett långt ingående tillstånd skulle det vara sant och den neurala nätverksproduktionen skulle Måste vara minst lika med tröskelvärdet för en lång ingång. När ett neuralt nätverk bildas, är en näringsidkare normalt ansvarig för att välja inmatningar och nätverkstopologi och för att träna nätverket, vilket bestämmer värdena för optimal vikt. Visas nedan, Adaptrade Builder utför dessa steg automatiskt som en del av den evolutionära byggprocessen som mjukvaran är baserad på Använda det neurala nätverket som ett handelsfilter gör att det enkelt kan kombineras med andra regler för att skapa en hybrid tradin G-strategi, en som kombinerar de bästa egenskaperna hos traditionella regelbaserade tillvägagångssätt med fördelarna med neurala nätverk. Som ett enkelt exempel kan Builder kombinera en glidande medelvärdesövergångsregel med ett neuralt nätverk så att en lång position tas vid snabb rörelse Genomsnittliga kors över det långsamma rörliga genomsnittet och den neurala nätverksproduktionen är vid eller över dess tröskel. Stopp-och-omvänd handelsstrategier. En stopp-och-omvänd handelsstrategi är en som alltid finns på marknaden, antingen lång eller kort. , Stopp och bakåt innebär att du byter handel när din stopporder slås. Men jag använder den som en kort hand för någon handelsstrategi som vänder sig från lång till kort till lång och så vidare, så att du alltid är inne Marknaden Med den här definitionen är det inte nödvändigt att orderna är stopporder. Du kan ange och vända om med hjälp av marknads - eller begränsningsorder. Det är inte heller nödvändigt att varje sida använder samma logik eller till och med samma ordertyp. Till exempel, du kunde Skriv in lång och avsluta kort på en stopporder och skriv in kort och avsluta länge på en marknadsordning med olika regler och villkor för varje utträde. Detta skulle vara ett exempel på en asymmetrisk stopp-och-omvänd strategi. Den främsta fördelen med ett stopp Och omvänd strategi är att genom att alltid vara på marknaden saknar du aldrig några stora drag. En annan fördel är enkelhet När det finns separata regler och villkor för att komma in och utträda handel är det mer komplicerat och mer som kan gå fel. Kombinera poster och Utgångar innebär att färre tidsbeslut måste fattas, vilket kan innebära färre misstag. Å andra sidan kan det hävdas att de bästa förutsättningarna för att lämna handel är sällan de samma som för att komma in i motsatt riktning som inträde och spännande affärer Är i sig separata beslut som därför bör använda separata regler och logik. En annan potentiell nackdel med att alltid vara på marknaden är att strategin kommer att handla genom varje öppningsgap. En stor o Penggap mot positionen kan innebära en stor förlust innan strategin kan vända strategier som går in och ut mer selektivt eller att utgången vid slutet av dagen kan minimera inverkan av öppningsgap. Eftersom målet är att bygga en valutahandel , MetaTrader 4 MT4 är ett självklart val för handelsplattformen, eftersom MetaTrader 4 är utformad främst för forex och används ofta för handel på dessa marknader, t ex MetaTrader vs TradeStation A Language Comparison. Men under de senaste åren har TradeStation riktat sig mot Valutamarknaden går mycket mer aggressivt Beroende på din volymen och eller på kontonivå kan du handla valutamarknaden via TradeStation utan att ådra några plattformskostnader eller betala några provisioner. Spread är enligt uppgift tight med god likviditet på de stora valutaparen. Av dessa skäl, Båda plattformarna riktade sig till detta projekt. Särskilda problem uppstår när man riktar flera plattformar samtidigt. För det första kan data vara diff Präglas av olika plattformar, med skillnader i tidszoner, prisnoteringar för vissa barer, volymer och tillgängliga datumintervall. För att jämföra över dessa skillnader erhölls data från båda plattformarna och strategierna byggdes över båda dataserierna samtidigt. De bästa strategierna var Därför de som fungerade bra på båda dataserierna trots skillnaderna i data. De datainställningar som används i Builder visas nedan i Fig. 1 Som kan härledas från tabellen Market Data i figuren riktades euro dollarns valutamarknad mot USDUSD Med en barstorlek på 4 timmar 240 minuter Andra barstorlekar eller marknader skulle ha tjänat lika bra jag kunde bara skaffa så mycket data via min MT4-plattform som indikeras av datumintervallet som visas i Fig 1 dataserie 2, så detsamma Datumintervall användes för att erhålla ekvivalenta dataserier från TradeStations dataserie 1 80 av de data som användes för byggnad kombinerad i prov och out-of-sample med 20 6 20 14 till 2 10 15 avsedda för valida Tion 80 av originalet 80 sattes sedan till provet med 20 inställd till urvalet, vilket visas i Fig. 1 Budförfrågningen var inställd på 5 pips och handelskostnader på 6 pips eller 60 i full storlek Mycket 100 000 aktier antogs per rundtur Båda dataserierna ingick i byggnaden, vilket indikeras av kryssrutorna i den vänstra kolumnen i tabellen Market Data. Figur 1 Marknadsdatainställningar för att bygga en forexstrategi för MetaTrader 4 och TradeStation . Ett annat potentiellt problem när du riktar in flera plattformar är att Builder är utformad för att duplicera hur varje stödd plattform beräknar dess indikatorer vilket kan innebära att indikatorvärdena kommer att vara olika beroende på vilken plattform som väljs. För att undvika denna möjliga källa till skillnad, Som utvärderar annorlunda i MetaTrader 4 än i TradeStation bör elimineras från byggnaden, vilket innebär att följande indikatorer bör undvikas. Alla andra indikatorer som är tillgängliga för båda plattformarna beräknas D på samma sätt på båda plattformar TradeStation innehåller alla indikatorer som finns tillgängliga i Builder, medan MetaTrader 4 inte för att bara inkludera indikatorer som finns tillgängliga på båda plattformarna, ska MetaTrader 4-plattformen väljas som kodtyp i Builder Det kommer automatiskt att ta bort några indikatorer från byggsatsen som inte är tillgängliga för MT4, vilket kommer att lämna indikatorerna som finns tillgängliga på båda plattformarna. Dessutom, eftersom jag märkte skillnader i volyldata från varje plattform, tog jag bort alla volymberoende indikatorer Från byggsatsen Slutligen avlägsnades tidsindikatorn på grund av skillnader i tidszoner mellan datafiler. I fig 2 nedan visas listan över indikatorer som används i byggsatsen sorterad efter om indikatorn eller inte Betraktades av byggprocessen Överväg kolumn Indikatorerna borttagna av hänsyn till orsakerna ovan diskuteras längst upp i listan. Den återstående indikatorn Ors, som börjar med Simple Mov Ave, var alla en del av bygguppsättningen. Figur 2-indikatorval i Builder, vilket visar indikatorerna som avlägsnats från byggsatsen. De utvärderingsalternativ som används i byggprocessen visas i Fig 3. Som diskuteras MetaTrader 4 Valdes som val av kodutgång När strategier är inbyggda i Builder kan något av alternativen på fliken Evalueringsalternativ, inklusive kodtyp, ändras och strategierna utvärderas, vilket också kommer att skriva om koden på vilket språk som är valt Denna funktion användes för att skaffa TradeStation-koden för den slutliga strategin efter att strategierna byggdes för MetaTrader 4.Figure 3-utvärderingsalternativen i Builder för EURUSD-forexstrategin. För att skapa stop-and-reverse-strategier, togs alla exittyper bort från Byggsats, som visas nedan i Fig 4 Alla tre typer av orderingång - marknad, stopp och gräns - lämnades som överväganden, vilket innebär att byggprocessen skulle kunna överväga någon av dem under byggprocessen. Re 4 Ordertyper som valts i Builder för att skapa en stopp-och-omvänd strategi. Builder-mjukvaran genererar automatiskt regelbaserade logiska förhållanden för inmatning och eller utgående. För att lägga till ett neuralt nätverk i strategin är det bara nödvändigt att välja alternativet Inkludera Ett neuralt nätverk i inmatningsförhållanden på fliken Strategialternativ, som visas nedan i Fig. 5. De neurala nätverksinställningarna lämnades vid deras standardvärden. Som en del av stop-and-reverse-logiken ställdes alternativet Market Sides till Long Short och Alternativ att vänta på Avsluta innan du anger ny handel var avmarkerad Det senare är nödvändigt för att möjliggöra att orderingången lämnar den aktuella positionen vid en omkastning. Alla övriga inställningar lämnades vid standardinställningarna. Figur 5 Strategialternativ valdes i Builder för att skapa en hybridstrategi med hjälp av Både regelbaserade och neurala nätverksförhållanden. Den evolutionära karaktären av byggprocessen i Builder styrs av träningen som beräknas utifrån de mål och villkor som definieras på fliken Metrics, som sho Wn nedan i Fig 6 Byggnadsmålen behölls enkelt att maximera nettoresultatet samtidigt som komplexiteten minimerades, vilket gav en liten vikt i förhållande till nettovinsten. Mer betoning gjordes på byggnadsförhållandena, vilket inkluderade korrelationskoefficienten och betydelsen för den allmänna strategin Kvalitet samt genomsnittliga barer i branschen och antalet branscher. Först var endast de genomsnittliga staplarna i handeln inkluderade som ett byggnadsförhållande. I några av de tidiga byggnaderna blev nettoresultatet gynnade över handelslängden, Så att antal-of-trades metriska lagts till. Det angivna intervallet för antalet branscher mellan 209 och 418 motsvarar genomsnittliga handelslängder mellan 15 och 30 bar baserat på antalet staplar i byggperioden. Som ett resultat, lägger du till denna metriska Lägga större vikt vid handelslängdsmålet, vilket resulterade i fler medlemmar av befolkningen med önskat antal handelslängder. Figur 6 Bygga mål och villkor som fastställts på tabellen Metriska bestämmer E hur fitnessen beräknas. Villkoren för att välja toppstrategier duplicerar byggnadsförhållandena, med undantag för att de översta strategiska villkoren utvärderas över hela datamängden, inklusive valideringssegmentet, vilket är separat, snarare än bara under byggnadsperioden, som Är fallet för byggnadsförhållandena De översta strategierna används av programmet för att avsätta alla strategier som uppfyller alla förhållanden i en separat population. De slutliga inställningarna görs på fliken Byggalternativ, som visas nedan i Fig 7. Viktiga alternativ här är befolkningsstorlek, antal generationer och alternativet att återställa baserat på externt resultat. Befolkningsstorleken valdes för att vara stor nog för att få bra mångfald i befolkningen, samtidigt som den fortfarande är tillräckligt liten för att bygga in En rimlig tid Antal generationer var baserad på hur lång tid det tog under några preliminära byggnader för resultaten att börja konvergera. Figur 7 Byggalternativ Lude befolkningsstorleken, antal generationer och alternativ för att återställa befolkningen baserat på externt resultat. Alternativet att återställa på exemplet OOS-prestanda startar byggprocessen efter det angivna antalet generationer om det angivna Villkoret är uppfyllt i detta fall kommer befolkningen att återställas om nettovinsten utanför provet är mindre än 20 000. Detta värde valdes utifrån preliminära tester för att vara ett tillräckligt högt värde som det förmodligen inte skulle uppnås. Byggprocessen upprepades var 30: e generationer tills den stoppades manuellt Det här är ett sätt att låta programmet identifiera strategier baserade på toppstrategierna under en längre tidsperiod. Periodiskt kan Topstrategies befolkning kontrolleras och byggprocessen avbröts när lämpliga strategier Finns. Notice som jag lägger ut i urvalet i citat När periodperioden utanför provet används för att återställa befolkningen på detta sätt är den externa perioden inte längre riktigt ute - prov Sedan denna period används nu för att styra byggprocessen är det effektivt en del av provperioden. Det är därför lämpligt att avsätta ett tredje segment för validering, vilket diskuterades ovan. Efter flera timmars bearbetning Och ett antal automatiska ombyggnader uppnåddes en lämplig strategi i Topstrategies befolkning. Den stängda kurvan för handelskapital visas nedan i Fig. 8. Aktiekurvan visar enhetlig prestanda i båda datasegmenten med ett adekvat antal branscher och i huvudsak samma resultat över Båda dataserierna. Figur 8 Closed-trade-kapitalkurva för EURUSD-stopp-och-omvänd strategi. För att kontrollera strategin under valideringsperioden kontrolleras datumet på fliken Marknader, se figur 1 ändras till slutdatum för data 2 11 2015, och strategin revurderades genom att välja kommandot Evaluate från Strategy menyn i Builder. Resultaten visas nedan i Fig. 9 Valideringsresultaten i den röda rutan visar att strategin Hålls kvar på data som inte användes under byggprocessen. Figur 9 Closed-trade-kapitalkurva för EURUSD-stopp-och-omvänd strategi, inklusive valideringsperioden. Den slutliga kontrollen är att se hur strategin utfördes för varje dataserie separat med hjälp av Kodutmatningsalternativ för den plattformen Detta är nödvändigt eftersom det kan finnas skillnader i resultaten beroende på 1 kodtypen och 2 dataserien Vi måste verifiera att de valda inställningarna minimerade dessa skillnader, som avsedda att testa Strategin för MetaTrader 4 avmarkerades dataserien från TradeStation på fliken Markets och strategin revurderades. Resultaten visas nedan i Fig 10, vilket duplicerar bottenkurvan i Fig 9. Figuren 10 Closed-trade equity curve För EURUSD-stop-and-reverse-strategin, inklusive valideringstiden för MetaTrader 4. För att testa strategin för TradeStation, valdes dataserien från TradeStation och serien för MetaTrader 4 var dese Föreläsades på fliken Markörer, ändrades kodutgången till TradeStation och strategin revurderades. Resultaten visas nedan i Fig 11 och verkar vara väldigt lika med mittkurvan i Fig 9, som förväntat. Figur 11 Sluten - Handelskurva för EURUSD-stopp-och-omvänd strategi, inklusive valideringstiden, för TradeStation. Koden för båda plattformarna finns nedan i Fig 12 Klicka på bilden för att öppna kodfilen för motsvarande plattform. Genom att granska koden visas att Regelbaserad del av strategin använder olika volatilitetsrelaterade förhållanden för de långa och korta sidorna. De neurala nätverksingångarna består av en mängd olika indikatorer, inklusive veckodag, trend ZLTrend, intraday high, oscillatorer InvFisherCycle, InvFisherRSI, Bollinger bands , Och standardavvikelsen. Strategins hybridkaraktär kan ses direkt i koddeklarationen från TradeStation-koden. Om EntCondL och NNOutput 0 5 börja sedan Köp EnMark-L NShares aktier nästa bar på marknaden . Den variabla EntCondL representerar de regelbaserade inmatningsförhållandena och NNOuput är utgången från det neurala nätverket. Båda förhållandena måste vara sanna att placera den långa postordern. Den korta inmatningsvillkoren fungerar på samma sätt. Ange 12 Handelsstrategikod för EURUSD Stop-and-reverse-strategi kvar, MetaTrader 4 right, TradeStation Klicka på siffran för att öppna motsvarande kodfil. Ladda ner en Builder-projektfil som innehåller de inställningar som beskrivs i den här artikeln. Den här artikeln tittade på processen att bygga en hybridregelbaserad neuron Nätverksstrategi för EURUSD med hjälp av en stopp-och-omvänd alltid i marknadsinriktningen med Adaptrade Builder Det visades hur strategikoden kan genereras för flera plattformar genom att välja en gemensam delmängd av indikatorerna som fungerar på samma sätt på varje plattform. Inställningar som behövs för att generera strategier som vänder om från lång till kort och bakåt beskrevs, och det visades att den resulterande strategin utfördes positivt på en sepa Rate, validering segment av data Det var också verifierat att strategin genererade liknande resultat med data och kod alternativ för varje plattform. Som diskuterats ovan har stop-and-reverse-metoden flera nackdelar och kan inte vädja till alla Men en alltid - in-marknaden-tillvägagångssättet kan vara mer attraktivt med forexdata eftersom valutamarknaden handlar dygnet runt. Som ett resultat är det inga öppningsöppningar, och handelsorderna är alltid aktiva och tillgängliga för att vända handeln när marknaden Ändringar Användningen av intradagsdata 4-timmarsfält gav flera datafält för användning i byggprocessen, men var annars ganska godtyckligt, eftersom strategin alltid innehas i marknadsföringen innebär att branschen transporteras över natten. Byggprocessen Fick utveckla olika villkor för att komma in lång och kort, vilket resulterade i en asymmetrisk stopp-och-omvänd strategi. Trots namnet går den resulterande strategin i både långa och korta affärer på marknadsordningar, även om märket Et, stop och limit orders var alla betraktas av byggprocessen oberoende av varje sida. I praktiken skulle omvändning från lång till kort betyda att sälja kort två gånger antalet aktier på marknaden, eftersom strategin för närvarande var länge, t ex om den nuvarande långa positionen Var 100 000 aktier skulle du sälja korta 200 000 aktier på marknaden. Om den nuvarande korta positionen var 100 000 aktier skulle du köpa 200 000 aktier på marknaden för att vända från kort till lång. En kortare prishistoria användes än vad som var idealisk. Resultaten var positiva på valideringssegmentet, vilket tyder på att strategin inte var överpassad. Detta stödjer tanken att ett neuralt nätverk kan användas i en handelsstrategi utan att nödvändigtvis överdriva strategin på marknaden. Den strategi som presenteras här är inte avsedd för Faktisk handel och testades inte i realtidsspårning eller handel. Denna artikel kan dock användas som en mall för att utveckla liknande strategier för EURUSD eller andra marknader. Sätt, varje handelsstrategi du utvecklar bör testas noggrant i realtidsspårning eller på separata data för att validera resultaten och för att bekanta dig med handelsegenskaperna i strategin före levande handel. Denna artikel uppträdde i februari 2015-numret av Adaptrade Software Newsletter. HYPOTETISKA ELLER SIMULERADE RESULTATRESULTAT HAR SÄRSKILDA BEGRÄNSNINGAR OM EN FAKTISK PRESTANDARDREKORD, SIMULERADE RESULTAT FÖRSÄKRAR INGEN FAKTISK HANDEL HÄRIGEN, SOM HANDLINGARNA INTE FAKTISKT UTFÖRS TILL RESULTATEN KAN HÄR UNDER - ELLER ÖVERKOMPENSERAS FÖR KONSEKVENSEN , IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN. If you d like to be informed of new developments, news, and special offers from Adaptrade Softw are, please join our email list Thank you. Neural Networks for FOREX Trading. In this article an example of using of our Neural Networks Software to create a complete neural network trading system. This example uses the Cortex built-in scripting language so please read the scripting language guide first. Using Neural Networks to create FOREX Trading Strategy. In this free online tutorial you will find the full cycle of using neural networks Cortex Neural Networks Software for Forex trading or stock market trading the idea is the same. You will learn how to choose inputs for the artificial neural networks and how to decide what to use as the output. You will find an example of a ready to use script that allows to perform neural networks optimization of both the structure of Neural Network number of neurons and the forex trading system stop loss etc. Finally the part that is not present in most tutorials , you will learn what to do next After all, Cortex Neural Networks Software cannot do real t ime trading, you need to use something like Trade Station, MetaQuotes or MetaTrader How to port the FOREX trading system from Cortex to your favorite trading platform Do you have to deal with DLLs, ActiveX controls and low-level programming The answer is NO Cortex Neural Networks Software comes with the easy to use feature that allows you to easily port the resulting trained Neural Network to the scripting language of your trading platform No DLLs, DDE, ActiveX or any other low-level solutions - everything is plain and simple. Important note this is NOT a how to trade tutorial Instead, it tells you how to use Cortex Neural Networks Software but you still need to invent your own trading system The one we use here is barely a starting point, and shouldn t be used as a forex trading strategy as is The idea of this text is to teach you to create NN-based trading systems and to port them to the trading platform of your choice The example is, however, ovesimplified, and can only be used as th e illustration of trading principles Same way, the MACD trading system, that can be found in many tutorials, is not working well anymore as markets have changed , but still is a good example of using indicators for mechanical trading In two words do your own analysis. Another important note the tutorial uses examples, lots of them To make your life easier, I have included them all, not just fragments However it makes the text much longer Also, I am going from the very first, clumsy, forex trading system to more advanced, every time explaining what had been improved and why Be patient, or jump directly to the section you need. Final important note the code is not something carved in stone, it could change while this text was written The final versions of script files are included in Cortex archive. Pitfalls of FOREX BUY SELL Signals What is wrong with simple examples. In the Cortex Neural Networks Software user s guide we used a simple example of an aftifficial Neural Network predicting the price of GENZ stock To find out what is wrong with this approach, let s do the same simple example, using instead of the use 800 records in the learning set, as is a little bit shorter, then. It just wouldn t work Why. The reason will become evident, if you ask yourself What is the reason neural network forecasting of future values can be done on the first place. The answer is it is learning to do what is called neural networks pattern recognition to recognize patterns, and if there is a hidden logic in these patterns, then even a new pattern with the same logic will be recognized. That s a trick - with the same logic There is not even one, but three problems here. First of all, if you look at the Microsoft s stock price, you will notice, that it was going down in the learning part of our data, and sideways - in the testing part So it is possible, that the logic had changed. Second, and even more important - WHAT IS THE PATTERN You see, if we teached the neural network in the range 10 - 100 , and then presented it with something in the 1 to 3 range - they are different patterns 10, 20, 30 and 1, 2, 3 look similar to the human because - BECAUSE - we have this ability to divide by ten, when presented with numbers ending with zero It is what is called a pre-processing of the data, and by default, the NN can not do it. Can we teach it Of course What is it EXACTLY we need to teach it. This is the third, and the most important one We do not need the price prediction We do not care What we need is FOREX buy sell signals. Now, wait a minute We need a to have our input both learning and testing in the same range, and we need b to be able to make trading decisions based on it Isn t it what we call an indicator Bingo. So, that s what we are going to do - we will build an indicator, to feed it to the NN as an input, and we will try to get a prediction of the indicator value, not the worthless stock price. In our first example, we will load stock quotes from the disk, open the Neural Netwo rk file and start the learning - all in an automated mode. Create a new script file or open the one that came with the Cortex Neural Networks Software archive and call it. First of all, we need to download the price values from the file We are going to use the CLV indicator see below , but to calculate it, we need split-adjusted values for High and Low, not just for close Here is how to get them. The first line assigns the path to the strStockPath variable, of course, you will have to edit it, if your data file is located in the different directory. In the second line we specify, that this path is not relative the relative to the location of file. The TABLELOADER receives the path, the empty string for the start line , 1 - to skip the first line column names , part of the file s footer line the last line in does not contain data , it is also instructed to load the column number 0 and call it arrDate , 2 arrHigh , 3 arrLow , 4 arrC and 6 arrClose For a full description of TABLELOADER, see th e SLANG reference guide. Then we calculate split, by dividing the Adjusted Close by Close, and use this value to adjust Low and High. The file contains newest data FIRST, while we want them LAST. Next, we need to create an indicator Let s say, it is going to be a Close Location Value indicator, though in the real life I would probably use more than one indicator as the NN input. The Close Location Value indicator is calculated like. CLV Close - Low - High - Close High - Low , where Close, Low and High are for the interval, not necessarily for a single bar Note, that we want it in the 0 - 1 range, to make it easier to normalize to our NN s range which is, again, 0-1.Next, we need to create a lag file Let s use lags equal to 1, 2 9 For details on file functions, see the SLANG reference guide Note, that the Cortex s NN dialog can produce simple lags automatically you can use a Generate lag button But later in this text, we are going to work with complex lags which means, they are not 1, 2, 3 b ut 1, 3, 64 whatever , so we need to create the code that can handle this task in a more flexible way. Having the lag file, we are ready to create our first neural network This function takes a lot of parameters, so be carefull However, the code is really simple. By the way, most of this code can be removed, if you think you can handle numbers, instead of meaningfull names in your code, however, that would be a very bad coding practice. Now, after we have a neural network and the lagged file with data, we need to teach the network The lag file has 1074 records, so it is reasonable to use 800 as a learning set, and the remaining 274 as a testing set. You can, of course, open a network file and to click the Run button on the Learning tab But as this is an introduction to advanced Cortex Neural Networks Software programming, let s use SLANG builtin scripting language instead. The following code brings up the modal dialog with ann NN settings Note, that if you want to have a privilege of clicki ng the Run button, you need to change the. The bStartLearning can be 0, in which case the dialog will wait for your input, or 1, then the learning will begin aytomatically. The bResumeScript, if equals 1, will resume the script, if you close the dialog by clicking the OK button. The bReset is used to reset the network before the learning begins. Run the script, and wait for the epoch counter to exceed 1000, then click Stop Go to the Apply tab, and click Apply This will run the entire data set both learning and testing through the NN, and create the file, containing both original input-output, and the NN-generated prediction, this way you can easily plot them and compate against each other. Go to the Output tab, select file, click Browse file , Select fields , then select the No in the left list box, and by holding down the CTRL key while selecting with the mouse Clv and NN Clv in the right list box Click Chart to see how good our prediction is Well It is more or less good, from what we can say by looking at it Still, nothing extraordinary. This was just an example of what you can do with SLANG scripting, and how to automate Cortex s routine tasks However, until now, we did nothing you couldn t do by hand Well almost nothing, because if you want to create a custom lag file, with, say, Clv-100, Clv-50, Clv-25 columns, then you will have to use SLANG or Excel , because you cannot do in in Cortex without scripting. FOREX Trading Strategy what to optimize. Here is our next problem Do we need a good-looking prediction, or do we need the one we can use to trade with profit The question seems odd, but just think about it for a moment Let s say we have a VERY good 1-hour prediction 95 accurate Still, how far can the price go in one hour Not too far, I am afraid Compare it to the situation, when you have a rather inaccurate 10-hours prediction Will it be better. To answer this question, we need to actually trade, a simple comparison of the mean errors produced by the two NNs will not help. The second part of the same problem is in the way we define a good prediction Let s say we have a network, that produces the prediction, which is 75 accurate Compare it to the NN, that is producing 100 accurate prediction The last one is better Now, DIVIDE the output prediction of the 100 accurate NN by 10 We will have a VERY inaccurate network, as its signal is nowhere near the signal we used as a desired output And yet, it can be used same way we used 100 accurate NN, all we have to do is to multiply it to 10.See, the NN is created, by tuning the mean quadratic error, and not the correlation, so, at least in theory, a better NN can show poor results, when used for the actual stock Forex trading. To solve this problem, we need to test our NNs using trading, and to use results of this trading profit and drawdowns to decide, if this NN is better than the other one. Let s do it Let s create a program, that can be used to fine-tune NN, and this time, by fine-tuning, we will mean tradin g results. Neural Network Trading Few short notes. First of all, in our example above, the automatic learning will never stop, because we haven t specified any stop criteria In the dialog, or in the CREATENN function, you can provide the min error when the NN reaches it, it stops and, if bResumeScript is set to 1, the dialog will close and the script will resume Also yo can provide the maximum number of epochs, or both I am not using it in the example below, at least not always, because I am planning to watch the learning and to click STOP when I think the NN is ready If you want to do it in fully automatic mode, pay attention to these parameters. Second One of the ways to make a network smaller, faster and more accurate, is to begin with the small network, and increase it s size, neuron by neuron Obwiously, the number of the input neurons is determined by the number of input data columns but we can vary them, too , and the number of output neurons should be equal to the number of output data columns usually one, but not necessarily This means we need to optimize the number of neurons in the hidden layer s. Also, as I have mentioned, we don t really know which data to use Will Clv-15 15 days delayed increase the accuracy of our prediction Do we need Clv-256 Will it be better to use both of them in the same NN, or will adding Clv-256 ruin our performance. Using nested cycles to try different input parameters, you can. Create the NN, same way we did it for the stock data let me repeate, for the NN, there is no difference between stocks and FOREX, it just happened that I have couple of high quality data files for FOREX that I want to process, while writing this text. Try different combinations of lags. Try different number of neurons in the hidden layer. and different combinations of different indicators. However, if you try all possible combinations of all possible parameters, you will NEVER get your results, no matter how fast your computer is Below, we will use couple of tricks to reduce calculations to a bare minimum. By the way, it may seem, that if you start from one hidden neuron, then increase it to 2, 3 and so on, and at some point the error quality of the prediction or the profit if you test the NN by trading using it will begin to go down, then you have your winner Unfortunately, I cannot prove, that after the first performance peak there can be no second one It means, that the error may go like 100, 30, 20, 40, 50 it was just at its minimum, right and then 30, 20, 10, 15 the second minimum We just have to test all reasonable numbers. Third Optimization is a two-edged sword If you over-optimize your code, it may not work outside the data you used to fine-tune it I will do my best to avoid this pitfall If you want to do addition al optimizations to your code or NN, I advise you to do a research in the Internet, to learn more about hidden problems of this approach ALso, I am going to pay some attention to the smoothness of the profit curve The profit that looks like 0, -500, 1000, -100, 10000 may be great, but the profit 0, 100, 200, 300, 400 is better, as it is less risky We may talk about it later. Finally, for this example we are going to use FOREX, rather than stock prices From the point of view of the NN there is no difference, and from my point - Forex is much more fun to trade If you prefer stocks, the code can easily be modified. A FOREX Trading Strategy to play with. First of all, let s create a prototype of our code, one that can easily be optimized in future It is going to be a trading system, that uses a Neural Network to trade and produces a chart profit against trade number It will also calculate drawdown, as a measure of robustness of our trading system. The main difference here is that we use functi ons, instead of placing all the code in the main block of the program This way it is much easier to manage. Second, we have a TestNet function I am using a very simple algorithm of trading The CLV indicator is confined to 0 - 1 interval our version of CLV is , so when the indicator crosses up the dBuyLevel see code above , I am buying, when it is crossing down the dSellLevel, I am selling. Obviously, it is not the best trading strategy, but it will do for our purpose just for now If you want to improve it, here are some pointers First, you may want to have a system, that is not ALWAYS in the market Second, you may want to use more than one indicator as inputs, and maybe, more than one NN, so that the trading decision is made based on few predicted indicators We will add some improvements to the trading algorithm later. We use some standard assumptions of the FOREX trading spread is 5 points, leverade is 100, min lot is 100 mini-FOREX. Let s take a look at our trading system Once again, it is an oversimplified one An important note the TestNn is called last, and it has access to all variables that were created to that point So if you see a variable that I am using, without initializing it, it probably means that it was initialized in NewNn , TeachNn or some other function that was called prior to TestNn. To make things easier, comments are placed in the code. Few words about the drawdown There are few ways of calculating it, and we are using what I consider the most honest The drawdown is a measure of instability of our system What is a chance, that it will loose money Lets say the initial amount is 1000 If the profit goes 100, 200, 300, 400 the drawdown is 0 If it goes 100, 200, 100 then the drawdown is 0 1 10 , as we have just lost an amount, equal to 1 10 of the initial deposit from 1200 to 1100.I would strongly advice against using trading systems with large drawdowns. Also, here I use a drawdown, that is to be used with variable lot size However, in the actual samples, that come with the eBook, you will see another version. As you can see, here we always use 1000 the initial amount to calculate the drawdown The reason is simple we always use the same lot size no money management yet , so there is no difference, how much money we have already accumulated on our account, an average profit should be constant The worse possible scenario in this case looks like this from the very beginning 1000 on account we are loosing money If we use 1000 to calculate the drawdown, we will get the worse drawdown This will help us not to trick ourselves For example, say, we traded for some time, and we have 10,000 on our account Then we loose some money, and we now have 8,000 Then we have recovered, and got 12,000 Good trading system Probably not. Let s repeat the logic again, as it is very important and it will become even more important, when we start doing money management We trade using fixed size lots So, statistically, there is no guarantee, that the maximum loss wi ll not happen at the very beginning, when we only have 1000 And if it happens, we will have -1000 10,000 - 8,000 , so the trading system is probably too risky. When we talk about the money management probably, not in this text , we will have to use different approach to drawdown calculation. Note, that in this trading system, I am using the worse possible scenario I am buying using High and selling, using Low Many testers do not follow these rules, and create trading systems, that work fine on historical data But in the real life, these trading systems have very poor performance Why. Take a look at the price bar It has Open, High, Low and Close Do you know, how the price was moving inside the bar No So, let s say, your trading system generated a buy signal, at the bottom of the price bar if dLow. Note that I am using dLotSize equal 0 1 lot 100 Obviously, in the real trading, you will benefit greatly, if the lot size is calculated depending on the money you have, something like. However, we are doing testing here, not trading And for testing, we need, among other things, to see how smooth the profit curve is This is much easier to do if the lot size is the same in ideal situation, for dLotSize 100 we will get a straight line, with some positive slope, while in case of the adjustable lot size we will get an exponent, that is much harder to analyze. Later in this text, we will apply money management rules to our trading system, but not yet. After we are done with the last part of our testing function, let s walk through the rest of the code. The following function creates a CLV indicator It takes the interval as a parameter, which means that we can call it many times, during the optimization, passing different numbers. Note, that I am using the NN that works in the 0 - 1 interval The data can be normalized, of course, but I chose to divide the indicator by 2 and to add 0 5, so that it is in 0 - 1 range. To make lag file, we can use the CREATELAGFILE function Alternatively, we ca n do it by explicitly providing all the necessary code In this case, we have more control, and we are going to need it, if we begin varying number of lagged columns and so on. The nRemoveFirst parameter is important Many functions, like indicators, moving averages, lag generators, for that matter, do not work well within the first few records of the dataset Let s say we have MA 14 - what will it place in the records 1 - 13 So we choose to simply remove the first few unreliable records. For the NewNn, as well as for all functions of this program, we need to pass as parameters only what can be changed during optimization process For example, there is no need to pass a skip before parameter, as it is always the same. The TeachNn function simply brings up the NN dialog. Finally, we need a charting function It is not mandatory, but it is always a good idea to see what our profit line looks like The following code uses the XML to produce a chart, so it is a good idea to read the tutorial Alterna tively, you can draw the chart, rather than saving it in a file To do it, use one of the samples, that are in the samples scripts directory Finally, you can modify the code, to produce HTML, rather than XML HTML is easier to learn, but the code itself will be a bit less readablepile and Run the script. Well As expected, using 7 hours as an interval for the CLV produced very poor results. FOREX Trading Strategies and Optimization. The reason for the poor results is quite obvious we used the Interval, Stop Loss, buy and sell levels and other parameters, that were purely random - we just picked first that came in mind What if we try few combinations. FOREX Trading Signals What to optimize. First of all, by overoptimizing the buy and sell levels, we can ruin our future performance However we still can tune them, especially, if the performance is close for close values of buy and sell limits For example, if we have -10 profit at buy limit equal 0 3, and 1000 profit when it equals 0 35, then ther e is probably a lucky coincidence, and we should not use 0 35 for our trading system, as in future it will probably not happen again If, instead, we have -10 and 10 instead of 1000 , it may be safer to use. Generally, our trading system should be built for WORSE possible scenario, as if during the real trading the performance will be better, then during the test, we will survive, but not the other way around. We can vary the value for the indicator interval, provided we have enough trades, so that we can be confident, in terms of statistics, in the performance of a system. We certainly can vary the number of neurons, I don t think it can be overoptimized easily. We can vary number of inputs and lags for inputs It is possible to overoptimize this, but it is not very likely to happen. And, of course, we can try different indicators. Accurate FOREX Signals How to optimize. As have already been mentioned, if we start trying all possible combinations, it will take forever So we are going to cheat We will create pre-defined sets of parameters, that we think are reasonable, and pass them to the program. To make as few calculations as possible, note, that Clv-1 and Clv-2 are, probably, important, but what about Clv-128 And - if we already have Clv-128, do we need Clv-129 Probably, not So we are going to have something like Clv-1, Clv-2, Clv-4, Clv-8 Clv-128 with just few variations, which will make our calculation time thousands times shorter. FOREX Professional System Trading Can it work at all. What is it exactly we want to predict Until this point we have used 1 hour chart for EURUSD, and we were predicting the next bar s CLV Will the CLV 2 be better What about CLV 3.Also, especially considering the poor performance of our first trading system, it would be nice to know, that - at least in the ideal world, the goal profitable trading can be achieved. To answer these questions, let s create a simple testing program We assume, that our prediction is 100 accurate, and, based on this as sumption, we will use CLV N, not the NN predicted one That s right - we are going to take data from the future, and to use them instead of the NN prediction This approach wouldn t work in the real life, of course, but at leats, it will give us some ideas of what to expect. When looking at the results, please keep in mind, that we are not using any advanced money management, our lot size is set to a minimum 100 If you use variable lot sizes, results will be dramatically different But even at a lot size set to 0 1 we can see below that getting the information from the future is an ultimate trader s holly graal. You are already familiar with this code, it was used in It handles data loading The only difference is in the part that obtains the list of files in the images directory and deletes all files with the extention The reason for this code is simple during our tests we are going to create many - may be, thousands - image files We don t want them to hung around after we are done So at th e beginning of the script we are deleting images, created by other scripts. Just a few comments We do not want to try all possible values for, for example, CLV interval Instead, we can create an array, that contains only values we want to test Then see below we will walk through this array. Stop losses are important part of any trading strategy, so I have decided to vary them as well It is a dangerous idea, however, as it is easy to overoptimize the system. I am planning to test different values for buy and sell levels, but it will be done in cycle, without using arrays. Unlike in our previous example, we want to have a large XML file, containing many images To do it, I have moved the code, that is forming the XML header and footer outside of the Chart function Read one of the online XML tutorials for details. Note, that I am using 0 as the first lag, which means, that first I am testing the indicator CLV that was not shifted from the future Just to get an idea, how good out trading system would be without NN horrible, is the right word It is loosing all the money. Cortex uses the Internet Explorer control to display XML pages When pages grow large, it takes a lot of memory If your computer cannot handle it, consider creating multiple XML or HTML pages, instead In the case of forexnn02, it should not be a problem, as the page is relatively short Alternatively that is what I am doing in scripts later in this text , create XML file, but do not open it from Cortex Open them using Internet Explorer instead - unlike IE control, the Internet Explorer does not have the memory problem. Now the code that is trying different combinations of parameters. Here, we are using nested cycles In every cycle, we are assidning some variable for example, nInterval for the outer cycle This way the cycle will assign values of all elements of a corresponding array, one in a time Then WITHIN it, the inner cycle is used, and so on, so that all combinations of all array elements are tested. In the inn ermost cycle, I am calling the Test function, to test trade , and Chart to add a new picture to a list of images saved on disk Note, that this Chart does not show any images, until all cycles are completed. The Test and CreateClv functions are almost the same as in the previous example The only real difference is due to the fact that it is called more then once To do it, I am calling ARRAYREMOVE to cleanup arrays. Also, notice, that we are only creating charts for the combinations of parameters, that produce trading system with positive profit Otherwise, we call continue , to skip the Chart function. Finally, we have Take Profit now, so our trading system can be a bit more flexible. The Chart function was broken into two pieces The header and the footer should be written to the XML file only once, so they were moved to the main part of the program. Also, I am using the counter, to save files under the different names The information about parameters is written to the header of an image, so we can easily see which one it is Finally, images are only saved for winning configurations, meaning the balance at the end should be more, then at the beginning. Run the program it will take some time to complete You will end up with a large XML page with images, one for each winning configuration. Some of the results are great, however, as we used data from the future , this system will not work in the real life Actually, if you look at the Test function, you will notice, that the cycle stops before we reach the last element of arrClose. for nBar nRemoveFirst 1 nBar. THIS IS C , just an example. As you can see, the code is really simple Now lets do the same using the SLANG script As in examples before, we will keep the overall structure of the code, so that this example looks familiar The only difference is that instead of using the built-in APPLYNN function, we call the function of our own The code that we do not use such as cycles is commented, but not removed. Note, that the logic behin d it was discussed in Neural Networks and Stock Forex Trading article already Briefly, the output of this script is formated to be compatible with the MQL, MetaTrader s scripting engine MetaTrader is a trading platform we use, if you want something different, like TradeStation, for example, you will have to alter the code to comply to its syntax. Then, in the following chapters, we are going to insert this code in the MetaTrader s indicator, and to use it to trade. Porting script to trading platform. The next step is not really required, but it is something, that may be useful We are going to create a version of a tsc file one above , but this time, we will use SLANG Cortex scripting language to emulate APPLYNN function The reason is, in the next chapter we are going to port it to the scripting language of a MetaTrader trading platform, so it is a good idea to make sure everything works. After we run this function, we discover, that the result it produces is the same, as the forexnn05a pro duced, which means the code works fine. Note, that there is a difference at the beginning of the charts, as our NN does not try to process the data at the beginning where lag is incomplete , while the built-in NN does not know about this problem Of course, it doesn t affect the result, as the beginning of the chart is ignored by using the nRemoveFirst parameter in our script set to 200, which is guaranteed to be larger, then our lag. Using third-party trading platform. We have the NN that more or less can be used We have the script, implementing this NN without calls to the Cortex-specific NN functions Now we are going to port it to the trading platform that can be used for the real trading, which means it can contact brocker, place orders and earn or loose money. As a trading platform, I am going to use MetaTrader. Disclaimer I am not related to MetaQuotes in any way I do not work for them, I am not their affiliate and so on I use MetaTrader, ONLY because I like it. I find this program user - friendly, flexible and powerful, and not a monster Also, it is free compare to other packages of this class. The only minor problem is that it is not always easy to find the dealer using MT in your area Then, when you do a research, you may find couple of brockers, with screenshots on their web sites, that look suspiciously familiar Yes, they use MetaTrader, but they don t call it MetaTrader. I have asked for clarification at the company s forum, and they have told me, that they don t reveal brockers using their services Very strange. One of the brockers that is not hiding the fact they use MT, is Alpari They will allow you to open a Demo account, so that you can trade in a real time, but without risking your money. Warning I am not going to recommeng services of Alpari Once again, I am not being paid for that Try their Demo account, and use your own judgement Or you can start your own research at Internet forums. Finally, if you do not like the MT, you can probably follow the example belo w using TS, MS or some other trading platform This is just an example. Our MT-based trading system will include two files, the indicator and an expert This is the way they call it in MQL scripting language of MT , and I am going to follow this naming convention. The indicator implements the neural network and draws a chart An expert takes these data and does trading As MetaTrader has a strategy tester , we will be able to test our strategy, to see how good it is. I will assume, that you are familiar with MQL programming, it is quite close to SLANG and tutorials can be found both at MetaQuotes and Alpari. Finally, I am using the code structure, that is borrowed from MetaQuotes forum, permission to use it the author of the corresponding posts had granted me permission to use fragments of his code. Also, as some of our MetaTrader code is the same for all experts and indicators, we moved it to a separate library file MetaTrader s libraries are nothing but includable files This library takes car e of synhronization, when two or more expert are trying to run in the same time, as well as of few other things If you use MetaTrader, it will help you to create robust experts, in any case, the MQL language is easy to understand. a helper library. The code should look familiar, all I did was re-writing it, using slightly different language syntax of MQL. This indicator has two buffers, and draws two lines, one for the original NOC, and one for the NN-predicted NOC For trading, you don t have to draw both indicator lines, of course see MQL tutorials to learn how to do it , but I have decided to show them together, so you can compare. Another difference, that you should know about, is the way MT performs testing It may, in some cases, be more accurate, then one we did we did the worse case scenario Of course, you can always to change the SLANG script from the examples above, to implement any logic you want. The result of our testing in MT is a bit better, then in Cortex, due to all these reasons. Keep in mind, that MT calculates the DD in a different way I still think, that my way is better. In should be especially noted, that no additional optimization had been performed using MetaTrader s optimizer We have just plugge d our MTS mechanical trading system in, and it worked as expected. That is it You can now create Cortex Neural Network, optimize it to do trading, and to port it to the trading platform of your choice. Download Cortex Order Cortex View Price List. Visibility is very important for this site If you like it please link to this URL.
No comments:
Post a Comment