Menu

Ne dolgozz forexpros

4 Comments

Trading-Signale Diese leicht zu forexpros Trading-Empfehlungen sagen Ihnen, wann Sie kaufen, wann verkaufen und wo Sie Ihre Stopps und Grenzen gesetzt. Die Signale werden in Echtzeit, 24 Stunden am Tag, 5 Tage die Woche generiert und aktualisiert. Und sehen Sie signifikante Candlestick-Muster auf Diagrammen. Spekulative Sentiment-Index Dieses leistungsstarke Tool zeigt die Stimmung des breiteren Devisenmarktes d. On-Demand Video Kurse Lernen Sie Forex zu erlernen oder entdecken Sie neue Strategien und Trading-Tipps aus diesen Video-Kursen. Live Classroom Erlernen Sie, Forex von den DailyFX Kurslehrern zu handeln. Join Live-Trading-Sitzungen, Montag bis Freitag, um einfache und erweiterte Forex-Konzepte und Strategien zu lernen. Real, aktuelle Handelsbeispiele werden verwendet, um ihre Wirksamkeit zu maximieren. Forex Artikel Donnerstag, Im Jahrda die Deregulierung der Forex-Handelsbranche, gab es eine riesige Verbreitung von Internet-basierten Spot Forex. Das AvaTrade Unternehmen, das zuvor als AvaForex oder AvaFX Broker, Estd. November um Oktober um Der HYCM Forex Broker ist der Handelsname der Henyep Capital Markets Ltd. Hong Kong Hong Kong SFC Regulierung News 28 DezHongkong - Blackwell Global Pressemitteilung - Hongkong-China Stock Verbinden Sie einen Boost auf die Multi-Asset-Brokerage. Vertreter aus der Finanzdienstleistungsbranche. Saudi Money Expo mit der Best Institutional FX-Plattform ausgezeichnet. Bitte lesen Sie unsere rechtlichen Hinweise. Kopie OptiLab Partners AB. Die hier angegebenen Rohstreuungen dienen nur als Referenz. USDOLLAR wird nicht mit der neuen Provisionsstruktur angeboten und wird weiterhin mit Aufschlag angeboten. Leverage kann gegen Sie arbeiten. Suchen Sie Beratung von einem separaten Finanzberater. Kanto Local Finance Bureau Finanzinstrumente-Unternehmen No. Account Management Plattform Handel dijalankan di MS Windows OS. Klien InstaForex bisa mendownload plattform InstaForex MobileTrader kostenlos runterladen. Setelah aplikasi terinstal, und ein memperoleh akses langsung ke pengelolaan akun. Unda bisa Handel mata ueinn, CFD peinl logeinm, komoditeinls, seeinm, dan menganeinlleis dan mereinrzun grafik. Aplikasi ini Mitgliedschaft fasilitas Handel yang dikembangkan. Setelah menginstalnya, unda bisa menutup transaksi, menganalisa kutipan, dan menguji strategi Handel. Dalam kisaran Yang mudah dijangkau Dari instrumen standar Yang Lengkap untuk kenyamanan kerja ada dalam genggaman undeinem. Handel tidak pernah semudah als sefleksibel ini. Herunterladen versi terbaru dari InstaForex MobileTrader dengan gratis. Nikmati handelnden yang nyaman dengan antarmuka yang rama pengguna dan software dari versi seluler. Platform InstaForex Mobile kesempatan besar untuk mencapai tujuan Multiterminal tidak mendukung dengan Mac OS Dengan Multiterminal undeinem dapat bekerja dengan beberapa akun Handel di InstaForex di saat Yang Sama, dengan mengelolanya dalam satu Terminal. Handelsstrategie Was unsere EA tun wird: Dies wird als Handelsstrategie bezeichnet. Wir werden auch einen anderen Indikator namens Average Directional Movement ADX mit der Periode 8 verwenden, um auch zu bestimmen, ob sich der Markt tendiert oder nicht. Wir haben nun unsere Strategie entwickelt, jetzt ist es an der Zeit, unseren Code zu schreiben. Schreiben eines Expertenberaters Beginnen Sie mit dem Starten des MetaQuotes Language Editor 5. In diesem Fall habe ich MyFirstEA eingegeben. Sobald Sie fertig sind, sollte es so aussehen: Der char-Typ kann sowohl positive als auch negative Werte enthalten. Der Wertebereich reicht von bis Der minimale Wert ist null, der maximale Wert Der Typ unsigned short ist der Typ ushort. Der minimale Wert ist 0, der maximale Wert ist 65 Der minimale Wert ist -2der maximale Wert ist 2 Der unsignierte Integer-Typ ist forexpros. Der minimale Wert ist -9der maximale Wert ist 9 Der obere Teil Header des Codes ist, wo die Eigenschaft der EA definiert ist. Es wird in der Form define identifier tokenstring geschrieben. Dies bedeutet, dass jedes Vorkommen von Bezeichner in Ihrem Code durch den Wert tokenstring ersetzt wird. Lassen Sie uns jetzt mit unserer Diskussion weiter. Der zweite Teil des Headers unseres Codes ist der Eingabeparameterabschnitt: Wir geben alle Parameter an, die in unserem EA in diesem Abschnitt verwendet werden. Dieser Abschnitt ist der beste Ort, um einige wichtige Kontrollen zu machen, um sicherzustellen, dass unsere EA funktioniert sehr gut. Diese Funktion verarbeitet das NewTick-Ereignis. Autotrading ist aktiviert Die meisten unserer Codes, die unsere bisherige Strategie implementieren, werden in diesem Abschnitt beschrieben. Dies ist ein einzeiliger Kommentar Dies ist ein mehrzeiliger Kommentar Dies ist ein mehrzeiliger Kommentar. Mehrzeilige Kommentare beginnen mit dem Paar von Symbolen und enden mit dem einen. Der Compiler ignoriert alle Kommentare beim Kompilieren des Codes. Bei den EA-Input-Eigenschaften sehen unsere Benutzer den Parameter selbst nicht, stattdessen sehen sie die Kommentare wie unten gezeigt: Der minimale ADX-Wert AdxMin wird als doppelter Datentyp deklariert. Ein Doppel wird verwendet, um Gleitkommakonstanten zu speichern, die einen ganzzahligen Teil, einen Dezimalpunkt und einen Bruchteil enthalten. Dann haben wir andere Parameter, die wir verwenden werden, deklariert: By the way, was sind dynamische Arrays Ein dynamisches Array ist ein Array ohne Dimension deklariert. Mit anderen Worten, in dem Paar eckiger Klammern wird kein Wert angegeben. Ein statisches Array, auf der anderen Seite hat seine Dimensionen am Deklarationspunkt definiert. STP und TKP werden verwendet, um die Stop Loss und die Take Profit Werte in unserem EA zu speichern. Der ADX-Indikatorhandgriff wird mit der iADX-Funktion erhalten. Es hat die folgenden Argumente: Wir verwenden die Alert-Funktion, um den Fehler mit der GetlastError-Funktion anzuzeigen. Also hier wollen wir sicherstellen, dass unsere EA funktioniert sehr gut mit allen Brokern. Ziffern oder Ziffern r stellt die Anzahl der Dezimalstellen fest, die die Genauigkeit des Preises des aktuellen Kartensymbols bestimmen. Wir verwenden die Funktion IndicatorReleaseum dies zu erreichen. Es dauert nur ein Argument das Indikator-Handle bool IndicatorRelease int Indikatorhandle. Indikatorhandle Die Funktion entfernt einen Indikatorgriff und gibt den Berechnungsblock des Indikators frei, falls dieser nicht verwendet wurde. Es gibt zwei Parameter, das Symbol erhalten Sie mit Symbol oder Symbol. Die Alert-Funktion zeigt eine Meldung in einem separaten Fenster an. Es werden alle Werte durch Kommas als Parameterargumente getrennt. In diesem Fall haben wir nur einen String-Wert. Wir beginnen mit der Deklaration einer statischen datetime Variable OldTime. Die die Bar-Zeit speichern wird. Wir haben auch eine Bool-Datentyp-Variable IsNewBar deklariert und ihren Wert auf false gesetzt. Dies ist, weil wir wollen, dass ihr Wert nur dann wahr ist, wenn wir eine neue Leiste haben. Wir verwenden die CopyTime-Funktion, um die Zeit des aktuellen Balkens zu erhalten. Es kopiert die Balkenzeit zum Array NewTime mit einem Element, wenn es erfolgreich ist, vergleichen wir die Zeit einer neuen Balken mit der vorherigen Balkenzeit. Wenn die Zeit arent gleich ist, bedeutet dies, dass wir eine neue Leiste haben, und wir setzen die Variable IsNewBar auf TRUE und speichern den Wert der aktuellen Barzeit auf die Variable OldTime. Die Variable IsNewBar zeigt an, dass wir eine neue Leiste haben. Warum wiederholen Sie es Wir wollen nur sicher sein, dass unsere EA richtig funktioniert. Innerhalb der OnTick-Funktion deklariert. Nehmen wir die Strukturen nacheinander. Hier haben wir MQ als MqlTradeRequest-Typ deklariert. Jede Variable, die als MqlTradeResult-Typ deklariert ist, kann auf die Ergebnisse der Handelsanforderungen zugreifen. Damit wird sichergestellt, dass die Werte, die in die Arrays kopiert werden, wie die Zeitreihen indexiert werden, dh, 0, 1, 2, 3 entsprechend dem Balkenindexso dass wir die ArraySetAsSeries - Funktion verwenden ArraySetAsSeries void-Array-Array nach Referenz-Bool-Set true bedeutet umgekehrte Reihenfolge der Indizierung Es sei darauf hingewiesen, dass dies auch einmal in der Initialisierung Abschnitt unseres Codes getan werden kann. Wenn es einen Fehler gibt, berichteten wir es. Die Copyounts-Funktion wird verwendet, um die History-Daten der MqlRates-Struktur einer bestimmten Symbol-Periode in einer bestimmten Menge in ein Array des MqlRates-Typs zu erhalten. Wird der aktuelle Periodenzeitraum unter Verwendung einer Periode erhalten. Das Ergebnis wird gespeichert werden in unserem Array, mrate. Damit wir die Details der Balken erhalten, verwenden wir folgendes: Int CopyBuffer int Indikatorhandle, Indikatorgrenze int buffernum, Indikatorpufferzahl int startpos, Startposition int count, Betrag zum Kopieren des Doppelpufferzielfeldes zum Kopieren Das Indikatorhandle ist das Handle, das wir im OnInit-Bereich erstellt haben. Bei Puffernummern hat der ADX-Indikator drei 3 Puffer: Der Moving Average-Indikator hat nur einen 1 Puffer: Wir kopieren aus dem aktuellen Balken 0 in die letzten zwei Balken. Wenn es Fehler, keine Notwendigkeit, weiter zu gehen. Wir verwenden die Handelsfunktion PositionSelect, um zu wissen, ob wir eine offene Position haben. Dazu verwenden wir die Funktion "PositionGetInteger". Wenn es ein Verkauf ist, speichern wir einen WAHREN Wert in Sellopened und wenn es ein Kauf ist, speichern wir einen WAHREN Wert in Buyopened. Es ist nun Zeit, nach einer Kaufgelegenheit zu suchen. Eine Variable vom Typ bool kann nur TRUE oder FALSE enthalten. So wurde unsere Kaufstrategie in vier Konditionen aufgeteilt. Betrachten wir sie nacheinander. Hier sehen wir die MA-8 Werte auf Balken 0, 1 und 2. Es bedeutet, dass MA-8 dolgozz oben zunimmt. Das Symbol ist das aktuelle Symbol Symbol oder Symbol. Die Funktion OrderSend verwendet zwei Argumente, die Variable MqlTradeRequest und die Variable MqlTradeResult. Wenn wir irgendwelche von ihnen haben, sind wir sicher, dass unsere Bestellung abgeschlossen wurde oder es wurde platziert. So wurde unsere Verkaufstrategie in vier Bedingungen unterteilt. Sehen wir uns die einzelnen MAWerte an den Bars 0, 1 und 2 an. Wenn der Wert von MA-8 auf dem aktuellen Balken kleiner ist als sein Wert auf dem vorherigen Balken 1 und auch der MA-8 Wert auf Balken 1 kleiner als sein Wert auf Balken 2 ist. Bedeutet dies, dass MA-8 nach unten abnimmt. This expression is checking to see if Bar 1 Close price is lower than the value of MA-8 at the same period Bar 1 period. If the price is lower, then our second condition has also been satisfied, then we can check for other conditions. However, if the two conditions we have just considered were not met, then there will be no need to check other conditions. That is why we decide to include the next expressions within these two initial conditions expressions. Now we want to check if the current value of ADX ADX value on Bar 0 is greater than the Minimum ADX value declared in the input parameters. If this expression is true, that is, the current value of ADX is greater than the Minimum required value we also want to be sure that the MinusDI value is greater than the plusDI value. This is what we achieved in the next expression If these conditions are met, that is, if they return true, then we want to be sure that we do not open a new Buy position if we already have one. It is now time to check the value of the Buyopened variable we declared earlier in our code. If Sellopened is true, we do not want to open another Sell position, so, we display an alert to inform us and then return so that our EA will now wait for the next Tick. However, if Sellopened is FALSE, then we setup our Sell trade request as we did for Buying order. The major difference here is the way we calculated our stop loss price and take profit price. Also since we are selling, we sell at the Bid price that is why we used our MqlTick type variable latestprice to get the latest bid price. Also here, we used the NormalizeDouble function for the Bid price, the StopLoss and TakeProfit values, it is good practice to always normalize these prices to the number of digits of currency pair before sending it to the trade server. Just as we did for our Buy order, we must also check if our Sell order is successful or not. So we used the same expression as in our Buy order. Debugging and Testing our Expert Advisor At this point, we need to test our EA to know it our strategy works or not. Also, it is possible that there are one or two errors in our EA code. This will be discovered in the next step. Debugging our code helps us to see how our code performs line by line if we set breakpoints and there and then we can notice any error or bug in our code and quickly make the necessary corrections before using our code in real trade. Here, we are going to go through the step by step process forexpros debugging our Expert Advisor, first of all, by setting breakpoints and secondly, without breakpoints. To do this, Make sure you have not closed the Editor. First of all, let us select the chart we want to use to test our EA. On the Editor Menu bar, click on Tools and click on Options as shown below: Setting Debugging options Once the Options window appears, select the currency pair, and the periodtimeframe to use and click the OK button: Before we start the debugger, let us set breakpoints. Breakpoints allow us to monitor the behaviorperformance of our code at certain selected locations or lines. Rather than running through all the code at once, the debugger will stop whenever it see a breakpoint, waiting for your net action. By this we will be able to analyze our code and monitor its behavior as it reaches every set break-points. We will also be able to evaluate the values of some of our variables to see if things are actually the way we envisaged. To insert a breakpoint, go to the line in your code where you want to set the breakpoint. By the left hand side, on the gray field near the border of the code line, double-click and you will see a small round blue button with a white square inside it. Or on the alternative, place the cursor of your mouse anywhere on the code line where you want the breakpoint to appear and press F9. To remove the breakpoint, press F9 again or double-click on it. Setting a breakpoint For our code, we are going to set breakpoint on five different lines. I will also label them form 1 to 5 for the sake of explanation. To continue, set breakpoint at the seven code lines as shown in the figure below. Breakpoint 1 is the one we have created above. Setting additional breakpoints Once we have finished setting our breakpoints, we are now set to start debugging our code. To start the debugger, press F5 or click the green button on the Toolbar of the MetaEditor: Starting the Debugger The first thing the editor does is to compile the code, if there is any error at the point, it will display it and if no error, it will let you know that the code compiled successfully. Compilation Report Please note that the fact that the code compiled successfully does not mean there may not be errors in your code. Depending on how your code is written, there may be runtime errors. For example, if any of our expressions does not evaluate correctly due to any little oversight, the code will compile correctly but may not run correctly. Too much of the talk, lets see it in action Once the debugger has finished compiling the code, it takes you to the trading terminal, and attach the EA to the chart you have specified on the MetaEditor Options settings. At the same time, it shows you the Input parameters section of the EA. Since we are not adjusting anything yet, just click the OK button. Expert Advisor Input Parameters for Debugging You will now see the EA clearly on the top-right hand corner of the chart. Once it starts the OnTick. Debugger stops at the first breakpoint You will notice a green arrow at that code line. That tells you that previous code line had been executed we are now ready to execute the present line. Let me make some explanations before we proceed. If you look at the Editors Tool Bar, you will observe that the three buttons with curved arrows which were earlier grayed out are now activated. This is because we are now running the debugger. These buttonscommands are used to step through our code Step into, Step over or Step out Figure Step into command The Step Into is used to go from one step of the program execution into the next step, entering into any called functions within that code line. Click on the button or press F11 to invoke the command. We will use this command in our Step-by-Step debugging of our code. Step over command The Step over. Click on the button or press F10 to invoke the command Figure Step out command To execute a program step that is one level higher, you click this button or press ShiftF Also, at the lower part of the Editor, you will see the Toolbox window. The Debug tab in this window has the following headings: This displays the name of the file been called Function: This displays the present function from the file been called Line: This displays the number of the code line in the file from which the function is called. This is where you can type the name of any expressionvariable you are interested in monitoring from our code. This will display the value of the expressionvariable we typed at the Expression area. This will display the data type of the expressionvariable been monitored. Back to our debugging process The next thing we want to do is now to type in the variablesexpressions from our code that we are interested in monitoring. Make sure you only monitor the variablesexpressions that really matters in your code. For our example, we will monitor the following: OldTime old bar time NewTime0 current bar time IsNewBar flag that indicates the new bar Mybars Total bars in History Our EA depends on it You can add other ones like the ADX values, the MA-8 values, etc. To add the expressionvariable, double-click under the Expressions area or right-click under the Expressions area and select Add as shown in the figure above. Type the expressionvariable to monitor or watch. The expressions watching window Type all the necessary variablesexpressions Figure Adding expressions or variables to watch If the variable hasnt been declared yet, its type is Unknown identifier except the static variables. Now, lets move on Figure Step into command in action Click the Step into button or press F11 and observe what happens. Keep on pressing this button or F11 until you get to breakpoint no 2. Watching the expressions or variables Figure Watching the expressions or variables Once there is a new tick, it will return to the fist code line of the OnTick function. And all the values of our variablesexpression will now be reset because this is a new tick except if any of them is declared as a static variable. In our case we have one static variable OldTime. Values of variables on NewTick forexpros To go over the process again, continue pressing the F11 key and keep monitoring the variables at the expressions watching window. You can stop the debugger and then remove all the breakpoints. As we see, in Debug mode it prints the message We have new bar here. Expert Advisor prints the message in Debug mode Start the debugging process again but this time without breakpoints. Keep watching at every tick and if any of our BuySell condition is met, it will place a trade and since we have written our code to tell us if an order is placed successful or otherwise, we will see an alert. Expert Advisor places trade during debugging I think you can leave the EA to work for a few more minutes while you take a coffee. Once you are back and you have made some money just kiddingthen click the STOP Red button on the MetaEditor to stop debugging. Stopping the debugger What we have actually done here is to see that our EA only checks for a trade at the opening of a new Bar and that our EA actually works. There is still a lot of room for adjustments to our EA code. Let me make it clear, at this point that, the Trading terminal must be connected to the internet, otherwise, debugging will not work because the terminal will not be able to trade. To start the Strategy Tester, press CONTROLR or click the View menu on the Terminal Menu Bar and click on Strategy Tester as shown below Figure Starting the Strategy Testing The Tester Strategy Tester is shown at the lower part of the terminal. For you to see all the Testers settings, you need to expandresize it. To do this, move your mouse pointer to the point shown by the red arrow as shown below Figure The Strategy Tester window The mouse pointer changes to a double-end arrow, hold down the mouse and drag the line upwards. Stop when you discover that you can see everything on the settings tab. The Strategy Tester Settings Tab Select the EA you want to test Select the Currency pair to use for the test Select the PeriodTimeframe to use for the test Select Custom Period and set the dates in 5 Set the dates for the custom period to be used for the test Execution is Normal Select the deposit amount in USD to be used for the test Set Optimization to Disable We are not optimizing now, we just want to test Click this button when you are ready to start test. Before we click the Start button, lets look at the other tabs on the Tester The processor used by the Tester for the Test. Depending on your Computers processor type. Mine is only one 1 core processor. The Strategy Tester Agents tab Once the agent, you will see something similar to the figure below Figure The Strategy Tester Agents tab during a test This is where all the events going on during the test period is displayed Figure The Strategy Tester Journal tab showing trade activities This is where you can specify the input dolgozz for the EA. The Strategy Tester Inputs tab If we are optimizing our EA, then we will need to set the values in the circled area. The Start is the values you want the Tester to begin with. The Step is the increment rate for the value you selected, and The Stop is the value at which the Tester will stop incrementing the forexpros for that parameter. However, in our case we are not optimizing our EA, so we will not need to touch that for now. Once everything is set, we now go back to dolgozz Settings tab and click the Start button. Then the tester begins its work. All you need to do now is to go and take another cup of coffee if you like, or, if you are like me, you may want to monitor every event, then turn to the Journal tab. Once you begin to see messages about orders been sent on the Journal Tab, you may then wish to turn to a NEW tab named Graph which has just been created. Once you switch to the Graph tab, you will see the graph keep on increasing or decreasing as the case may be depending on the outcome of your trades. The graph result for the Expert Advisor Test Once the test is completed, you will see another tab called Results. Switch to the Results tab and you will see the summary of the test we have just carried out. The Strategy Tester Results tab showing test results summary You can see the total Gross Profit, Net Profit, total trades total loss trades and many more. Its really interesting to see that we have about USD 1, At least we have some profit. Let me make something very clear to you here. You will discover that the settings for the EA parameters that you see in the Strategy tester is different from the initial settings in the Input parameters of the EA. I have just demonstrated to you that you can change any of those input parameters to get the best out of your EA. Instead of using a period of 8 each for the Moving Average and ADX, I changed it to 10 for Moving Average and 14 for ADX. I also change the Stop Loss from 30 to Last but not the least, I decided to use 2 Hour timeframe. Remember, this is the Strategy Tester. If you want to view a complete report of the test, then right-click on anywhere in the Results tab, you will see a menu. From this menu, Select Save as Report. Saving the result of the test The save dialog window will appear, type a name for your report if you want, otherwise leave the default name and click the save button. The whole report will be saved in HTML format for you. To view the chart for the test that was carried out, click Open Chart and you will see the chart displayed Figure The chart showing the test Thats it, we have successfully written and tested our EA and we now have a result to work with. You can now go back to the strategy tester Settings tab and make the test for other TimeframesPeriod. I want you to carry out the test using different currency pairs, different timeframes, different Stop Loss, different Take profit and see how the EA performs. You can even try new Moving Average and ADX values. As I said earlier, that is the essence of the Strategy tester. I will also like you to share your results with me. Conclusion In this step by step guide, we have been able to look at the basic steps required in writing a simple Expert Advisor based on a developed trading strategy. We have also looked at how we check our EA for errors using the debugger. We also discussed how to test the performance of our EA using the Strategy Tester. With this, we have been able to see the power and robustness of the new MQL5 language. Our EA is not yet perfect or complete as many more adjustments must still be made in order to used it for real trading. There is still more to learn and I want you to read the article over again together with the MQL5 manual, and try everything you have learn in this article, I can assure you that you will be a great EA developer in no distant future. Advanced Guide To MetaTrader 4 - Expert Advisors Expert Advisor Creation Expert Advisors are programs that allow automation of the analytical and trading processes in the MT4 platform. To create an Expert Advisor or Expertthe expert editing program - MetaEditor - has to be opened from within the MT4 platform. To open the editor see Figure 1: The Wizard can be used to create Expert Advisors, Custom Indicators, Scripts and DLLs. To create an Expert Advisor, select Expert Advisor and click Next to continue, as shown in Figure 2. Here, traders must specify the: Name - A user-created name for the Expert. Developer - The developers name. Link - To the developers website, if applicable. Inputs - the list of Expert inputs 13 13To add a new parameter to the Inputs field, press the Add button. For each Parameter, the trader must specify the Name, Type and Initial Value, as shown in Figure 3. To delete a parameter, highlight the parameter and press Delete. These become the Input Variables within the Expert. Once all the inputs have been listed, click Finish to continue. The Experts name appears at the top of the window, and the previously entered input parameters are listed near the top of the code, as shown in Figure 4. Specifics regarding programming are outside the scope of this tutorial understanding programming logic and learning a specific language require significant effort. Traders can learn more about programming in the MQL4 environment by reading the MT4 Help Guides and participating in the active MQL4 community forums. MQL4, like other proprietary languages, has a list of Reserved Words and Standard Constants that are used during programming. Examples of constants for trade operations, along with their descriptions, include: Certain words have predefined uses here, OPSELL instructs the computer to sell if other criteria are met if statements. Traders can find a MQL4 Reference in the Help tab of the Toolbox in the MetaEditor window. This Reference includes information that is helpful to beginner and experienced programmers including: Expert Advisor Compiling After the Expert development has been completed, it must be compiled in order to ensure that the code has been written in the proper format needed to run the Expert. To compile the Expert: Select File gt Compile see Figure 6 or Click the Compile button on the toolbar or Press F5 on the computer keyboard. An errors or warnings will be listed. If the Expert did not compile successfully, it will still appear but its icon will be gray and the Expert cannot be used. Expert Advisor Setup Before the Expert can be used, its parameters must be defined in the Terminal Settings window. To open the window: Either action will open the Options window. Select the Expert Advisors tab, as shown in Figure 8. Enable Expert Advisors - this option allows the user to enable check or disable uncheck the use of all Experts. Disable experts when the account has been changed - this option disables the Expert if the account has been changes, such as from a demo to a live account. Disable experts when the profile has been changed - this option prevents Experts from launching if the profile has changed. Allow live trading - to enable Experts in real-time mode rather than testing an Expert on historical data. Ask manual confirmation - to send trade confirmation prior to submitting the order. Allow DLL imports - to use DLLs to enhance Expert functionality. Confirm DLL function calls - to allow control over the execution of each called function. Allow external experts imports - to allow the Expert to access functions from other Experts or MQL4 libraries. Expert Advisor Launch 13 After the Expert has been created and setup, it is ready to be launched. To launch an Expert: Review the settings in each tab and make any necessary changes, and then click OK to attach the Expert to the active price chart. Its name will appear in the upper right-hand corner of the chart. The Experts name will be followed by a smiley face, as shown in Figure 10, if live trading is enabled. Otherwise, the Experts name will appear with a frowny face, a dagger after the name indicates that all experts are disabled. Expert Advisor Shutdown To shut down an Expert, it has to be removed from the chart. To remove an Expert, right-click on the active price chart, select Expert Advisors and then Remove, as shown in Figure Notes About Expert Advisors All Experts are shutdown if the Terminal is closed. If a chart is closed, the Expert attached to the chart will shut down as well. Adding another Expert to a chart will remove the previous one a confirmation appears. Deleting the Expert from the Navigator window does not shut down an Expert of the same name on an active price chart. Trading Systems Coding Advanced Guide To MetaTrader 4 - Custom IndicatorsMetaTrader 5 - Examples Writing an Expert Advisor Using the MQL5 Object-Oriented Programming Approach Introduction In the first article. Everything we did was very simple and interesting however, the new MQL5 language has much more to offer. In this article, we will consider the Object Oriented approach to doing what we did in the first article. Most people think this is difficult, but I want to assure you that by the time you finish reading through this article, you will be able to write your own Expert Advisor which is object oriented based. We will not repeat some of the things we have learned in the first article. The Object-Oriented Paradigm One of the things that make the new MQL5 much more powerful and robust than MQL4 is its OOP Object Oriented Programming approach. It is recommended in OOP that an object should not expose any of its implementation details. This way, its implementation can be changed without changing the code that uses the object. This means that a class allows a programmer to hide and also prevents changes to how the class he has written is implemented. To get things clearer, let us dwell a bit on the terms class and object just mentioned. A class is more like an expanded concept of a data structure but instead of holding data only, it holds both data and functions. A class can contain several variables and functions, which are called the members of the class. It is an encapsulation of data members and functions that manipulate the data. A class is much more powerful, in that you can wrap up all your Expert Advisors functions in a class. You will only be making reference to the functions anytime you need them in your EA code. By the way, this is what this article is all about. An object is an instance of a class. Once a class has been created, to use the class, we must declare an instance of the class. This is called an object. In other words, to create an object you need a class. DECLARING A CLASS A class, basically. Let us look at an example If we want to create an object that will have doors, sits, tyres, weight. The doors, sits, tyres, weight, start, changegear, stop and horn will be the members of the class. Of course, you will observe that, these members are categorized some are just what our object will have properties while the others are what our object will do actions functionsmethods. To declare our class, we need to think of a very good and descriptive name for it. In this case, we will call our class CAR. Our CAR class will have the properties and functions stated above as its members. To declare a class, we start by typing the keyword class followed by the name of the class followed by a pair of braces that contains the members of the class. So, the basic format of a class is as shown below: Here, classname is a valid identifier for the class we want to write, members1 and members2 are the data members of the class. The accesskeyword specifies the access right to the members of our class. An accesskeyword can be private. Remember that we are trying to write a class that can be used by ourselves and others without actually exposing the implementation details. That is why access rights are necessary. There may be some members of our class we dont want access to from outside of our class. These are declared within the private access section using the private or protected keyword. Other members that we want access to from outside of our class will then be declared within the public access section using the public keyword. Now, our new CAR class will now look like below: Our CAR class is declared using the keyword class. This class contains eighth members with four members having private access and four members having public access. The four members in the private section are data members. Three are of integer int data type and one a double data type. These members cannot be accessed by any other function that is declared outside of this class. The four members in the public section are function members. Two return bool data type and two return void type. These are the members that are accessible to any object of this class whenever it is created by anyone using our class. Once an object of our class is created, these members will be readily available for use. As you will rightly observed, the access keywords private, public, protected are always followed by a colon. The class declaration also ended with a semi-colon. The members are declared using their correct data type. It should be noted that once you declare a class, all members of the class are given private access rights unless it is explicitly specified as we did above. For example, in the class declaration below: All the four members declared above the public access keyword automatically have private access. For our class to be used, an object of the class must first of all be created. Now, let us create an object which is a type of our class. To do this we will use our class name followed by the name we want to give the object. Or we can create another object Honda or Toyota is now a type of a CAR and can now have access to all the member functions of our CAR class provided the member functions are declared within the public access section. We will come back to this later. You can see that we can create as many objects of this class as we want. This is one of the benefits of Object Oriented programming. At this point, let us consider in details, the format of a class in MQL5. This is a declaration of a class where classname is the name of the class. This class has nine members, but out of this nine, two are special members. The constructor represented as classname is a special function that is called automatically when a new object of the type of the class is created. So in this case, when you create an object of the type of this class the constructor, classname. The name of the constructor must match the name of the class, that is why we named the constructor as classname. In MQL5, a constructor does not take any input parameters and has no return type. Memory allocations and initialization of the class members are normally done when the constructor is called. Constructors cannot be called explicitly as if they were regular member functions. They are only executed when a new object of that class is created. A class in MQL5 can only have one constructor. The second special member is represented as classname. This is the class destructor written with a tide before the class name. It is called automatically when a class object is destroyed. All members of the class that needs to be de-initialized are de-initialized dolgozz this stage and it does not really matter whether you explicitly declared the destructor or not. Members of a class can be any legal data type, the class type or the struct type. In other words, when declaring member variables of a class, you can use any legal data type int, double, string, etcan object of another class or a type of a structure for example, the MQL5 MqlTradeRequest, etc Function Members: These are members of the class which are used for modifying the data members and executing the major functions methods of the class. The return type for the function members can be of any legal return type bool, void, double, string, etc. Members declared within this section are only accessible by the function members of the class. They cannot be accessed by any other function outside of the class. Members declared within this section are accessible to the function members of the class and also can be accessed by the member functions of other classes that are derived from this class. This means that we can also create a new class from this class. In this case, the new class derived from this class which will now become the base class will be able to access the protected members of the base class. This is the concept of inheritance in OOP. We will soon discuss it, just relax Public: Members declared within this section are available for usage outside of the class by an object of the class. This is where to declare some of the functions that will be needed to use the class in other programs. Now that we have looked at the basic format of a class, I hope you are not bored yet because we still have some other interesting aspect of classes we need to look at before we finally jump into creating a class wrapper for our Expert Advisor. Lets say we want to make another class from this initial class baseclass. The format for deriving a new class from an initial class is as follows: A few explanations here before we proceed to explain the details. The class newclass is derived from the class baseclass using the colon and an accesskeyword as shown above. Now, the newclass derivedmade from baseclass can access or inherit both the public and protected members of baseclass but cannot access or not inherit the private members of the baseclass. The newclass can also implement new member methodsfunctions different from the baseclass. In other words, the newclass can also have its own data and function members apart from the ones it inherits from the baseclass. If the public keyword is used in creating the derived class, it means that the public and protected members of the base class will be inherited as public and protected members of the derived class. If the Protected keyword is used, public and protected members of base class will be inherited as protected members of the derived class. If the private keyword is used, the public and protected members of base class will be inherited as private members of the derived class. It is important to note that when a new object of the newclas s the derived class is created, the constructor of the baseclass is called first before the constructor of the newclass while when the object is destroyed, the destructor of the newclass the derived class is called first before the destructor of the baseclass. To better understand this concept of inheritance, let us go back to our initial class CAR. We can derive another class SALOON from this class. Notice that I have declared three of the data members of the class CAR as protected. This is to enable our new class SALOON inherit these members. Also, I want you to understand that the order in which you place the access keywords does not matter. What matters is that all members declared under an access keyword belong to that keyword. Our derived class SALOON has forexpros members and at the same time inherits seven members protected and public members from the base class CAR. This means that once an object of SALOON is created, it will be able to access the public member functions of CAR which are start. This is the concept of inheritance. Just as some charactersbehaviours methods of our fatherparents base class show up in us, their children derived classbecause we inherit those behaviours methodsfunctions from them either genetically or otherwise. Sorry, I am not a medical personnel, but I believe you quite grasp the picture I am trying to paint. By the way, MQL5 does not support multiple inheritance, so no need to talk about it. I hope the black cloth covering the mystical thing called OOP or CLASS is being removed little by liitle dont get tired, if you feel at this point you are still not very clear with what we are discussing, you may need to relax, take a cup of coffee and then come back and start from the beginning. It is not as mysterious as you think If you are now back at this point, I assume you are following my explanation. I want you to tell me how many more classes you can derive from our base class CAR Please I need you answer. Name them and write their declarations and mail them to me. If you can name them all, I will take you out for launch am I kidding Now that you are set for more, lets continue It is true that when I write, I write like my Dad. His hand writings are very neat and highly stylish just like mine. I guess it is something I inherit from him, but guess what he uses his left hand to write while I use my right hand and when you see the writings you can hardly differentiate because they look similar. What is the problem here I inherit good hand-writing from my father but I do not write with my left hand like my father. This means that even though its what I inherit and it looks similar but the way I do mine is different from my father. Does this make sense to you This is an idea of what is called Polymorphism in OOP. A derived class myself, as in the example above inherits a member function writefine for my handwritng from a base class my Dad but it I implements the function writefine in a different way from the base class My Dad. Back to our CAR class, and the derived class SALOON Let us look at a few changes we have made here. First, we have declared a new derived class from CAR named WAGON with two members. We have also modified the member function changegear to become a virtual function in the base class. Why did we make changegear a virtual function. It is simply because we want any class that inherits the function from the base class to be able to implement it in its own way. In other words, virtual member functions of a class are member functions that can be overridden or implemented differently in any class derived from the class where they are declared. The member function body can then be replaced with a new set of implementation in the derived class. Even though, we may not use the word virtual again in the derived classes, it is good programming practice to always use it in the derived classes. From the examples above, classes SALOON and WAGON implements the function changegear in their own ways. DEFINING CLASS METHODS MEMBER FUNCTIONS Since we have known, to some extent, how to declare classes lets move further by discussing how to define the member functions of a class. After we have declared the class, the next thing is to define the member functions of our class. Let us look at our CAR class again In defining the member functions, we have used a double colon:: This is written just like normal functions, the only difference is the class name and the scope operator that is added. You will also observe that one of the functions was already defined within the class member function horn. A member function can be defined in the class declaration or outside the class declaration as you have seen it here. I think it will be of importance if we can review the concept of functions a little before we proceed. By the way, what is a function Sometimes in a house where you have three kids, rather than just one of them doing all the works in the house one was asked to be washing the plates every day after supper, one was asked to be doing the sweeping while the third was given the task of arranging the beds every morning. There are some works to be done in the house, instead of giving all the works to one child, we divided it among the three of them. This will make the task very easy and light for each one of them rather than been a burden to just one of them. Also, if one of the kids did not do hisher task, we quickly know which one of them to flog. This is the idea behind functions. Most times we want to write a code that will do many tasks. This is where functions come in. We can decide to break the task into smaller tasks and then write a function to perform each of the smaller tasks. A function is a code-block that performs or implements a set of operations. It is a group of statements that is executed whenever it is called from some point in a program. A function can be defined as follows: If a function has more than one parameter, they are separated by commas. The function return type is integer intdoaddition is the function name and int x and int y are the parameters. What the function does is to add any two input parameters supplied it and return the result. So if we supply the function with two integer variables 2 and 3, the function will do the addition and return 5 as the result. For more information about functions, please consult the MQL5 Reference manual. Now enough of the theories let us get down to work. The essence of this article is to teach you how you can write a class for your Expert Advisor using the Object Oriented approach presented in MQL5. It is now time for action 2. Writing an Expert Advisor At this point, we will be making reference to the Expert Advisor we created in the first article. If you have not read the article, please go and do so now so that most of the things we shall be discussing from this point on will not be strange to you. However, I may still revise a few things that may be necessary. Before you can write your class, you need to sit down and develop your trading strategy first. We have already done this in the first article. The next thing is to select those functionalities we want to delegate to our class. These functionalities will determine the member variables of our class. Just a recap of our trading strategy from the first article. What our EA will do: It will monitor a particular indicator, and when a certain condition is met or certain conditions are metit will place a trade either a ShortSell or LongBuydepending on the present condition that has been met. The above is called a trading strategy. Before you can write an EA, you must first develop the strategy that you want to automate into the EA. So in this case, let us modify the above statement so that it reflects the strategy we want to develop into an EA. We will use an indicator called Moving Average with a period of 8 You can choose any period, but for the purpose of our strategy, we will use 8 We want our EA to place a Long Buy trade when the Moving Average-8 for the sake of our discussion, I will refer to it as MA-8 is increasing upwards and the price is close above it and it will place a Short Sell when MA-8 is decreasing downwards and the price is close below it. We are also going to use another indicator called Average Directional Movement ADX with period 8 also to help us determine whether the market is trending or not. We are doing this because we only want to enter the trade when the market is trending and relax when the market is ranging that is, not trending. To achieve this, we will only place our trade Buy or Sell when above conditions are met and the ADX value is greater than If ADX is greater than 22 but decreasing, or ADX is less than 22, we will not trade, even though the condition B has been met. We want to also protect ourselves by setting a Stop loss of 30 pips, and for our Profit target we will target a profit of pips. We also want our EA to look for BuySell opportunities only when a new bar has been formed and we will also make sure we open a Buy position if the Buy conditions are met and we do not already have one opened, and open a Sell position when the Sell conditions are met and we do not already have one opened. In addition, we want to make sure that we are able to control the percent of our Free Margin that can be used in placing a trade and also to ensure that we check available free margin before placing any trade. Our EA will only place a trade if available margin is enough for the trade. Now you understand what we want to do. The functions we want to delegate to our class are: Check for Buy and Sell conditions Place BuySell depending on the result of the conditions checked Basically, this is all we want our EA to do. These two functionalities are the major functions but there are still more. For example, in checking for BuySell positions, the indicators must be used. This means obtaining the values of the indicators must also be in our class. Get all the indicator handles at the EA OnInit section Get all indicator buffers at the EA OnTick section Release all indicator handles at the EA OnDeinit section In getting the indicator values, our class will need to know the MA and ADX periods, the chart period and symbol currency pair we are working withso we must also include: Get ADX and MA periods, and other important parameters like the chart period and symbol. Also for the checking of free margin before placing a trade, we will include Check Free Marginpercentage of account to use for trade With this we already have an idea of what variables and functions dolgozz be in our class. Okay, I have done the thinking for you it is time to write some code. Writing a class Let us begin by launching the MetaEditor I believe you already know this. Once the MetaEditor is opened, let us start a new MQL document by clicking the New toolbar or CtrlN. In the wizard window, select Include and click the NEXT button. Starting a new MQL5 document Type the name of the file as shown below and click finish: Naming a new document We selected include because our class is going to be an include file which will be included in our EA code once we are ready to use it. That is why you do not have room to enter input parameters. As usual, the editor provides you with a skeleton of what it thinks you want to do. To begin, please delete everything below the property link code line. You should now have something like this. Now let us write the declaration of our class, we shall call our class, MyExpert. Lets analyze the class declaration. The declaration starts with dolgozz name of the class. Next we declared the private members of the class. As explained earlier, these private member variables are not accessible by any function outside of the class. Most of the variables are very clear in their declarations so I wont waste time talking about them. However, you will remember in our discussion, that we stated that member variables can be any legal data type, structure or class. I believe you can see this in action here with the declaration of the MqlTradeRequest and MqlTradeResults types. The constructor does not take any input parameters please bear this in mind when writing your own class. The member functions We have defined these member functions to allow us set the important variables that will be needed by our class to perform its function. Without using these functions, these variables will not be available for our class to use. As you will also notice, we had already declare a corresponding variable in our class that will hold these values once they are set by these functions. Another thing to note is that we have defined these member functions within the class declaration. As I explained earlier, it is allowed. It means we wont need to define them again when defining other member functions as you will see very soon. Just like normal functions, they have parameters of the correct data type depending on the return values of each function. I believe this should not be strange to you. We only declare these member functions but we did not define them. This is because we will be doing that later. These are functions that will manipulate most of the values store in the member variables of our class and at the same time they form the functions for the major role of our class. We will discuss them later. The Protected members These members will be inherited by any class that is derived from our class. It is not really necessary if you dont intend to derive any other class from this class. You can as well place them as private members. I am only doing this to let you understand the various issues we have discussed earlier about classes. These three functions are also very important though internal to our class. The showError will display our errors and the getBuffers will be used to get indicator buffers. MarginOK check if there is enough free margin to open a position. Once you have finished with the declaration of the class, dont forget the semi-colon. It is very important. The next thing to do immediately after declaring the class is to define the member functions that have not been defined in the declaration section. This is our class constructor. Here we used the double colon:: What we are trying to say is this: Though we are defining this member function outside of the class declaration, but it is still in the scope of the class. It is a member of the class whose name comes before the two colons scope operator. It does not have any input parameters. It is at this point we initialize most of the necessary member variables and we use the ZeroMemory function to accomplish this. In this case we use it to reset the values of our structure types MqlTradeRequest and MqlTradeResult and our arrays. This is a protected member function which is used to display all errors encountered during the operations of any object of our class. It takes two argumentsparameters Error description and error code. This function is used to copy all our indicators buffers to the arrays we have specified in the member variables using the respective indicator handle. The CopyBuffer function was explained in the first article. The getBuffers function does not have any input parameters because we are using the values from the member variables of the class. We used our internal error function here to display any error that may occur in the process of copying the buffers. This function is actually doing two jobs. It checks to make sure that we have enough free margin to place the trade and also checks to make sure we dont use more than a specified percentage of the free margin available to place the trade. In this way we can control how much money we use for each trade. The AccountInfoInteger and AccountInfoDouble are account functions used to get the details of the current account using the EA. We also used the symbol properties functions SymbolInfoDouble and SymbolInfoString to get the contract size and base currency for the current symbol currency pair respectively. The results of these functions are stored in the declared variables for each data type. The calculation we have done here is very simple. To get the required margin for placing a trade, we consider two situations: The base currency is USD USDCAD, USDCHF, USDJPY, etc. Margin required Contract forexpros per lot Leverage 2. The base currency is not USD EURUSD, etc Margin required current price of symbol contract size per lotLeverage. We now decide to check if the margin required to trade the specified lot size or volume is greater than the percentage of free margin you want to use for a trade. If margin required is less the function returns TRUE and the trade is placed, otherwise, it return FALSE and the trade will not be placed. This is a public function we intend to use in the OnInit function of our EA which we will write soon and it is going to do two things. First, it will set the handles for our indicators and also perform the array-set-as-series action on the array variables. It has two input parameters which will be supplied from within our EA code. This function is also a public member function which will be used in the UnDeInit function of our EA to release all handles for the indicators we have used. This function will be used to check if a buy condition has been set or not. That is why its return type is bool. It means that it will return a TRUE or a FALSE. This is where we defined our Buy trade strategy. If a buy condition is met based on the strategy we have defined, it will return TRUE however, if the Buy condition is not met it will return FALSE. When using this function in our code, we will then place a buy if it returns TRUE. The first thing we have done here is to call the internal member function getBuffers. The conditions coded here had been explained in the first article. Just like the checkBuy. That is why its return type is also bool. This is where we defined our Sell trade strategy. If a sell condition is met based on the strategy we have defined, it will return TRUE however, if the sell condition is not met it will return FALSE. When using this function in our code, we will then place a sell if it returns TRUE. Just like in checkBuy. The conditions coded here had also been explained in the first article. This is the function that opens a buy position whenever it is called in our EA. It has, as input parameters, most of the variables that will be needed to place the trade and some of the variables will be provided by our EA code. You will notice, as explained in the first article. We will not need to use them in our EA code. Before a trade is placed, we want to confirm if the user wants to check margin, if the value of ChkMargin which will be obtained from the EA is 1, then we call the MarginOK function to do that for us. The result of this function determines the next step to take. However, if the user does not want to check margin, then we just continue and place the trade. Just like the openBuy function, this function opens a sell position whenever it is called in our EA. Just as we did when opening a Buy position, before a trade is placed, we want to confirm if the user wants to check margin, if the value of ChkMargin which will be obtained from the EA is 1, then we call the MarginOK function to do that for us. Now we have finished the declaration and definition of our class and the member functions, however, we have left out some other tasks which we intend to handle in our EA code. These include checking of available bars, checking of new bars and checking for available opened positions. They will be handled in our EA code. To see a list of the all the functions and methods of our class, click on the functions commandmenu on the MetaEditor as shown below. The function displays all the member functions including the Destructor which we did not explicitly declared in our code. The protected members are pointed by green arrows while the Constructor and destructor are pointed by blue arrows. Our class member functions showing the class destructor Did I hear you say, debug Maybe you are right. It is always good to test and see if your code has errors otherwise you will be disappointed when you release it to the public. The problem here is that this is just an include file, it is not an expert adviser code or script or indicator code which can be attached to the chart. At this point you have two options from my experience. OR Go ahead and write the code for the EA that will use your class. Once you start debugging the EA, the included file will be checked along with it. In fact, this is the best and most acceptable way to do it. WRITING THE EXPERT ADVISOR I guess your editor is still opened. Start a new document again but this time select Expert Advisor. Please see the first article for details. But this time, name your EA myoopea. This is where you should be now: Now we are ready to write our OOP based EA. The first thing we are going to do here is to include the class we have just written using the include preprocessor command. Include the class just immediately after the last preprocessor property command There are two ways of including a file, When we use the angle bracket lt. The current directory which is the Experts folder inside the MQL5 directory will not be considered as a possible place to look for the file. However, if the file is enclosed in quotation marks. If your class is saved in the Include folder standard directory and you use the quotation marks instead of angle brackets or vice versa, you will get an error when compiling the code. Lets discuss the new ones. We have introduced an integer variable to hold a value of 1 if we want to use margin check or 0 if we dont. We have also declared another variable to hold the maximum percentage of Free margin to be used in opening a position. These values will later be used in our class object when created. Immediately after the input parameters, we define other two parameters STP and TKP which we want to be able to manipulate to cater for 5 and 3 digit prices since we cannot change the values of the input variables. Then we create an object of our class for use within our EA code. As explained earlier, to create an object of a class, you use the class name followed by the name of the object you wish to create. Here we have created an object Cexpert which is a type of MyExpert class. Cexpert can now be used to access all the public member functions of the class MyExpert. Next we set all the other variables that will be needed by the object we have just created so that it will be stored in the objects member variables using the functions we already described when writing our class. The next line of codes shouldnt be strange, we just decide to adjust our Stop Loss and Take Profit values for three and five-digit prices. EA ONTICK SECTION The first thing we do here is to check for total available bars. If it is enough for our EA to trade, it will otherwise it will not trade until we have enough bars that is, 60 bars. Then we declared two variables of the MQL5 structure MqlTick and MqlRates. And lastly, we use the ArraySetAsSeries function on the rates array. Here, we used the SymbolInfoTick function to get the latest price quote and used CopyRates to get the last rates for the past three bars present bar inclusive. The next lines of code check if we have a new bar. We declared two datetime variables, one is a static variable PrevTime and the other is BarTime. If we have a new bar, the bar time is stored in the static variable PrevTime so that we will be able to compare its value with the value of BarTime in the next tick. In the next tick, if the PrevTime equals BarTime. So our EA will relax. If however BarTime is not equal to PrevTime. We decide to store the new bar start time in the static datetime variable, PrevTime and our EA can now proceed to check for new BUY or SELL opportunities. We decide to check if we already have an opened position. We just want to be sure we opened a buy trade when there is no Buy opened and a sell trade when there is no sell opened. Now we are back to the object we created, why Because we have been able to make all the necessary checks that is necessary for our object to do its work. The first thing we do is to get the closed price for the previous bar using our objects member function setCloseprice. Then we call the checkBuy function to find out if a condition for buy is set, if it returns TRUE, then we want to be sure we dont have an already opened buy position. If we dont have an already opened buy position, then we prepare the required variables to be used for our order the order type, the current ASK price, stop loss, take profit and maximum deviation and call the openBuy function. See how easy it is to use the class we have written. This is the same as what we have done above. Since we are checking for a sell, we called the checkSell function and if it returns TRUE and we dont already have a sell position opened, we prepare the required variables to place our order the order type, the current ASK price, stop loss, take profit and maximum deviation and then call the openSell function. Pretty easy, isnt it We have finished writing the codes. Now it is time to debug our code. If you dont know how to use the debugger, please read the first article for a better understanding. When you press F5 or press the debug button, the included file our class will be included and checked, and if there is any error, it will report it. Once you see the error, you need to go back to the code and correct the error. Our include file is included when debugging the main EA code If everything is okay you have done well. It is now time to test our EA using the strategy tester. We need to compile our EA before testing it with the Strategy Tester. To do this, click on the Compile button or press F7 on your computer keyboard. Click the Compile menu button to compile our code From the trading terminal menu bar, go to View --gt Strategy Tester or press CONTROLR to start the strategy tester. For details of how to use the tester, please read the first article. For you to be able to test the EA with the strategy tester, you must first of all compile it. If you dont compile it, you will get an error when you select the Expert Advisor on the settings bar of the strategy tester. I just discover this in the new version of the terminal. The code of EA should be compiled before its use in the Strategy Tester Find below the results of the Strategy tester for our Dolgozz based Expert Advisor. The trade results for our Object Oriented Expert Advisor Figure The graph results for our Object Oriented Expert Advisor The trade activity reportjournal: The trade activity results for our Object Oriented Expert Advisor The chart for the test: The trade chart results for our Object Oriented Expert Advisor Conclusion In this article we have discussed, to some level, the basics of a class and how to use it in writing a simple Expert Advisor. We have not delved too much into the advanced areas of classes but what we have discussed in this article is enough to help you develop yourself to a level you will be able to write your own object oriented Expert Advisor code. We have also discussed about how we can check for free margin such that our EA does not trade when the free margin available is not enough for the position we want to open. You will now agree with me that the new MQL5 language has much more to offer and you dont have to be a programming guru to take advantage of this new language. That is the main reason behind writing the step-by-step guides. Kaufen Billig Erkelenz North Rhine-Westphalia. Saturday, 29 April Forex Trading Markt Analyse. Posted by Tina at Share to Twitter Share to Facebook Share to Pinterest. Friday, 28 April Forex Handelsunternehmen In Hong Kong. Schreiben Forex Expert Berater.

4 thoughts on “Ne dolgozz forexpros”

  1. aglaz says:

    This is a concept that defines the admissions review process at selective colleges and universities across the US.

  2. affiliate says:

    Glaciers which had beenset up in 1894, with the aim of bringing.

  3. mike says:

    The absence of such data is specifically relevant for compounds with low acute toxicity (such as cannabis), the risk of which may therefore be underestimated.

  4. AlekSashkaF says:

    I would like to hear from people who were there with me.Master Chief Ollie.you still kicking.

Leave a Reply

Your email address will not be published. Required fields are marked *

inserted by FC2 system