EA from scratch - Part 1

 

Hi there,

I hope I may start this thread here under expert analysis.

First of all, excuse my English. It's my second language, but I'll try to correctly express myself.

I've been trading live (part-time) for about a year now, and lost a lot of money. Not just on trading, but on books, systems, EA's, ect. Most of you might relate to my situation

Because I like my job and don't want to sit in front of my computer watching forex charts 24/7, (I tried this last year for 2 weeks and almost went crazy ) a good, consistent EA will suit me better. This has motivate me to learn and write my own EA's and not to depend on other people.

I don't have any programming experience ( I did teach my dog to fetch a ball, does that count?) and only have some materials I got from this site about learning MQL4.

If we (all the non-programmers) can work together, line for line, from the very beginning and write our own EA's, wouldn't that be great?

I have named this thread "Part 1", which will be where we learn how MQL4 programming works. "Part 2" might be writing 5 or 10 good EA's and testing them.

Please don't tell me to buy a book about a programming language such as C++ and study. I hate study! Let's try and find a practical way of learning MQL4 programming step by step.

So, what will the very first step be to write your own EA? Where can we start?

Any suggestions? Remember KISS (keep it simple stupid).

PK

 

The very first step

Ok, the very first step for non-programmers to write the holy grail of EA's: Switch on your computer

 
PKFX:

So, what will the very first step be to write your own EA? Where can we start?

Any suggestions? Remember KISS (keep it simple stupid).

PK

Hi,

it can be a good lesson for those who has no sufficient skills in programming.

I suggest you to pay attention on my last experts(TrendEnvelopesExpert, TrendStrengthExpert and HMAExpert), which have clear and well structured code.

 

ea

I would read the book on writing code. Its not that bad.

the mql development course..is a must read from the main area. I learned from scratch and can pretty much hold my own after 1 year.

Both this site and the one below have alot on experts to learn from. Index of /_MT4_Experts

Also, below is a site to look at some code.

Expert Advisor Builder for MetaTrader 4

You can build a bunch of stuff and see the layout.

After all that --- you may want to go back to manual trading because

you will be able to feel the market.

Just kidding ---

 

Thanks for the reply and advise ajk and igorad.

One method I used when studying accounting (but that was 200 years ago) was to start at the end and work backwards to the beginning. For example: Start with the questions at the end of the chapters and use the concepts explained in the chapter to answer the question (without looking at the answer). Please note that this worked for me and it won't necessarily work for others.

Maybe we can get a simple, completed EA and work backwards to the beginning. Any suggestions on an EA that we could use without getting in trouble regarding copy write issues?

 

Whats copy right? -- I copy everything~! Building from scratch is for programming crazies. Just dont sell it. Your method is fine. -- However, I think though you will have trouble as function concepts are not explained extremely well and take a long time to learn.I still don't know how to build an indicator and have no interest---but I know how to extact the guts and make it work in the ea. EA building at first is not exactly easy and information is hard to come by. 1 mistake and the ea doesnt function properly and sometimes with no mistakes it gives you a bunch of hickups.

Just getting the help key to come up and why it sometimes doesn't come up with the right font size was hard to figure out.

For me, I concentrate on get in (multiple ways of get in ) -- and also get out stuff. There are plenty of ea's that

have a lot of guts - terminators , firebird....These are very good ea's for trade and money management but not complete on the full cycles. Actually,

the best way is to get challenged by an outsider to say " make my ea do this" -- it's amazing the crazy stuff you can come up with and say "yeh baby' take that! All I can say is you will work hard, very hard!

 

...I am working on this "ea" strategy...

PKFX:
Ok, the very first step for non-programmers to write the holy grail of EA's: Switch on your computer

...this "ea" will;

1.will find and identify all kinds of markets, then assess the right time for entry...

2.once entry has been made, it will close after a certain percentage above equity has been added, thus accumulating equity, not in pips, but in equity percentage, this can vary depending on market volatily...

3. most volatile pairs should be used at all time frames...

4.the least amount of deposit with the highest amount of leverage can be used ie; $250.00 with 400/1 leverage...

5. it must have "drawdown protection", when this occurrs the "ea" places a hedging entry at 1 and a half times the lots as the oringinal entry so you will have an overall positive, once this drawdown protection has been activated (surpassing the spread) then the trade is closed locking in profit, IT CAN DO THIS INVARIABLY, with discretion, depending on market volatility...

6. then the search resumes again for an entry, then the process is repeated,

this can hypothetically assure you an overall profit and a meteoric equity curve with no lossess...

7. stoploss is supplmented by a breakeven mode, so no "sl", just "be", this can be achieved mathmatically, constantly remaining in small negitive, big positive mode to ensure constant gains or it can deactivate the "dd" protection and remain in an unidirectional trading if the trend permits, (but a parabolic "sl" can be added)...

8. it can have a step mode that can safely utilize the martingale method...

9. this "ea" will be the best of the best, and it will be called, "DreamEA", or

"TitaniumEA"...

...I will help design it, how? By reverse engineering an existing "ea" and adding an "dd" protect.

ZERO DRAWDOWN CONSTANT PROFIT

 

Igorad's HMA indicator and HMA EA are examples we could possibly look at? Igorad included an add-on TesterReport to the EA so the whole package is indicator, EA and add-on - 3 parts - very well commented code too.

 
PKFX:
Ok, the very first step for non-programmers to write the holy grail of EA's: Switch on your computer

... Plug it in first

I think this is a wonderful idea and I will join in too

Would it be better to program an indicator first then the EA to go with it?

- Indicator;

- EA of indicator;

- Add-on's.

Does that make sense?

 

I believe MT4 has a simple MA EA included which we could look at. We could plot the MA's using indicators then look at the EA to see how it functions. As MA x-over trades are "always in" the market, this makes things a little simpler. We could then add account checking, session time trades, conditional entries based on other external indicators (if this can be programmed), stop loss and target settings ...

 

This is great!

Sadly and Mycode, this was just the response I was looking for.

Sadly, I also think we should start with a simple EA like the MA one from MT4 and then add some stuff to make it more interesting. After we understand the basics of this EA we could move on to something more complicated.

Reason: