Let's learn MQL4 online together

int Variable1 = 1; //int means integer and can only be numbers like 1, 2, 3, 10000 etc
double Variable2 = 1.1; //double is also an integer but WITH a comma, like 1.4 and 1000.2 and 2.0000
string Variable3 = “here is text. Hello world”; //string just creates a text message, nothing special :smiley:

So a test for you, Rhelt. When you want a LotSize variable or price variable, what data type will you give it? int, double or string? There you have your answer :slight_smile:

thank you. I finished that MQL ebook today! I made some tutorial EA’s, indicators and scripts. But that template tutorial didn’t work because I found out that the latest MetaEditor doesn’t have a template option anymore, is that right? I’m finally ready to make my first EA that is not a tutorial :). I’m gonna start simple, I just want to create an EA that puts 3 buttons on the chart. If I press on button 1: then it buys an order instantly (tp/sl: 10), button 2: same, but sells instantly. button 3: create pending order with SL/TP: 10.

Don’t hold yourself back if you have tips :slight_smile:

1 Like

When do you guys think you will finish the MQL tutorial? My MQL tutorial (18 chapters) took me 1 month. I just finished with the complete tutorial. Does anyone like to make an EA together with me?

[B]QUESTION[/B]
Does anyone know where I can find a trade manager EA, with buttons to instantly open a (pending) order with pre-set StopLoss/Take profit/LotSize?

[B]Does anyone want to create an Expert Advisor with me?[/B] Here are ideas for profitable EA’s. Pick one idea out, and let’s build it together!

Profitable strategies:

  • 50sma + engulving
  • Ema14
  • PP
  • overbought + MA + main trend
  • open based on 1/4th of candle
  • ema8 crosses ema13
  • martingale based
  • bolinger band based (has both breakout and consolidation strategies)

Or if you have another strategy suggestion, let me know. Then we’ll build it together!

"My MQL tutorial (18 chapters) took me 1 month. "

Which MQL tutorial/ebook do you mean Michael Lobry?

I have started this course - https://www.udemy.com/learn-mql4/

So far it’s very basic, and so it would be suitable for almost anyone, even complete beginners. Whether it can actually teach you make an EA, is another matter. I’ll report back.

RE: picking strategies for building a first EA - which system is the simplest? Which one has the least number of entry/exit conditions?

Bro, don’t need to pay $190 bucks to learn how to code. The links provided earlier give exactly the same info for free.

As for first strategy, find the thread on donchain channel trading. I’ve posted a few bots there. Copy them them understand the simple logic and work from there.

As for multiply strategies, initially won’t work. Focus in on your style and goals, find that one strategy and apply everything you have forever to improve it.

I agree 190 would be too much but I only paid $24, and the course is pretty good, if somewhat basic, so far. Sure the info in the links is great, and I will go through those as well, and report back, hopefully this week.

Thank you Bob.
Thank you Clemmo.

I did a couple of complete mql courses.

  • coders’ guru forex-tsd (best tutorial for learning mql in my opinion)(it’s better than forexboat)
  • forexboat.com (don’t buy the videos, just go to google and use the google keyword: site:forexboat.com and you can watch all the videos). Or look up algorithmic trading in forex create your first forex robot in google. This is the name of the course.
  • Expert Advisor Programming Creating Automated Trading Systems in MQL for MetaTrader
  • EA Programming Automated Trading Systems in MQL
  • MQL4 Reference Guide (lots of good strategies)
  • Mql 4- Metatrader 4 Development Course

Yes, the link you posted is forexboat, but no it’s not enough. That link is a tutorial on a too low level. It’s too basic and the course is too slow. Well, if you never programmed in your life then I suppose it’s the perfect step. I already had Action Script and php knowledge.

It’s normal for programmers to work together. Anyone wanna make an EA together with me? It’s a stimuli for me. And four hands, make a program.

1 Like

Let me know if you have questions. I would like to help. Great Idea to make this thread.

Here is an update of the MQL-courses that I finished:

  • MQL4 Reference Guide, all functions, error codes, etc
  • Mql 4- Metatrader 4 Development Course
  • Krill MQL video Course
  • Expert Advisor Programming Creating Automated Trading Systems in MQL for MetaTrader
  • MQL4BookSourceCode
  • forex robots use mt4 strategy tester like a forex protrader (aka the infamous forex boat)
  • algorithmic trading in forex create your first forex robot - video course

Below MQL courses are too difficult for me. I do recommend these for Mathematicians:

  • Algorithmic Techniques for the Polymer Sciences - Bradley S. Tice (CRC, Apple Academic Press, 2015)
  • Algorithmic Trading Winning Strategies and Their Rationale
  • Barry Johnson - Algorithmic Trading & DMA
  • Building Winning Algorithmic Trading Systems- tradestation - Davey, Kevin (this last one is not about MQL but still interesting trading Algos)

Thank you for your interest TC Holland!! See pm :slight_smile:

You are a machine Michaellobry!

I am also taking the forex boat course, but progressing more slowly than you. Why are they infamous?

Can you post some links to these courses? TSD is a forum I know but I couldn’t see their course.

Yes, I would like to, Michael Lobry, although you might be more advanced than me. I’m also not sure I have enough free time to keep up with you, but we can see.

How can we do this as a team? Out of those ideas that you mentioned which one is the SIMPLEST to implement?

  • 50sma + engulving
  • Ema14
  • PP
  • overbought + MA + main trend
  • open based on 1/4th of candle
  • ema8 crosses ema13
  • martingale based
  • bolinger band based (has both breakout and consolidation strategies)

Not sure what PP is. I have some Bollinger band and semi-martingale ideas. You’d have to explain these other ones, although I can guess 50SMA and one engulfing candle is the entry signal - what’s the exit? I have one very simple idea based on the 1,2,3 hi/lo system.

When I write a trading system I use a few standard categories.
Chart
Timeframe
Indicators needed (if any)
Entry conditions
Exit conditions
Positing sizing (money management)

So if the strategy requires a specific pair or timeframe I set that out first.
Exit covers things like tp and sl levels, and MM can be very simple, like X$ per N$ of balance/equity. Here’s an example:

Aragorn v. 0.06 (because it’s a range-trading system, get it? :P)
[B]Chart:[/B] Any major pair should work - trying on EURUSD to start.
[B]Timeframe:[/B] Any - but starting with M15
Indicators: 3 Bollinger bands - 1, 2, and 3 standard deviations. Different colours.
5 period ATR, and 14 period ATR.

[B]Entry:[/B]
Wait for a candle to close across the top or bottom bounds of the 2 or 3 std dev bands - call it the ‘signal candle’. Then wait for a ‘confirming candle’ - one that closes in the favorable direction. Enter at the next candle open, call it the ‘entry candle’, using 1PSU (position size unit) for an entry at the 2 std dev band, and 2 PSU for an entry starting at the 3 std da band.

Optional:
Place ½ size orders when ATR is downtrending.

[B]Exit:[/B]
Place a trailing stop when price crosses any 3 bands or when it hits 2nd st. deviation or more.
Place a stop-loss 1ATR below the opening.

[B]Notes:[/B]
Count the exiting candle as the first candle for the next trade.
Would we make more profit with 2x the stop loss and only close when it hits 3x band? Needs testing.

I also mark the items that I intend to be configurable options in a different color (green). Those are the settings that need to be optimized in back/forward testing. You’ll know about that if you took Kirill’s course.

I dont understand: Candle close across the Top => confirming candle Short or Long?
ATR down trending? Short or Long? and Up trending?

Can you say more about the exit. Is the Trailing stop also based on ATR or fixed amount of pips? When to move at BE?

I already made a couple of EA’s. Problem was it didn’t perform as expected (probably over-hyped). Tried the 3 EMA Crossover and one Kumo Trading strategy. So just to give everyone some tips for building theirs:

Grab that sample template EA and reverse engineer it
How I learnt was going through the built-in docs in the Metaeditor. I simply highlight that word and press F1. The docs explained it really well. But don’t skip the basics. Understand why the structure is like that and how often a specific function is triggered per tick is required (Hint: put most of your codes in OnTick())

MT5 / MT4 docs are the best and Forums are your friends
Sure, there are online courses for this but my preference is more self-pacing and less data consuming than loading videos. And when I’m stuck, I check the forums (either in reddit or the mql community). Because for sure, someone must have asked the same question and someone has already answered it like StackOverflow.

Learn to debug
There are times when I get stuck that the EA doesn’t trigger the way I wanted it to. So I tried to debug by adding some Print values here and there and see what changed/stopped/mutated. This goes without saying for any programmer out there.

Have a bit of scripting knowledge
I came from a Javascript background and no idea about C. But when I load up the sample Moving Average template, everything just looks familiar. So it doesn’t matter if you’re on C or C++. Just take any scripting language and learn how to form IF ELSE, WHILE LOOPS, FOR LOOPS, etc because it works just the same. The difference is its in a different dialect (or language) but speaks just the same. But this is a personal opinion though and it has helped me understand MQL much easier.

Got any questions? Ask away.

At the moment, I’m trying out new strategies and tweaking parameters until I find something more satisfactory of a performance.

IIRC, doesn’t Metatrader have this already? I think its called the One-Click Trading option. I’ve never used it.

sources to learn mql:

  • google for: expert advisor mq4 filetype: pdf
  • You can youtube for: jim dandy. He’s a good one.
  • On page 1 and 2 in this thread are some mql ebooks that I recommend.
  • on page 4 is a list of mql courses, that you can download on google
1 Like

thank you for the tips! Yes, I got a question. Do you have a mq4 file with default functions for any EA?

What tips could you give me to make an already profitable EA, more profitable? Please add to the list:

  • MM (lotSize% off equity)
  • skipping x losing streaks
  • martingale
  • hedging
  • optimize; use the right pair/timeframe/day/time of the day
  • good broker: low spread/commission costs; fast order execution
  • WHAT ELSE?

Which built-in protection would you recommend for any EA? please add to the list:

  • tick: only if first tick finished the program, only then another tick can pass
  • 4/5 digit compatibility
  • spread protection: only open order if spread <5pips
  • before opening/modifying/closing/deleting an order, check whether the EA_stack isn’t occupied (meaning: check if other EAs are currently doing the same)
  • Bars<100
  • WHAT ELSE?

Unfortunately, I don’t. Each EA I made are made specifically different with the different uses of indicators, monitoring of ticks, and strength of supplies and demands. But I could give a few code snippets that a lot of traders always use like:

  • Lot Optimizations for the number of digits in a pip
  • Check against current trade and if an existing trade is available, don’t open another trade

But honestly, these are already available in your existing sample EA template. Just have to dissect it out for reuse.

Money Management is simple. Just set how much lot you willing to spend per condition met.

Skipping x losing streaks only relates to how you set up your trading strategy. To check against, run Visual mode and find that losing streak in the chart. Did the EA miscalculate or misunderstood what you tell it to do in that situation? If it did, debug it. If not, then you need to revisit your strategy parameters and try again.

[B]NEVER DO MARTINGALE! [/B]My first EA was martingale and that caused a huge drawback to my account. It failed against any news events (expected or unexpected). At first, I thought, “I’ll do martingale in my EA and I’ll pause the EA when a major news event is close.” Problem was, there were some news that just happened so unexpectedly like a Gold mine strike and that killed my account.

I’ve never used hedging because my broker won’t allow it.

Optimize is based on which pair you know best. Do you follow EURJPY related news? Do you know how volatile that pair is? Go for it. Also, the purpose of my EA builds is that it doesn’t matter of day of the week or month it is, as long as the conditions are met, it will continue to buy or sell.

That’s a personal preference. If you wanna go hardcore, go with OANDA, use its developer API and run some algotrading instead of building EAs.

Personally, I’m with XM at the moment because I’m a Muslim trader and I need an Islamic account. The upside is that I don’t have to pay commissions each time to the broker, which is nice. But I am planning to move out and find a better Islamic broker to do business with because of spreads.

I don’t understand. Isn’t OnTick() doing this already?

It’s called Lot Optimization. And it depends if you plan on using the EA on multiple pairs instead of just one. I’ll share a snippet soon.

Sure, you could add that condition. But you’ll need to check on the previous tick’s spread to find the difference though.

How do you stack multiple EAs on a single chart? This is news to me.

Best to run the EA if there are enough bars on chart. And that’s exactly right. 100 bars is good.