Some coding suggestions
|
|||
|
Hi All
I would like to sugest a couple of coding practises which may change the professionalism of the EAs being delivered. There are many good reasons for doing this, but the main one being that the people who may be able to make the best improvements to the EAs and therefore make them more profitable and less risky, are not good programmers. 1. Hide the logic! The start routine is usually one enormous mess of code and cryptic variables. What it should be is the step-by-step processing that is required to make the EA function. Take the cryptic logic and put it into functions and name those functions very explicitly using Hungarian notation, for example: int start() { double tradeLots = Lots; int tradeTicket = 0; bool enterTrade = evaluateTradingConditions(); if (enterTrade) { tradeLots = getTradeLotSize(); tradeTicket = placeTradeAndRecordToLog(); if (tradeTicket==0) { logFailure(tradeTicket); } } } bool evaluateTradingConditions() { bool canTrade = false; bool oversold = false; double macdMain = iMACD(.... double macdSignal = iMACD(.... if (macdMain>macdSignal) { oversold = checkRSIForOverSold(); if (oversold) { canTrade = true; } else { canTrade = false; } } return (canTrade); } ... the EA becomes a lot easier to read, to debug and to get up to speed on. There is no mistaking the logic as each bit of logic is explicitly stated and programmer and non-programmer alike can read it. 2. Create libraries. I don't have time to go into the details of how to structure the code, but the basic principle of using libraries to store one's logic and then to seperate the logic components into a flow which is obvious and break it into smaller, simpler steps than one big equation, will allow for the proper sharing of code and the proper expansion of a logic routine, instead of considering an EA to be a discrete piece of code. 3. Use templates as a starting point. NEVER start an EA from scratch - NEVER! There should be pre-defined structures and options to choose from. These would incorporate all of the tried and tested standard functionality - found in libraries. Things like trailing stops, trend evaluation, market volatility, etc could even be put into standard templates with a section called "your trade entry code goes here..." and "your trade exit code goes here ...". Why spend months writing the same code as everyone else when it already exists - better than you could ever write it, in the public domain? I'm out of time, but I hope this helps. |
| The following users have thanked 4xdude for useful post above: | ||
![]() |
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Suggestions? Post Here! | gazuz | Issues | 25 | 06-10-2008 05:58 AM |
| Need some help coding indicator | martini5470 | Indicator Coding | 1 | 09-01-2007 03:01 AM |
| Coding an EA | ossaossa | System Coding | 0 | 04-15-2007 12:25 AM |
| 3 methods of FOREX trade, suggestions? | alan_FX | Commercial Products | 0 | 03-17-2007 11:38 PM |
| Zero code beta 2 suggestions | Belzebut | MetaTrader and ZeroCode | 0 | 06-12-2005 09:40 AM |
All times are GMT. The time now is 11:18 AM.
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now







Linear Mode

