Set as homepage
Våra filialer över hela världen: Tyskland | Frankrike | Spanien mer »

Varför Automatiserad Handel med XTB?

  • Slå av dina känslor - bli automatisk
  • High Frequency Trading – var snabbare än alla andra
  • Sapara din tid – låt datorn sköta jobbet
  • Gör dina egna strategier utan programmeringskunskaper
  • Dina pengar kommer aldrig att sova

 

Vad menas med Automatiserad handel?

Automatiserad handel är en samling av olika metoder som gör att handeln blir lättare, mer precis eller helt automatisk.

Tack vare det, datorn kan genomföra transaktioner utan din närvaro. Du behöver inte sitta framför skärmen och vänta på rätt tillfälle utan allt kan programmeras i förväg.

Automatisk handel kommer att spara både din tid och pengar.
Ta del av den möjligheten.

Ladda ner

 

  • Dokument
    • MQL boken
      MQL boken innehåller all nödvändig information för att kunna köra och använda MQL program i XTB-Trader. Boken förklarar installationen och användningen av MQL program. Alla vanliga problem är förklarade tillsammans med korta , fungerande lösningar.
      Filen är i PDF formatet.
      Ladda ner- MQL Newbie Book

 

Utbildning

  • Inledning

    Vad är Automatiserad Handel?

    Automatiserad handel är en samling av olika metoder som tillåter handeln med datorstödd. Med det menas inte att datorn själv bestämmer hur den ska agera på marknaden , den kan lägga order men efter dina förutbestämda strategier och beroende på marknadsläget. Tack vare det behöver du inte sitta framför datorn hela dagen och följa marknadsutvecklingen.

     

    Med Automatiskt Handel följer lösningar som kan göra tekniska analyser åt dig direkt på diagrammet. Varför slösa bort timmar framför datorn med att räkna ut tekniska indikatorer när allt kan göras av datorn.

    Vad är MQL?

    MQL är ett programmeringsspråk som utökar möjligheter i X-Trader. Språket i sig är mycket likt C, är enkelt att lära sig och kan användas av både professionella användare och amatörer. Man kan behärska språket inom några veckor och redan efter första dagen kan man skriva egna enkla strategier.

    Hur känner man igen ett MQL program?

    MQL filer har två möjliga filändelser:

    • MQ4 – för källkoden
    • EX4 – för kompilerade program

    Skillnaden mellan filer är följande : MQ4 är källfilen och kan redigeras av alla som kan MQL språket. EX4 är en kompilerad fil och kan endast läsas av handelsplattformen.  Kommersiella MQL program är distribuerade i detta form.

    Vad kan jag använda den till?

    För handeln såklart! Program skrivna i MQL kan förbättra handel på flera olika sätt. Oändlig många tekniska indikatorer kan bli skrivna i MQL men framför allt Strategier som kan kontrollera positioner, öppna nya och stänga befintliga. Med Automatiserad handel får du mer tid över och behöver inte följa marknaden och diagram varje dag.

    visa mer visa mindre
  • Olika Typers av MQL program

     

    Strategier (Expert Advisors)

    Strategier (Expert Advisors) är den mest intressanta MQL skripten . De har förmågan att hitta den bästa tidpunkten för att komma in på marknaden. MQL Strategier baserar sig för det mesta på tekniska indikatorer men det finns en mängd av strategier som kan implementeras och som har inget samband med teknisk analys. Till exempel Strategier (Expert Advisor) kan räkna ut korrelationen mellan två instrument och starta handeln beroende på ändringar av korrelationen över tiden. MQL tillåter att skriva Strategier som kan hitta mönster mellan flera instrument.

    Indikatorer

    Indikatorer för Teknisk Analys är speciella skript som kan teckna objekt direkt på diagrammet. Algoritmen ansvarar för värden vid olika tidsteg. Till exempel ”Moving Average” algoritmen tar priset för en given tidsperiod, summerar priser och sen dividerar med perioder. För nästa period kommer algoritmen att göra samma sak men datan som kommer att tas för uträkningar kommer att flyttas en period. Resultatet blir en kontinuerlig linje som visar värden för ”Moving Average” under tidsperioden täckt av diagrammet.

    Skript

    Skript är program som gör det möjligt att göra enkla repetitiva transaktioner automatiskt. Exempel där skripter kan användas:

    • Stänga alla positioner
    • Räkna ut belopp som krävs att öppna positioner
    • Lägga till data på diagrammet
    • Kontrollera anslutningen
    • Konventera och spara data från diagrammet
    visa mer visa mindre
  • Installation

    Most of scripts written in MQL are single files. More sophisticated script can contain more files. This chapter covers all methods of installing the scripts you already have on platform. In order to start using the MQL program, no matter if it is script, indicator or expert advisor, you need to place the program files in the proper platform folder. For our X-Trader platform the folder is usually placed in c:\Program Files folder.

    Copying to folder

    Copying MQL files to the proper folder is the most crude form of installing. However it also appears to be the most comfortable way of installing for more experienced investors. If you are ready to copy MQL files of some program which you have found on our website or found on one of many other internet sites, then just follow the below simple steps:

    • Check in the description of the MQL program you want to install whether it is script, indicator or expert advisor. You may find useful description above which highlight the differences between MQL program types. It’s a very important step, because each type of script has their own folder inside the platform folder. Putting the MQL program into wrong folder will cause inability to run the MQL program.
    • Select the files and select copy operation from right-click menu.
    • Go to the folder where the type of MQL programs you want to install is stored.
    • Expert Advisors: you have to paste the MQL Program file of this kind into folder platform_folder\experts\

    • Indicators: you have to paste the MQL Program file of this kind into folder platform_folder\experts\indicators . It’s the subfolder for the folder where Expert Advisors are stored.
    • Scripts: you have to paste the MQL Program file of this kind into folder platform_folder\experts\scripts . It’s the subfolder for the folder where Expert Advisors are stored.

    I am Vista/Win7 user and I have a problem. What can I do?

    Unfortunately Microsoft Windows Vista has default set of very strict rules for changing data in program files folders (it also includes our Platform folder). Unfortunately if you want use these method (copying) for install the scripts, then you have to ask your system administrator to change the permissions for entire platform folder and the subfolders. You have to be allowed to read and write in platform folder. If you are the user of your own system, then you have to change these permissions.

    Installer based method of installation

    The simplest way to install the MQL program is to use dedicated installer. X-Trade Brokers provide installers for all MQL programs published on their websites. User have to run the installer and follow the instructions on the screen. If the platform has been installed in non-standard folder, then choosing destination folder needs additional care.

    visa mer visa mindre
  • Köra igång

    Preparations

    The very first place where everything need to be properly set in order to use MQL Programs is Setting Menu. The menu is available under Ctrl+O combination of keys. Choose Expert Advisors tab. If any settings has not been changed in platform since installation then the window with settings set like below should appear:

    In order to use MQL Programs in comfortable way, it is needed to change settings. The changed settings are in red rectangles.

    After pressing the OK button, setting should be preserved.

    Caution notice

    Why you should be extra cautious when running program from unknown source. Why it is better to use scripts from trusted sources. (Like us or our affiliates)

    Setting properties of program

    Most of the MQL Programs have properties which can be set before starting the program. It’s extremely important to check and understand these properties. Some properties can change totally program behavior. It’s possible, for example, that the expert advisor will enter the position when completely opposite market conditions will appear.

    Starting the program

    Every program in MQL is attached to the chart on which is started. This means that some properties are taken directly from the chart to which is attached. It also means that user can, and have to choose the chart on which the MQL Program will be executed. I need to note here two important things. Changing the chart (i.e. changing the period of the chart) will cause the restart of the MQL Program. This is imminent and cannot be prevented. There are some scripts that have Instrument and timeframe hardcoded. This means that no matter on what chart such program will be executed. It will do exactly the same work. (first important attention still occurs for this case).

    Expert Advisors

    Expert Advisor can be run by double clicking selected Expert Advisor in Navigator window in Expert Advisors subtree.

    Then the properties window will appear:

    The window has got two tabs: “Common” tab and “Inputs” tab. Let’s focus on ”Common” tab. The most important properties which have to be set are market by the red rectangles. User can choose how independent the Expert Advisor is. Top left red rectangle shows option there can be chosen whether the Expert Advisor is able to open Long Positions, Short Positions or both. It is useful if user want to limit the Expert Advisor to only one type of trade. “Allow live trading” is the most important setting for Expert Advisors. When this option is set, then the Expert Advisor is able to manipulate orders (opening orders, closing orders and modifying orders). “Ask manual confirmation” option is additional to the option above. Setting this option forces manual confirmation of the user for each action regarding orders started by Expert Advisor. The program works in advise only mode. Most users turns this option off.
    The last option, which is very important for users of commercial Expert Advisors is “Allow DLL imports” option. Setting this option allows Expert Advisor using external libraries named DLL files.

    When everything is set and ready to run, then click OK. If everything is in order, then name of the Expert Advisor and smiled face should appear in top-right corner of the chart. If instead of smiled face, sad face is present, then Expert Advisor is working but from some reason it cannot trade. The reason could be unset property “Allow live trading” or closed market for the instrument on chart. If instead of smiles crossed lines has appeared in top-left corner of the chart, then it means that it is needed to turn on Expert Advisors in Option window described earlier.

    Indicators

    Indicator can be run by double clicking selected Indicator in Navigator window in Custom Indicators subtree. The following window should appear:

    If Indicator uses external DLL files, then option Allow DLL imports HAVE TO be turned on.

    “Inputs” tab shows parameters that can be set for chosen indicator. The number of settings and the meaning of each one depends on programmer who coded the indicator. For example the indicator which is shown on window above have only one settings – period for which each calculation of indicator is made. The rest of tabs are responsible for visual properties of indicator and therefore will be omitted.
    Press OK for starting the indicator. The indicator should be now placed on chart.

    Scripts

    Indicator can be run by double clicking selected Script in Navigator window in Scripts subtree.

    Stopping the program

    Each type of program have their own way of stopping execution. The scripts should end their work without user intervention. In case this not happens the script can be stopped by right-clicking the chart to which the script is attached and clicking “Remove Script” option.

    In order to remove indicator from the chart user need remove the indicator from the “Indicators List” of the chart. To achieve that right-click on the chart, choose “Indicators List” option. In window which has been shown choose the indicator you want to delete, and click the “Remove” button. Close the window. The indicator should disappear.


    In order to stop Expert Advisor user have two possibilities:

    • Use “panic button” which turns off all Expert Advisors on the platform:
    • Turn off one Expert Advisor by Right-click on chart to which Expert Advisor is attached and choose “Remove” from “Expert Advisors” submenu:
    visa mer visa mindre
  • Testa programmet

    Testing Expert Advisor

    Really important

    What is really important during testing the strategy? Why the strategy testing is important? The answer is simple. Testing provides the possibility to check if all assumptions included into strategy are right, if the code of the strategy does exactly what was meant by maker and if there are no potentially dangerous errors.
    In XTB-Trader platform three levels of testing Expert Advisors can be applied:

    • Backtesting – testing on historical data, some assumptions described below are taken
    • Demo account testing – testing on demo account with virtual money
    • Real account testing – testing on real account, with real money, but under user advisory

    First test should be made on Backtesting, because it could be done in minutes. The second is running strategy on demo, which spends more time. Sometimes it takes a week of working for Expert Advisor on demo account. If everything is working as it was in assumptions, then there is time for real account tests, where the Expert Advisor will be tested “on battlefield”. After that we could be sure that our Expert Advisor (or Expert Advisor we want to use) is reliable piece of software, and can be used for profitable Automated Trading.

    Backtest testing

    Backtesting of the strategy is very important. Testing on historical data gives information how the strategy behaves in historical conditions. That should always be the very first step of testing Expert Advisor. In few seconds validity of the Expert Advisor will be checked. The implications are obvious. Good, profitable Strategy can be easily recognized, and losing strategy (or even strategy with errors) can be easily discarded or sent back to programming stage. In most cases backtesting helps in correcting small, yet important errors.
    In XTB-Trader platform special functionality for backtesting is available under the key combination Ctrl+R. The Tester subwindow should appear.


    This window has several properties:

    1. Expert advisor – for choosing expert advisor to be tested.
    2. Symbol – instrument on which Expert Advisor will be tested.
    3. Model – type of data modeling used for testing the Expert Advisor. It’s very important to understand each method of modeling and their impact to testing results. All three methods of modeling will be described later.
    4. Use data – allows to choose time period for which the Expert will be used.
    5. Visual mode – allows to check on chart how the Expert Advisor behaves during previously set period of time.
    6. Period – allows to choose on which chart period the Expert Advisor will be ran
    7. Expert properties – this button opens the window where various parameters can be changed. This window will be described later.
    8. Symbol properties – this button shows window with current properties of chosen symbol.
    9. Start – this button starts the testing

    Demo account testing

    Testing on demo account is just running the Expert Advisor on account with virtual money. The Expert Advisor have to be left working for some time. There is no difference between real account testing and demo testing in the functional matters. The only difference is that there is no risk for real money. If something is going wrong, just turn off Expert Advisor and check the Journal Tab in Terminal subwindow:


    Any error which were caused by Expert Advisor will be noticed here.

    Real account testing

    Testing on real account needs far more caution than Backtesting or demo account testing. The reason is obvious – real money is involved. Of course, after backtesting and demo account testing we can be almost one hundred percent sure, that the Expert Advisor is working fine. However, the responsible investor should check on their own if Expert Advisor is not doing what he doesn’t suppose to do on real account.
    The procedure is simple: run Expert Advisor and watch if all moves done by Expert Advisor are done right. If something is going wrong, do the same as for demo account testing procedure.

    Testing Scripts

    How to test script is doing what it should do? The rule of the thumb for scripts says: if the script works as it should and ends in less than minute, then we could assume that is working fine. Of course, first test of the script should be made on demo account. This is especially very important for the scripts which operate on orders.

    visa mer visa mindre