Matlab Handelsindikatorer
MetaTrader 5 - Exempel. MetaTrader 5 och MATLAB Interaction. My första artikeln Interaktion mellan MetaTrader 4 och MATLAB Engine Virtual MATLAB Machine noterades av MQL-community Några läsare 1Q2W3E4R5T kunde även flytta detta projekt från Borland till VS2008 Men tiden går framåt obevekligt och tråkigt men sant MetaTrader 4 försvinner och ger plats åt sin efterträdare MetaTrader 5 med MQL5, som introducerade pekare och dynamiskt minne. Tack vare dessa innovationer har vi möjlighet att skriva ett universellt bibliotek med interaktion med MATLAB Engine virtuell maskin och direkt länkbibliotek, genererade av MATLAB, med MetaTrader 5 Den här artikeln täcker en sådan funktionalitet Den här artikeln fortsätter logiskt den tidigare och behandlar mer noggrant problemet med interaktion mellan MetaTrader 5 och MATLAB. För att göra omfattningen av denna artikel mer begriplig för oförberedda läsare, vi kommer att dela upp det i tre delar teori, referens och praktik Teori kommer att omfatta de typer av dataanvändning d i MQL5 och MATLAB, liksom deras ömsesidiga omvandling I Referens kommer du att lära dig de språkliga strukturerna och syntaxen för funktioner som behövs för att skapa en DLL. I praktiken analyserar vi fallgropar av denna interaktion. Experterade läsare kan hoppa över teori och referens, och Börja med övning Andra uppmanas att läsa teori och referens och bara sedan fortsätt till öva. Det är också värt att läsa böcker som nämns i litteraturavsnittet. 1 1 Datatyper i MATLAB och MQL5.1 1 1 Enkla datatyper. Först av allt , måste vi lära känna MQL5 och MATLABs inre världar. Efter parametrisk inspektion av variabla typer, konstaterar vi att de är nästan identiska. Tala 1 datatyper i MATLAB och MQL5. Det finns en stor skillnad variablerna i MQL5 kan vara enkla eller kompositkomplex, och i MATLAB är alla variabler multidimensionella komplexa - dvs matrisen. Du måste alltid komma ihåg om denna skillnad. 1 1 2 Komplexa datatyper. I MQL5 finns det 4 komplexa typer av datarrayer, strängar, strukturer och klasser Komplex datatyp är uppsatt av flera enkla datatyper, kombinerad i minnesblock av viss längd När du hanterar sådan data behöver du alltid veta antingen minnesblockstorlek i byte eller antal element utom klasser Vi är endast intresserade av arrays och strängar, eftersom inlämning av klasser och MQL5-strukturer till MATLAB ger ingen mening. När passande arrays av någon typ behöver du veta typdimension och antal element med ArraySize-funktionen. Speciell uppmärksamhet bör ges till indexering i MetaTrader 5 - vanligtvis är det bakåt dvs det första elementet innehåller senare data än nästa. Kontrollera det här med funktionen ArrayIsSeries och MATLAB har följande indexering. Det första elementet innehåller äldre data än nästa - så du måste vända om dina arrayer innan du skickar dem till MATLAB, om flagg ASSURIES TRUE Baserat på ovanstående, låt oss samtycka till följande. Omvänd arrays osynligt för MQL5-program, förutom arrays av char-typen och 2-dimensionella arrays - lämna dem oförändrade. Ändra osynligt alla arrayer från MATLAB och tilldela ASSERIES-flaggan med SANT, förutom arrays av char-typen och 2- dimensionella arrays - lämna dem oförändrade. I varje array i MQL5-programmet, skapat enligt bakåtindexering, måste ASSERIES-flaggan vara SANT, förutom arrays av char-typen och 2-dimensionella arrays - lämna dem oförändrade. Men det här är inte det Endast begränsning när du arbetar med arrayer När du arbetar med multidimensionella arrayer eller matriser för att vara mer korrekt, särskilt från MATLAB, introducerar vi begränsningen för högst 2-dimensionella arrayer. Här kan ASSERIES-flaggan inte vara SANT, och därför är sådana arrayer inte reversed. Don t glömma att strängar i MQL5 inte är arrays av Char Type-elementen Så när passerar strängar kommer ett litet problem i MQL5 strängar kodade med Unicode och MATLAB använder ANSI-kodning Så innan du passar En sträng, bör den omvandlas till array av ANSI-tecken med funktionen StringToCharArray Och vice versa, när du får en teckenuppsättning från MATLAB, konvertera den med CharArrayToString-funktionen, se tabell 2 För att undvika förvirring, kom överens att lagra alla strängar i MQL5-program med hjälp av Unicode, inga arrayer av char-typen.1 2 Jämförelse av MQL5- och MATLAB-datatyper. För att minska mängden funktioner och förenkla bibliotekalgoritmen kommer vi att minska antalet typer genom automatisk omvandling, som inte skulle påverka integritet av data Följande tabell illustrerar regeln för datatypsomvandling från MQL5 till MATLAB. Med denna typ av konvertering finns det en förlust av noggrannhet Vi kommer inte använda den, men du kan använda en sådan omvandling i dina program. Tabel 2 Jämförelse av MQL5 och MATLAB Datatyper. Nu är du bekant med datatyper som används i MQL5 och MATLAB You vet vad fallgropar väntar vid dataöverföring och hur man kringgår dem kompetent Du måste fortfarande känna till MATLAB Engine API och bli bekant med MATLAB Compiler 4.2 MATLAB Engine API Reference, MATLAB Compiler 4 Referens och C Input Output Library Reference. This avsnitt introducerar dig till MATLAB Engine APIs viktigaste funktioner, funktioner i MATLAB Compiler 4 och antal användbara funktioner i C-standardinmatningsutdatabiblioteket. Så låt oss börja.2 1 MATLAB Engine API och MCR Functions. MATLAB Engine - är ett externt gränssnitt som gör det möjligt för andra program att använd MATLAB-skrivbordet Det ger ett fullt fungerande arbete för alla MATLAB-paket utan några begränsningar. Även om det inte sägs i dokumentationen, men när det gäller systemprogrammeraren - det är bara en respekterad ual maskin, som PHP, MySQL etc. som stöder ett enkelt och relativt snabbt sätt att utbyta data mellan MetaTrader 4 5 och MATLAB. Den här metoden för att ansluta externa program med MATLAB-paket rekommenderas av utvecklare Gränssnittet består av sex funktioner. NULL denna funktion kallar MATLAB skrivbord, parametern är alltid NULL, returnerar en pekare till skrivbordet descriptor. int exitCode engClose Engine pEng denna funktion stänger skrivbordet, returnerar antal återstående användare av MATLAB skrivbord, där. Engine pEng pekar till skrivbordsbeskrivaren. mxArray mxVector mxCreateDoubleMatrix int m, int n, int ComplexFlag den här funktionen skapar en variabel matris av MATLAB skrivbord, returnerar en pekare till variabel matris, där. mxArray mxVector pekar till matris variabel. int m antal rader. int n antal kolumnsplexFlag typ av komplext tal, för MetaTrader 4 5 mxREAL. void mxDestroyArray mxArray mxVector förstörs denna funktion MATLAB-matrisen, den behövs för att rensa minnet, var. MxArray mxVector pekare till matrix variable. int engPutVariable Engine pEng, char Namn, mxArray mxVector den här funktionen skickar variabel till skrivbordet Du måste inte bara skapa variabler av mxArray-typen, utan även skicka dem till MATLAB, där. Engine pEng-pekare till skrivbordsbeskrivaren. char Namn variabelnamn för char-typen i MATLAB-skrivbordet. MxArray mxVector-pekaren till matrisvariabel. mxArray mxVector engGetVariable Engine pEng, char Namn den här funktionen blir variabel från skrivbordet - den inverse av föregående funktion Endast variabler av typen mxArray accepteras, Where. mxArray mxVector pekar till matris variabel. Engin pEng pekare till skrivbordet descriptor. char Namn variabel namnet på char typen i MATLAB desktop. double p mxGetPr mxArray mxVector den här funktionen får pekaren till array av värden, det används för att kopiera data längs med memcpy se 2 3 C Standard Input Output Library, där. double p pekare till matris av dubbel type. mxArray mxVector pekaren till matris variabel. int engEvalStrin g Engine pEng, char Kommandot den här funktionen skickar kommandon till MATLAB-skrivbordet, där. Engine pEng pekar på skrivbordet descriptor. char Kommandokommandot för MATLAB, sträng av char-typen. Du märkte förmodligen att MATLAB Engine API kan du skapa mxArray-struktur Bara för dubbeltyp Men denna begränsning påverkar inte dina möjligheter, men kommer att påverka algoritmen för ditt bibliotek. MCC-exemplet är det speciella biblioteket MATLAB-paketet, som gör det möjligt att köra fristående applikationer offentliga bibliotek som genereras av MATLAB-miljö på vilken dator som helst Observera att även om du har ett komplett MATLAB-paket behöver du fortfarande installera MCR-biblioteket genom att köra filen, som finns i MATLAB Toolbox compiler deploy win32-mappen. Innan du ringer till någon offentlig biblioteksfunktion, skapad av MATLAB-miljö, behöver du ring MCR initialisering function. bool mclInitializeApplication const char alternativ, int räknar tillbaka TRUE om MCR start lyckades, annars FALSE, where. const char Alternativ sträng av alternativ, som i mcc - R är vanligtvis NULL. int räknestorlek alternativ sträng, typiskt 0. Vid slut på biblioteket måste du ringa bool mclTerminateApplication void returnerar TRUE om MCR stängdes framgångsrikt.2 2 MATLAB Compiler 4.MATLAB Compiler Kan du skapa följande från M-functions. Standalone-program som körs även om MATLAB inte är installerat. CC delar bibliotek, som kan användas utan MATLAB på slutanvändare systemspiler stöder de flesta kommandon och paket i MATLAB, men inte alla En fullständig förteckning över restriktioner finns på MATLABs hemsida. Med denna metod kan du skapa en programvarubaserad bunt MetaTrader 5 och MATLAB, men i motsats till MATLAB Engine krävs en välutbildad programmerare och djup kunskap om kompilering. MATLAB Compiler kräver minst En av följande CC compilers. Lcc C levereras vanligtvis med MATLAB Det är bara C compiler. Borland C versioner 5 3, 5 4, 5 5, 5 6.Microsoft Visual CC versioner 6 0, 7 0, 7 1.MATLAB Compiler 4 , i Kontrast till sina föregångare, genererar endast gränssnittskodshanteraren, det vill säga översätter inte m-funktioner till binär eller CC-kod, men det skapar en speciell fil baserad på Component Technology File CTF-teknik, som inkluderar integreringar av olika paket som krävs för att stödja m - funktioner MATLAB Compiler krypterar även den här filen med unik unrepeated 1024-bitars nyckel. Nu kan vi se algoritmen för MATLAB Compiler 4-arbetet, eftersom okunnighet om detta ämne kommer att leda till många dumma misstag vid sammanställningstiden. Funktioner, MEX-filer och P-filer, som sammanslagna m-funktioner beror på. Skapa arkiv - CTF-fil skapas, den är krypterad och komprimerad. Genom att genomsöka objektkod för wrapper i detta skede skapas alla källkoder som behövs för component. CC gränssnittskod för m-funktioner som anges i kommandoraden NameFilemain cponent-fil som innehåller all information som behövs för att utföra m-kod inklusive krypteringsnycklar och sökvägar, sto Rött i CTF-file. CC translation I detta skede samlas CC-källkodsfiler i objektfiler. Länkar Det slutliga fasen av projektbyggnaden. Nu när du är bekant med MATLAB Compiler-algoritmbeteendet måste du lära dig mer om nycklar i ordning Att ha en detaljerad handlingsplan när man använder kompilatorn mcc. Table 4 Matlab mbuild Linker version 4 keys. Table 4 listar huvudtangenterna För mer information använd hjälp mbuild eller doc mbuild kommandon.2 3 C Standard Input Output Library. Using the Standard Input Output Library ger rätt data kopiering Användningen kommer att spara dig från dumma fel som uppstår under programdesignfasen, till exempel många nybörjare programmerare kopierar bara pekaren till minnesblocket istället för att kopiera hela minnesblocket Från hela Input Output Library är vi intresserade Bara i en funktion. void pIn memcpy void pIn, void pOut, int nSizeByte kopierar denna funktion kloner variabel array från pOut till pIn med storleken på nSizeByte bytes, where. void pIn pekare till arra Y, var du ska kopiera. void pOut-pekare till array, varifrån kopieringen görs. int nSizeByte storleken på kopierade data, bör inte överstiga storleken på pIn-matrisen, annars kommer åtkomstfel för minne att inträffa. Nu är vi färdiga med teori och Vi kan fortsätta med realiseringen av MetaTrader 5 MATLAB-interaktionen. Som du antagligen gissat kommer detta att göras på två sätt med MATLAB Engine virtuell maskin och med hjälp av bibliotek som genereras av MATLAB Compiler First, överväga ett enkelt, snabbt och mångsidigt sätt att växla via MATLAB Engine. Denna del av artikeln måste läsas från början till slut, eftersom trots den uppenbara skillnaden mellan metoderna för interaktion har de en filosofi och välbekant syntax av språkkonstruktioner, och att lära sig något nytt är lättare med enkla exempel.3 1 Utveckla Universal Biblioteket med MetaTrader 5 MATLAB Engine Interaction. This metoden för interaktion kan inte kallas elegant och snabb, men det är den mest tillförlitliga och täcker hela MATLAB-paketet. Naturligtvis bör vi nämna t Hans snabbhet med slutlig modellutveckling Utvecklingssättet är att skriva ett universellt bibliotekspaket för MetaTrader 4 5 MATLAB Engine Interaction Efter det här MetaTrader 4 5-skriptindikatorn kan hantera MATLABs virtuella skrivbord och hela matematiska algoritmen kan lagras i MQL-programmet Som strängar, så du kan använda den för att skydda din immateriella äganderätt för mer information se skydda er, utvecklarartikel. Det kan också lagras i m-funktioner eller P-funktioner separata filer i mappen MetaTrader 5 MQL5 Biblioteken. Möjliga tillämpningsområden Av sådan interaktion. För att testa eller visa matematiska modeller kan idéer utan att skriva komplexa program skyddas av immateriella rättigheter som i MQL-program och med MATLAB-paket - med hjälp av P-funktioner. Att skriva komplexa matematiska modeller med alla funktioner i MATLAB. To alla dem som inte kommer att distribuera sina skript indikatorer experter. Let s fortsätt Jag hoppas att du har läst 1 1 Data ty pes i MATLAB och MQL5 1 2 Jämförelse av MQL5 och MATLAB Datatyper 2 1 MATLAB Engine API och MCR Funktioner och 2 3 C Standard Input Output Library sektioner, eftersom vi inte pausar och analyserar dem längre Läs noga följande block-schema, som Illustrerar algoritmen för det framtida biblioteket. Figure 1 Block-Scheme of Library Algorithm. Som framgår av Figur 1 består biblioteket av tre huvudblock. Överväg deras purpose. MQL5-block, preliminär förberedelse av skickade mottagna data. Omvänd arrays. Types conversion. Strings encodings conversion. Converts array i mxArray structure. Passes MATLAB Engine commands. MATLAB Engine block beräkningar system. Now, låt oss hantera algoritmer Vi ska börja med MQL5 block Att uppmärksamma läsaren har redan märkt att det kommer att fokusera på genomförandet av det som skrevs i datatyperna i MATLAB och MQL5 avsnitt Om du har missat det, kommer du knappt förstå varför allt detta är nödvändigt. Algoritmen för mlInput variabletypsfunktionerna är nästan identiska Låt s diskutera sitt arbete med funktionen mlInputDouble som ger inmatning av variabler av dubbeltyp till MATLAB virtuell machine. bool mlInputDouble dubbel array, int sizeArray, sträng NameArray where. array referens till variabel eller array av storleken på double type. sizeArray array storlek Av element, inte byte. NameArray-sträng, som innehåller unikt variabelnamn för MATLABs virtuella maskinnamn måste motsvara MATLAB-krav. Konvertera namnArray-sträng till char array med funktionen StringToCharArray. Kontrollera typ av indexering med funktionen ArrayIsSeries Om typ av indexering är normalt passvärde till funktionen mlxInputDouble ELSE indexering av timeseries array reverse array och överför värde till funktionen mlxInputDouble. End funktion, skicka det returnerade värdet till funktionen mlxInputDouble. Algoritmen för mlGet variabletypsfunktionerna är också nästan identiska. Låt oss diskutera sitt arbete med Funktionen mlGetDouble, som returnerar variabeln av dubbeltypen från MATLAB virtuell maskin Ne. int mlGetDouble dubbel array, int sizeArray, sträng NameArray where. array referens till variabel eller array av double type. sizeArray array storlek antal element, inte bytes. NameArray-sträng, som innehåller unikt variabelnamn för MATLAB virtuell maskin. Convert NameArray-sträng att räkna array med funktionen StringToCharArray. Find storleken på array med funktionen mlxGetSizeOfName. IF storlek är mer än noll fördela mottagaruppsättningen med nödvändig storlek med funktionen ArrayResize, hämta data om mlxGetDouble-retur array size. IF storlek är NOLL returfel , Det vill säga nullvärdet. Det är det mlGetInt och mlGetLogical funktionerna producerar skuggkonvertering av typer dubbelintool. För detta ändamål skapar dessa funktioner en temporär minnesbuffert i sina kroppar. Detta är en tvångsmätning, tyvärr tillåter MATLAB API inte att skapa MxArray-strukturer för andra datatyper än dubbla Men det betyder inte att MATLAB fungerar exklusivt dubbeltypen. CC-blocket är långt ifrån ier - det ska tillhandahålla datatranslation från dubbeltypen till mxArray-strukturen. Det görs med mxCreateDoubleMatrix mxGetPr och memcpy-funktionerna. Sedan använder den engPutVariable-funktionen data till MATLABs virtuella maskin och för att extrahera data som den använder funktionen engGetVariable Again, uppmärksamma funktioner med prefix Int och Logical som ses i block-programmet, de interagerar inte direkt med MATLAB, men använder mlxInputDouble mlxGetDouble och mlxInputChar-funktionerna. Algoritmen för deras beteende är ett enkelt samtal av mlxInputDouble mlxGetDouble-funktionens ingångsutgångsvärden som dubbla Och skicka skuggan MATLAB-kommandot för att konvertera datatyp via funktionen mlxInputChar. MATLAB Engine block är ännu enklare Det ger endast matematiska funktioner Dess beteende beror på dina kommandon och dina m-funktioner. Nu när alla detaljer i projektet är klara , Det är dags att ta itu med projektbyggnaden. En sådan byggnad börjar med att skapa huvudbiblioteket i vårt fall jag T är CC-block För detta ändamål skapar du i en ANSI-textredigerare Notepad, Bred, etc, en fil med DEF-tillägget. Det är önskvärt att namnet på den här filen består av latinska tecken utan mellanslag och skiljetecken, annars kommer du att höra många Smickrande ord från din kompilator Den här filen anger dina funktioner Om den här filen är frånvarande kommer CC-kompilatorn att uppfinna sina egna exotiska namn för att exportera funktioner. Den här filen innehåller BIBRARY-kontrollord, bibliotekets LibMlEngine-namn och EXPORTS andra kontrollord, då kommer namnen på funktioner Som du visste förmodligen kan namnen på exportfunktioner inte ha mellanslag och skiljetecken. Här är texten i filen från arkivet. BIBLIOTEK LibMlEngine EXPORTS mlxClose mlxInputChar mlxInputDouble mlxInputInt mlxInputLogical mlxGetDouble mlxGetInt mlxGetLogical mlxGetSizeOfName mlxOpen. So vi har Den första filen av projektet Öppna nu Utforskaren och gå till mappen MATLAB Extern inkludera mappen Kopiera filhovedfilen till M h-filen MATLAB vi Rtual maskin till mapp, där du projektet är byggt om du vann t gör det här måste du manuellt ange sökvägen till scenen vid sammanställningen. Nu är det dags att skapa CC-block Vi kommer inte att inkludera hela källkoden för Program i artikeln eftersom den här filen finns i as och den är väl kommenterad Observera att det är bättre att skapa funktioner med stdcall-konventionen, dvs parametrar skickas genom stapeln och funktionen rensar stacken. Denna standard är inbyggd för Win32 64 API. Consider hur man deklarerar en funktion extern C declspec dllexport variabel typ stdcall Funktionstyp name. extern C declspec dllexport berättar C-kompilatorn att funktionen är extern. variabletyp typ av returnerad variabel, kan vara ogiltig, bool, int, dubbla komposittyper som inte bara är kända till Dll, men också att ringa program och pekare. Förklaring om att överföra parametrar för att fungera och tillbaka, det är standard för Win32 64 API. Funger din funktion name. type namntyp och namn på inmatningsvariabel, max Imal antal variabler är 64.CC block building för detta måste du inkludera standardinmatningsutdatabibliotek och lägg till projekt följande filer i kompilatorn Project - Add Project. In MATLAB Extern lib win32 64 compiler mapp, där MATLAB MATLAB huvudmapp win32 64 antingen Win32-mappen för 32-bitars OS, eller Win64 för 64-bitars OS-kompilatorn Borland-mappen för Borland CC ver 5-6, Microsoft-mappen för Microsoft Visual CA vanlig fråga som det här kan hända att jag har en annan version av kompilatorn eller nej En sådan kompilator i listan Mycket sällan finns det inga sådana filer Låt oss se hur man manuellt skapar ett offentligt bibliotek Vi kommer att överväga hur det görs i Visual C och i Borland C. I FAR öppna MATLAB Bin Win32 64 mapp där MATLAB MATLAB Huvudmappen win32 64 antingen win32-mappen för 32-bitars OS eller Win64 för 64-bitars OS. För Borland C anger Implib Samma för. För Visual C skriv in lib samma för. Om annan kompilator måste någon kompilator av något programmeringsspråk ha det här verktyget - Library Manager, Vanligtvis är det här en konsol-programkompilatormapp. Förresten glömde jag att varna dig. Försök inte göra 64-bitars LIB för 32-bitars kompilator. Ta reda på om det finns 64-bitars adresseringsstöd i kompilatorhjälp Om inte , Antingen letar efter 32-bitars MATLAB DLL eller välj en annan CC-kompilator. Kommer ner till kompilering, varefter vi får ett bibliotek, som ska placeras i mappen MQL5-bibliotek i terminalmappen. Nu börjar vi med MQL-blocket Kör MetaEditor, klicka på Ny och gör som på följande figurer. Figur 2 MQL5 Wizard Skapa Library. Figure 3 MQL5 Wizard General Properties of Library. Nu när Wizard MQL5 har skapat en mall, fortsätt till dess redigering. Notera att MQL 5 du kan skicka pekare på två sätt. void NameArray Denna metod att gå från array tillåter bara att läsa data. Om du försöker använda den här referensen för att redigera innehållet får du åtminstone ett åtkomstfel i det bästa fallet. MetaTrader 5 kommer tyst att hantera felet i SEH - ram, men vi har inte skrivit en SEH-ram, så vi c En jämn saknar orsaken till error. void NameArray Med denna metod kan du läsa och redigera array innehåll, men du måste behålla array size. If funktionen inte accepterar eller inte passerar parametrar, ange alltid tomtypen.2 Vi vann T beskriva alla funktioner i MQL-blocket, eftersom du kan hitta källkod i. Därför ska vi överväga detaljerna för deklarationen och definitionen av externa funktioner i MQL5.As ses i exemplet kombineras deklarationen och definitionen av funktionen i detta fallet deklarerar vi en funktion som heter mlInputChar som extern export, som returnerar värdet av bool-typen och accepterar array-strängen som parameter nu kompilera. Nu när vi har slutfört det sista blocket i biblioteket och sammanställt det är det dags att testa det I reella förhållanden. För att göra detta, skriv ett enkelt testskript eller ta det från filen. Skriptkoden är enkel och väl kommenterad. Som vi ser från skriptet, skriver vi in värden och får värden. I motsats till MetaTrader 4, där vi behövde att veta storleken på bufferten på designstadiet, i MetaTrader 5 behövs det inte, eftersom vi använder dynamiska buffertar. När du äntligen förstått MATLABs virtuella maskin kan du börja använda DLL inbyggd i MATLAB-miljö.3 2 Tekniska riktlinjer för byggandet Med hjälp av DLL genererad av MATLAB Compiler 4.I den föregående sektionen har du lärt dig hur du skapar ett bibliotek för universell interaktion med MATLAB-paketet. Denna metod har dock en nackdel - det kräver MATLAB-paket från slutanvändaren. Denna begränsning skapar ett antal svårigheter vid distribution Av färdig mjukvaruprodukt Det är därför MATLAB matematiska paket har en inbyggd kompilator som gör att du kan skapa fristående applikationer oberoende av MATLAB-paketet. Låt oss ta en titt på det. Tänk på en enkel indikator - glidande medelvärde SMA Lätt uppgradera det genom att lägga till ett Neural Network Filter GRNN, som tillåter att släta vitt brus slumpmässigt utbrott Namn den nya indikatorn som NeoSMA, och filtrera som GRNNFilter. Thus vi har två m-fun ctions, av vilka vi vill skapa en DLL, som kan kallas från MetaTrader 5.Nå kom ihåg att MetaTrader 5 söker efter DLL-filer i följande mappar. terminaldir MQL5-bibliotek. Aktuell mapp. Systemmapp windowsdir SYSTEM32.Directories listade i systemmiljön Variabel PATH. Därför placerar du i en av dessa kataloger två m-funktioner NeoSMA m och GRNNFilter m där vi bygger DLL Jag uppmärksammar detta placeringsfält, eftersom detta inte sker oavsiktligt Uppmärksam läsare vet redan MATLAB-kompilatorn Funktionen - den bevarar vägarna när man sammanställer se 2 2 MATLAB Compiler 4. Innan du börjar kompilera projektet måste du konfigurera kompilatorn Gör så här genom att följa dessa steg. I MATLAB-kommandoraden, skriv in mbuild - setup. Tryck på y för att bekräfta sökningen av CC Kompatibla kompilatorer installerade i ditt system. Välj standard Lcc-win32 C compiler. Press y för att bekräfta vald kompilator. Bild 4 Kompilera projektet. Nå är vi redo att flytta till m-funktioner kompileringsprocessen. mcc - N - W lib NeoSMA - T-länk lib NeoSMA m GRNNFilter m. förklara tangenterna. - N för att hoppa över alla onödiga sökvägar - W lib NeoSMA berättar kompilatorn om att NeoSMA är bibliotekets namn - T länk lib berättar kompilatorn för att skapa ett offentligt bibliotek med länkning av NeoSMA M och GRNNFilter m m-funktioner namn. Nu, låt oss se vilken kompilator har skapat. loggfil som innehåller compilers actions. NeoSMA c C version av biblioteket innehåller - kod för wrapper. CTF-fil se 2 2 MATLAB Compiler 4 section. NeoSMA h header-filen innehåller deklarationer av bibliotek, funktioner, konstanter. Objekt filkälla fil som innehåller maskin och pseudokod. exporterade funktionsnamn. Dll för vidare koppling. Dll att använda i CC-projekt. NeoSMAmcccomponentdata c C-version på komponent som används för överensstämmelse med CTF-fil, innehåller sökvägar etc. objektversion av komponentkällans fil innehållande maskin och pseudokod. Så låt oss hantera DLL, exakt med dess interna struktur Den består bara av grundläggande funktioner. Huvudfunktionen hos en DLL-BOOL WINAPI DllMain som enligt Microsoft-specifikationen hanterar händelser som uppstår i DLL DLL, laddar in i adressutrymme för process, skapar en ny ström, tar bort strömmen och laddar Dll från minnet. funktioner för DLL-initialisering deinitialisering BOOL NameLib Initialisera void void NameLib Avsluta tomgång behövs för att starta avläsning av Math Arbetsmiljö innan du använder biblioteksfunktionerna och i slutet av deras användning. Exporterad m-funktioner tomt mlf NamnMefil int antal återställningsvärden, mxArray-returvärden, mxArray-inmatningar, var. numberofreturnvalues antal returnerade variabler don t förvirra med array storlek, etc. mxArray returnvalues adress av mxArray-strukturen där resultaten av m-funktionsarbetet kommer att returneras. mxArray-inputvärden pekar på mxArray-strukturen för m-funktionens inmatningsvariabel. Som du kan se innehåller exporterade m-funktioner adresser och pekare till mxArray-strukturen, och du kan inte direkt Ring dessa funktioner från MetaTrader 5, eftersom det inte kommer att förstå denna typ av data. Vi vann inte t beskriva mxArray-strukturen i MetaTrader 5, eftersom MATLAB-utvecklare inte garanterar att det inte kommer att förändras över tid, även inom samma version av produkten, så Du måste skriva en enkel DLL-adapter. Dess block-schema visas nedan. 5 DLL-adapter Block - Scheme. It ligner mycket på höger sida av DLL för MATLAB Engine, så vi vann inte att analysera sin algoritm och fortsätta direkt till koden För att göra detta, skapa två små filer i din CC compiler. LIBRARY nnSMA EXPORTS IsStartSMA nSMA. Build projektet i din CC-kompilator för detta måste du inkludera standardinmatningsutdatabibliotek och lägg till projekt följande filer i din Kompilator Projekt - Lägg till Project. In MATLAB Extern lib win32 64 kompilator mapp, där MATLAB MATLAB huvudmapp win32 64 antingen win32 mapp för 32-bitars OS, eller win64 för 64-bitars OS kompilatorn borland mappen för Borland CC ver 5-6, Microsoft-mappen för Microsoft Visual CI har filer för version 6. Skapa manuellt 3 1 Utveckla universellt bibliotek med MetaTrader 5 MATLAB Engine Interaction. Den sista, vad jag vill berätta för dig i det här avsnittet handlar om filer som behövs när projekt flyttas till en annan dator, där det inte finns någon MATLAB installerad. Här är en lista över filer och sökvägar på målmaskinen. någon mapp MCR installatör. någon mapp för MCR-installationsprogrammet. någon mapp för MCR-installationsprogrammet. någon mapp för MCR-installationsprogrammet. terminaldir MQL5-bibliotek. terminaldir MQL5-bibliotek. terminaldir MQL5-bibliotek. Många avancerade programmerare har redan gissat att det är lämpligt att använda ett installationsprogram SETUP Det finns många av dem via Internet, inklusive gratisprodukter. Nu måste vi testa denna DLL i MetaTrader 5 För att göra detta ska vi skriva Ett enkelt skript från. Så, du vet hur man skapar ett universellt bibliotek för MetaTrader 5 MATLAB-interaktion, och hur man ansluter DLL inbyggd i MATLAB-miljö. Men det finns fortfarande gränssnitt för MetaTrader 5 MATLAB-interaktion som beskrivs, men detta ligger bortom Omfattningen av denna artikel Emnet i den här artikeln är täckt av detaljer Jag har valt de mest effektiva sätten att växelverkan, utan att kräva en speciell typ av adaptrar. Även om du kan gå på ett annat sätt, som teknik - Hur exporterar du citat från MetaTrader 5 till applikationer Använda WCF-tjänster. Många läsare kan få en fråga vilken metod som ska väljas. Svaret är enkelt - båda, eftersom det inte behövs någon hastighet i designfelsökningen av matematisk modell. Men du ska Behöver full kraft av MATLAB utan speciella produktionskostnader för programmering MATLAB Engine hjälper här, förstås Men när matematisk modell är debugged och redo att använda, behöver du hastighet, multitasking arbete med indikator och eller handelssystem på flera prisdiagram - här utan tvekan behöver du en DLL, byggd i MATLAB-miljö. Men allt detta förpliktar dig inte att följa det. Alla kommer att svara på den här frågan själv, och baserar sig främst på hur mycket programkostnaden är för projektets omfattning Antal indikatorer och eller systemanvändare Det är ingen mening att skapa Dll i MATLAB-miljön för en eller två användare. Det är lättare att installera MATLAB på två datorer. Många läsare, som inte är bekant med MATLAB, har förmodligen en fråga varför alla Denna MQL5 har redan matematiska funktioner Svaret är att användningen av MATLAB gör att du enkelt kan implementera dina matematiska idéer, här är bara en partiell lista över möjligheter. Dynamisk algoritm för fu Zzy logik i indikatorn och eller mekanisk handelssystem. dynamisk genetisk algoritm i mekanisk handelssystem dynamisk strategi tester. dynamiska neurala nätverksalgoritmen i indikatorn och eller mekaniska handelssystemet. Tre dimensionella indikatorer. imulering av olinjära styrsystem. Så allt i din händer och glöm inte matematik har alltid varit vetenskapsdrottningen och MATLAB-paketet är din vetenskapliga räknare. Översatt från ryska av MetaQuotes Software Corp Originalartikel. Bitfinex tillkännagav idag starten av gruvkontrakt som en handelsprodukt på sin plattform Totalt 100 THS terahashes per second with an expiration in 3 months have been made available for trading under the name TH1BTC The 100 THS are part of a larger pool of 3500 THS so more mining contracts might become available in the future Interestingly, this marks the first time that it is possible to short a mining contract. Shorting a mining contract means to receive an amount of Bitcoin now the price we sell it at and subsequently paying dividends in Bitcoin over the following 3 month until the contract expires in the middle of December A profit is made if the sum of all the dividends paid out plus the interest we paid to short the contract is less than what we received at the beginning when we sold the contract to someone else obviously. This means the price of TH1BTC should depend on 3 variables in decreasing order of importance. The change of the mining difficulty until 15 December. The time remaining until 15 December. The interest rate swap rate. If difficulty increases dividend payments become smaller because 1 THS represents a smaller fraction of the whole network hashing power Therefore the price of one contract should decrease if difficulty increases The closer we get to expiration the fever Bitcoins can be mind with 1 THS in total Therefore the price of one contract should decrease the closer we get to expiration and reach a price of 0 at expiration. The higher the interest ra te the more costly it is to enter and keep the contract over the full length of 3 month Bitfinex does not offer 90 days swaps, therefore entering a contract with the goal to hold it until the end contains quite a bit of interest rate risk because at some point a new swap has to be taken out at a potentially unfavorable interest rate This is less of a problem when going long Bitcoin rates are typically low than when going short there is only a maximum of 100 contracts available in total, no naked shorting To compensate for the risk prices should increase when swap rates are increasing. The big unknown is of course the change in the mining difficulty over the next 90 days In the following figure we see how difficulty changed over the previous 6 month. The data is from Tradeblock and it shows not only a graphical representation of past changes in the difficulty difficulty changes every 14 days depending on past hash rate More info can be found in the wiki but also some basic summary statist ics On average difficulty has increased 27 over the last 30 days and 77 over the last 60 days. To estimate the fair price of one TH1BTC we will assume that difficulty will increase on average 15 per month over the next 3 month Currently the price of buying one contract worth 1 THS is 2 BTC The pool fee is 3 and we will ignore interest rates Filling in all the information we get the following results. Hence if we go long one contract based on our assumptions we would make a loss of about 0 39 Bitcoin a bit more in reality since we will start mining in the middle of September until the middle of December because the expected dividends monthly revenue is not going to cover our initial costs of 2 BTC before the contract expires. On the other hand, going short at a price of 2 Bitcoin would have generated a profit of about 0 39 Bitcoin per contract Keep in mind that we didn t include swap costs which are currently at around 1 per day. There are two ways to look at the results Either we could say prices for TH1BTC are currently overvalued and should be closer to around 1 5 BTC If we assume difficulty will increase more than 15 per month then prices should be even lower than that Or we could say that the market is efficient and prices are correct, which would imply that the market is expecting difficulty to decrease on average about 2 per month over the next 90 days Either way, results will be known with certainty in 90 days. Struggling to recover from the most recent Bitcoin flash crash which originated on Bitfinex only four days go Bitcoin prices took another dive today as margin traders got their positions liquidated on BTC-e. The event started at 1 36 PM UTC 1 when large sell orders began to show up on the third largest western Bitcoin exchange BTC-e Downwards momentum increased steadily as the orderbook became increasingly thin, crashing prices to a low of USD 309 per Bitcoin at 1 43 PM In the following minutes prices rebounded swiftly on thin volume back to around USD 442 a s arbitrage traders started to take advantage of the discount relative to other exchanges. BTC-e is one of the few large exchanges that offer margin trading to their clients via the MetaTrader platform since November 2013, but the details of who excactly provides the funds necessary for margin trading have remained unclear The shape and especially timing of the crash points towards margin traders being liquidated or stop orders being executed , similar to what happened on Bitfinex a couple of days ago However, unlike Bitfinex which is transparent about open swap positions BTC-e does not provide important data which would be needed to provide a more thorough analysis and so this last statement can only be considered a good guess. Unlike Bitfinex, which relies on a hidden algorithm in an effort to control the order flow BTC-e seems to have no special safeguards in place to mitigate such events The fall below 400 was mainly due to a lack of bids in the orderbook and not because the market b elieved that the true value was below 400, as the rebound back to over 440 only minutes later basically proved Hence, halting trading during extreme downwards volatility could have easily averted the bloodshed among margin traders by giving other market participants more time to thicken the orderbook. Update 4 58PM UTC 1 BrCapoeira posted on Reddit an interesting graph based on data from the Metatrader platform. This graph implies that a single large order was the cause of this event Whether this order was created due to a margin call, a simple mistake, to manipulate the market, or to open a large short position remains unclear Common sense would suggest that it was probably the result of a margin call of a single large trader. My previous post on this topic has been brought up during discussions in the aftermath of the most recent Bitcoin flash crash Coindesk was one of the first to pick it up and since then various posts about transparency and the possible responsibilty of exchanges to actively manage order execution started to appear As a result of those events Josh Rossi, Vice President of Business Development at Bitfinex, went on Reddit to openly address some of the issues brought up against the exchange. The facts we know for sure are that there were some large sell orders shortly before the crash started, for example a 500 sell order on Bitstamp at 9 49am UTC 1 , about 6 minutes before a large sell order on Bitfinex triggered the crash However, the data does not tell us whether it was insider trading, some form of market manipulation or a simple mistake. Fact is that after the Bitcoin flash crash open swap positions decreased from around 28m to 24m which indicates about 8400 margin long positions were closed assuming an average of 475 in one way margin call or another stop order hit The data does not tell us what the ratio is but according to Josh only about 650 Bitcoins were sold as the result of margin calls. As correctly pointed out by Jonathan Levin fact is tha t starting about 24 hours before the bitcoin flash crash until the crash itself an additional 1000 Bitcoins were taken out in short positions and about 2500 shorts were subsequently closed during the crash Whether those shorts were opened to hedge existing positions, as a malicious attempt to trigger a margin call, or a way to front-run the market using private information cannot be determined from the available data it does look oddly suspicious though. What was unexpected. Personally, the interesting point is not that Bitcoin flash crashed Sudden price fluctuations happened in the past and will happen in the future, especially in illiquid markets such as Bitcoin The interesting point is the involvement of Bitfinex and how they actively managed order execution without informing market participants in advance. The Bitfinex matching engine was not halted during the whole crash though it did slow down but nowhere as bad as the infamous 70 minute order lag on the now defunct MtGox exchange d uring the crash in 2012 However, what Bitfinex did was they introduced something they now refer to as speed bumps What it means is that they essentially flag orders they deem as invalid or potentially dangerous and slow them down intentionally. At first sight this might seem like a nice idea Who doesn t want a filter to remove or slow down malicious orders However, as so often with those kind of things the devil is in the detail. The problem is that Bitfinex has not and possibly never will make public how exactly they categorize an order as bad and slow it down If a market participant decides to put up a large sell order against a thin orderbook then that s his decision Whether his action was intended or not is not up to the exchange to decide It might be that this market participant was simply the first person to react to a major event and is entirely willing to bear the additional costs of the resulting slippage in anticipation of a major price move There simply does not exist a way to accurately classify orders a priori as good or bad since that would automatically assume knowledge of all immediate future events. What can be improved. Mistakes fat finger , algorithm going havoc happen, margins get called and people try to game the system in every possible way Logically there have to be safeguards in place to protect markets and its participants Bitfinex was definitely aware of potential toxic order flow and prepared counter measures The only thing they forgot was to inform their clients about the hidden safety features. Hiding those safeguards from the public adds uncertainty to the market especially now that we know they exist and sometimes do something and essentially puts every traders trust into the hands of Bitfinex At this point a trader can only hope that Bitfinex will always act in the best intentions of their clients This hope might be futile though, since Bitfinex makes money from trading fees, independently whether a trader actually makes any money One does not have to think for long to realize the hidden potential for abuse in such a system. The main reason brought up by Josh why Bitfinex does not intend to publicise their algorithm is to avoid giving traders the possibility to exploit it is bogus and the following shows why. Those are the official market wide circuit breakers used by NASDAQ, posted online and entirely transparent for every market participant Those rules are certainly not perfect but they are simple, transparent, and work for one of the largest stock markets in the world Now, I have great respect for the people working on the Bitfinex platform, but I doubt that they managed to come up with an algorithm which protects market participants better than the ones used by a major exchange trading more than 900 million shares per day on average And if they did, now is the chance for Bitfinex to prove it to the world and possibly write history by teaching the big boys how to properly run an exchange. When it comes to public exchang es transparency is a must, not just for Bitfinex but for any exchange Market participants have to know exactly what happens when they place an order and should under no circumstances have to rely on good faith alone Safeguards are important because accidents happen and markets crash but it is not up to the exchange to engage in secret order discrimination There are different ways to safeguard financial markets and none of them is perfect Adding complexity usually increases the chance for unintended side effects and therefore a simple, transparent approach seems more appropriate than a hidden, complex one. Two days ago BitMEX reduced their trading fees to 0 and celebrated it by releasing a basic market making bot on Github. BitMEX is currently running a trading challenge until August 29, 2014 to promote their new platform Releasing a market marking bot is probably an interesting and effective way to increase API traffic and stress test the platform a bit Of course I couldn t resist and ha d a look. Market-maker is a forked off Liquidbot which was original designed to run on the now obsolet MtGox exchange There were some minor changes new api class to connect to BitMEX, some additional prints to console, changes to adapt for futures contracts, and a huge and unnecessary print to console when starting up but no significant changes to the trade logic. The algorithm uses REST and only checks for changes every 60 seconds This already disqualifies the bot as it is essential too slow to react to ongoing changes in the orderbook BitMEX limits requests to the REST API to 150 per 5 minutes so you can try reducing the 60 seconds to something like 3 but it won t change the fact that as soon as markets start to move you will hit the limit and be stuck with open positions To be fair, BitMEX provides the bot more as a marketing stunt and explicitly states that switching to WebSocket will be highly beneficial as it allows real time updates. Overall, the algorithm is solidly written, techn ically works and is easy to setup, but it won t make you any money in the long run If someone seriously considers to employ this bot I would recommend the following small changes to make the code more usable.1 Change to Websocket.2 Exit position on close.3 Build orders starting from the midpoint. In addition I would advise to measure volatility in some way and adapt the distance between orders dynamically as well as the size. During my testing the API was always responsive and accurate Volume on the exchange is still low but the fundamentals of the platform look promising This bot is a fun tool to introduce users into the world of market making and algorithmic trading but it won t stand a chance against established algorithms. Note If you consider using this algorithm keep in mind that market making is a full time job Anything less than complete dedication, fast reaction time, and 100 uptime will cause you to lose money. Edit Follow up on the aftermath here. Today Bitcoin prices took a dive as margin traders on one of the largest exchange Bitfinex got their orders liquidated For many close market observers and more sophisticated traders this did not come as a surprise In fact, long positions have been building up continuously over the last couple of months in anticipation of a new bubble in Bitcoin prices and reached as high as 30m in outstanding swap positions on Bitfinex. Now, this wouldn t be a problem all by itself as long as there is enough capital backing the loan Unfortunately, most of those long positions were entered around 600 640 USD BTC and the collateral was mostly provided in Bitcoins itself The following chart nicely shows the buildup of long positions, peaking around July 14 with close to 32m in swaps. Running some quick math based on the maintenance margin of Bitfinex of 13 and assuming Bitcoin as collateral we find that margin calls should start around the 520 540 USD BTC mark Yesterday, prices came close and today they finally jumped over the cliff. The p roblem is that once margin calls set in you have a cascading effect which rips through the order book, causing even more orders to reach the point of no return and increasing the downward momentum further These kind of events are not limited to Bitcoin exchanges but can also occur on major exchanges such as during the 2010 flash crash in the US The cause of such a flash crashe can vary and goes from fat finger mistakes to programming errors to cascading margin calls. It is interesting to see how the exchanges deal with these events In the US, Nasdaq implemented market wide circuit breakers which will cause trading to stop under such extreme circumstances Bitcoin markets are not yet as advanced and usually continue trading If we look at the order action on Bitfinex today we see something very peculiar. It seems and this is just a guess as there is no official comment from the exchange as if Bitfinex is running an algorithm to handle the margin calls The algorithm starts selling but limits itself to a 10 drop in prices within 1 minute If prices drop more than 10 in 1 minute it will stop selling and wait for buy orders to come in Once there are again a certain amount of buy orders in the orderbook the algorithm starts selling again until all margin calls are met Edit LeMogawai was the first to point this out in this post and it matches my personal observation at the time of the event. This seems to be an interesting way to deal with cascading margin calls but can also be considered as borderline market manipulation from the exchange side By spreading out the sell orders over time the downwards momentum is reduced, however traders end up trading against the exchange itself and not the market anymore The exchange has an informational advantage at that point and is therefore more likely to profit than the traders Fortunately, this only lasted for about 10 minutes after which control was given back to the market. Other exchanges which also offer margin trading such as BTC-e an d OKcoin are now in a favorable position and can learn from todays events Implementing a system more closely resembling the circuit breakers of big exchanges such as Nasdaq might be a smart first move. Recently I am working to get my new trading platform going This new version is based on Python, uses MySQL to keep a database of all time series of different virtual currencies with automatic backfill from BitcoinCharts and integrates the 3 major exchanges MtGox, BTC-E and Bitstamp The platform will be used as way to backtest some strategies and engage in automatic trading. During the run-up to this I decided to pull some data of BTC against USD from BitcoinCharts and based on the ideas of a paper by Hashem and Timmermann 1995 implemented a simple trading strategy The idea is to forecast the sign of the t 1 period return based on a regression, which is estimated on an automatic selection of technical indicators during the last n period up until t Then, after t 1 happened, we refresh the mo del and try to predict t 2 using all the data available of the last n periods until t 1 and so on. For my Bachelor Thesis I examined four different technical trading rules in Forex markets It uses MCS and SPA test to search for valid models among different parameters that are not subject to data snooping Taking into account realistic transaction costs we find no evidence of excess returns, which is consistent with market efficiency. With this code you should be able to look for Bitcoin arbitrage opportunities within BTC-e It uses the idea of one price and applies triangular arbitrage, taking into account costs and spread The reason I post this here is despite that it works, chances are you will be too slow to compete with other investors doing the same. Possible improvements would be to take into account the order book depth and split the trades up dynamically, trying to undercut other traders doing the same Also setting everything up on a dedicated server close to the physical location o f the BTC-e match engine should drastically reduce lag and give you a potential edge. Post navigation. Cointegration Indicator. Cointegration Indicator. Thanks 10 given, 66 received. I posted a cointegration indicator CADF in the Elite Downloads area It plots the output statistic of an Augmented Dickey Fuller cointegrating regression of 2 instruments It s a C translation of MATLAB code developed by James P LeSage and posted at Econometrics Toolbox for MATLAB I used some mathematical routines from ALGLIB ALGLIB which are included, and wrote a lot of helper routines to accomplish the MATLAB functions Even if you re not interested in cointegration, you might find it useful as an example programming with quantitative methods for NinjaTrader. I haven t seen a cointegration indicator for a trading platform posted publicly before, only MATLAB or R code So I thought I would be the first I posted it for formerly BMT Elite members only, please don t share or distribute. This version is made using prima rily static routines, which call new frequently This works fine for indicators or normal strategies, but it can fall apart by filling up memory if you try to run an extensive optimization on it The alternative is to implement the internal routines as classes which can be instantiated once and pre-allocate their storage once at the start I ve done that for strategies, and it helps optimizer performance quite a bit, but ALGLIB uses new in some places so I haven t been able to get rid of all uses of new. I also posted the latest ALGLIB 3 5 0 library, packaged as a NinjaTrader indicator , in the MATLAB downloads area But it s not needed for CADF, the required ALGLIB routines are included. I posted a cointegration indicator CADF in the Elite Downloads area It plots the output statistic of an Augmented Dickey Fuller cointegrating regression of 2 instruments It s a C translation of MATLAB code developed by James P LeSage and posted at Econometrics Toolbox for MATLAB I used some mathematical rou tines from ALGLIB ALGLIB which are included, and wrote a lot of helper routines to accomplish the MATLAB functions Even if you re not interested in cointegration, you might find it useful as an example programming with quantitative methods for NinjaTrader. I haven t seen a cointegration indicator for a trading platform posted publicly before, only MATLAB or R code So I thought I would be the first I posted it for formerly BMT Elite members only, please don t share or distribute. This version is made using primarily static routines, which call new frequently This works fine for indicators or normal strategies, but it can fall apart by filling up memory if you try to run an extensive optimization on it The alternative is to implement the internal routines as classes which can be instantiated once and pre-allocate their storage once at the start I ve done that for strategies, and it helps optimizer performance quite a bit, but ALGLIB uses new in some places so I haven t been able to get rid of all uses of new. I also posted the latest ALGLIB 3 5 0 library, packaged as a NinjaTrader indicator , in the MATLAB downloads area But it s not needed for CADF, the required ALGLIB routines are included. Thanks for your contribution, I never been exposed to this trade style and i am a completely ignorant about this, but for sure its an interest theme and style It will be good if you post some example on how to use this approach. May 24th, 2012, 03 43 PM. Futures Experience Beginner. Favorite Futures DAX, EUR USD. Posts 18 since Aug 2010.Thanks 16 given, 2 received. kevind, about some examples I would be pleased too I experimented with this approach in Matlab before a while and tried to translate this to C but failed The same problem with R Thank you for your code I will take a look. It should work fine with futures, or futures paired with stocks You need to enter a symbol in the proper form, the symbol must exist in the instrument manager, and the data has to exist for the period specified Cointegration is typically tested on daily data over longer periods, so continuous futures data is probably your best bet. Proper symbol form is i e ES - for continuous futures, or ES 06-12 for a specific contract. Thanks for the reply I have the ES and 6E loaded on a Ninja chart for max days daily chart Also tried 1440 minute chart because I know some indicators only report on 1440 minute charts on Ninja Still nothing with the CADF The parameters list Symbol 2 , which I assume is the second symbol, Nlag ste to 1, P set to 0, and Period set to 250 Should any of these be adjusted Thanks.
Comments
Post a Comment