In Part 49 I posted my generic start code for you. It seems the download link may have been a problem. I’ve created a GitHub site with all the code for Trader’s Tech. I’ll be adding new code as we proceed. In this installment I’ll explain the code.
I’d like to start with an apology (I seem to do that often.) When I copy and paste the code from MetaEditor to the WordPress editor, it doesn’t translate well. I usually have to go through the code and replace line feeds and spaces and such. It’s very annoying. I apologize that I didn’t look over the code as well as I should. There are missing line feeds. I like to space things out to make them more readable.
Notice the #include statements. If you’ll remember, #include is a compiler pre-processor command that includes the named file in your code. You may recognize the PcntTradeSize.mqh include file. The others, not so much. The stderror.mqh file includes a list of the definitions for the error constants, allowing you to use, for example, ERR_TRADE_CONTEXT_BUSY in place of the error code 146. That’s kind of like using the constant MODE_BID in the MarketInfo() function instead of having to remember the integer that represents Bid in that function call.
Stdlib.mqh imports stdlib.ex4 and defines the functions therein. You can look at the stdlib.mqh and stderror.mqh in the include folder of your MetaTrader Navigator Files window. As far as I know, they are included with every MT4 platform. If you don’t happen to have them, drop me message and I’ll send them to you.
Lastly, OrderReliable is a brave attempt to fix the fallacies of the Order functions in MQL4. It is a very helpful library and I use it all the time. It’s public domain and I’ve included a copy of it at my new GitHub download site. For the most part, the functions in OrderReliable will only cause you to change the name of the corresponding Order function in your code. For example, OrderSend() becomes OrderSendReliable(), with the same parameters. It will handle much of the problems caused by the pickiness of the Order functions, such as not using SL and TP with ECN brokers. One thing you do have to remember, when designating the symbol in OrderSendReliable() and the others is to use Symbol() for the local chart symbol instead of NULL which doesn’t work.
Next, you’ll notice several globals (not to be confused with GVs) that I like to use. I put the title, prefix, version and expiration date high up in the code so I can easily find and update them if necessary. I update the version number each time I edit the code. That’s mainly to be sure those using the EAs have the latest version of the code. Later we’ll look at the function DrawVersion() which prints the current version number in the lower left hand corner of the chart. I use the prefix with all GVs and drawing objects so I can delete them wholesale without having to name all of them. I keep this prefix unique to all my EAs and all GVs and drawing objects start with those characters. I use the title periodically in experts log entries – particularly at the beginning of the EA run. The Expiration Date is sometimes used to be sure that the EA users have the latest version of the EA. The default Expiration Date is 30 years in the future to be sure I don’t accidentally release a version that will expire prematurely. Anyone still using my EAs in 2041 has a real problem. 😉
That’s it for today. We’ll go over more of the start code in our next session.
Thanks for your attention and please follow me on Twitter and LinkedIn.
Latest posts by admin (see all)
- How To Plan a Trade From Start to Finish - May 3, 2016
- How To Trade The Eur/Usd Right Now - April 29, 2016
- Eur/Usd Could Move Higher Based off of Support Pin Bar - February 19, 2016
Winner’s Edge Trading, as seen on: