Automated trading - Howto (MT4)

Hello guys and girls,

This challenge has been on my mind for a while and I have been challenged to start it, so I think it is time…:slight_smile:
I trade automated. I fired myself as a trader and let the scripts do their work. This has major advantages as well as disadvantages (which I both will address).

I will start from scratch and I won’t go in to theory too much, as it needs to stay practical and easy to use. It will also give me the opportunity to provides some tools to the manual traders out there to help improve their trading.

This thread will be the discussion and the index thread. I will deal with subjects in other threads and refer to them from here. Also I’d like to see discussion going on in this thread and only subject related input in the subject threads, or else I won’t be able to manage it all.

I need you guys to give me input and to keep the thread alive!

Principles:
-[B] I am a trader that learned to code, not the other way around.[/B] This means that there are for sure sexier looking code available, and I hope snippets of these are shared in the different subject threads.

  • [B]Scripts shared are for use, but at your own risk. [/B] I share tested scripts, but you have to at least backtested them on your system to feel confident in using them.
  • [B]I give opinions and want to read yours, but I am not going to be academic about believes that I have with regard to automated trading. [/B] Meaning, when I say that automated trading isn’t scamming. Than that is what I mean. If you disagree as a non-automated trader, please carry on with your live and leave this thread alone. Constructive feedback is certainly appreciated, but we can use the ICT threads for boxing on topics. :wink:

[B]Input I need:[/B]

  • Support to continue
  • Ideas to code
  • Ideas to improve my coding (either making it sexier or to reduce the number of lines).

I hope I help you with this. Keep an open mind. I wouldn’t be doing this if I wouldn’t know that it can help you as a starting trader.

1 Like

[Reserved for indexing]

x. 301 Moved Permanently
(Includes a first practical script : Line notification)
x. 301 Moved Permanently

To be added later:
x. Setup trade using lines
x. What am I working on now
x. Standard EA generator script
x. Howto run an EA in MT4
x. Myths and truths about working with EAs.

A very helpful function of an EA is that you can receive messages. As receiving emails isn’t easy to set-up for all (non-smtp email required) I will use the metaquotes notifications in the script I share. Following thread shows you on how to set that up for use. It was made by me under my old account, so I can’t post in there.

http://forums.babypips.com/forextown/49308-metatrader-alerts-your-mobile-how-do.html

Hello Toekan,

thank you for this thread, it´s really interesting! :35:
I am starting again (after a big crash due to a martingale bot) to test EAs, but i think i will also learn more about forex and how to code mql. Because as it seems, most or nearly all of the free or commercial EAs don´t bring us anywhere, except to lose money.
Not now, because i have a hard job and a family to take care, but i hope soon when (if?) i will have more time.

Thanks Ricki, I’ll do my best to make it as simple and practical as possible. This is also new for me, so keep feeding me input on how to improve or what tools can be usefull for you.

Great, you started it :slight_smile:

EA’s have a really bad reputation in trading because of all the trash being sold on the internet, newbie attempts to produce crazy returns, lack of money management, etc.

But where EA’s can really help is in making trading easier, both practically and psychologically. They can trail stops intelligently, monitor markets when you’re busy, alert you when your entry criteria is met, calculate your position size, etc. We can use them as the name suggests…as Expert [B]Assistants[/B]!

Hi Toekan,

I want to make an EA that will watch fo twezer tips, hammers and other things. It will notify me somehow when the condition exists and then I will make the decision to trade or not. It doesn’t sound complicated but I have no idea where to begin other than finding the functions that look at bar open high low and close and compairing to the next bar.

Anyway, i’m not in a big hurry and I want to learn to code.

Thanks for the thread.

m

Interesting thread idea. :slight_smile:

I tend to muck about with scripting whenever an application interests me and am interested in learning mql4 since I intend to chill in the fx community for a good while. You have the support of this fx newb for this thread!

As for making your code “sexier” and reducing the number of lines…

I learned most of my skills coding scripts for Blender, the open source 3d modeling, animation, rendering and video editing application. The best advice I can give you from this open source perspective is to comment your code well. This might increase the number of lines in your files, but if you want others to improve on your work and if you want to be able to look at your scripts in a few months and understand them quickly then you’ll need those comments.

Another essential is sensible variable names. If you need to use huge comments to explain the functioning of your scripts then it’s possible that you could use the variable names themselves to provide some of the explanation. I have found the scripts written by professional coders to be almost opaque in their operation. When coding professionally, obfuscation is pretty much par for the course, but when operating in a community driven coding environment, clarity is one of the most important things.

eg.
Bad variable names: S, CSL, NTP, C, param1, param2, a, b, c, d (I have seen things like all of these slaps forehead)
Good variable names: Spread, CurrentStopLoss, NewTakeProfit, Counter, DefaultStopLoss

Hope I’m not teaching granny to suck eggs here, just offering a little support.

Happy scripting, happy trading. :slight_smile:

Best of luck Teokan. :slight_smile: If you need any help, just send me a message.

How hard will it be to program using MT4 if you have experience with C++??? Because im planning on learning C++