• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 7:37pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 7:37pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

MT4 build 1220 EA running OK, build 1260 not OK 1 reply

Why your broker is your friend and your enemy 4 replies

MT4 Compiler Build prior to Build 6xxx 7 replies

Making your Indicators work with MT4 Build 600+; Simple! 1 reply

Build 201 has new function names that can mess up your EA 0 replies

  • Commercial Content
  • /
  • Reply to Thread
  • Subscribe
  • 27
Attachments: How to Build your EA
Exit Attachments
Tags: How to Build your EA
Cancel

How to Build your EA

  • Last Post
  •  
  • Page 1 23456 10
  • Page 1 234 10
  •  
  • Post #1
  • Quote
  • First Post: Edited Jul 5, 2022 7:09am Oct 7, 2016 12:00pm | Edited Jul 5, 2022 7:09am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Disclaimer: Please note that this thread has nothing to do with any particular EA nor it will provide any valuable trading knowledge. I could not find any thread where people are taught to build their own EA, so I started this thread.

Who m I ? Just a simple trader who thinks designing our own system will give us more free time. Technically I am a designer too, and have designed multiple EA for large number of peoples including myself.

What this thread will offer: We will discuss all possibilities available for a trader to design their personal systems. Traders who have their personal trading method but are not able to create any special tool for themselves will learn how to create it step by step, no matter how bad they are in coding.

Who can contribute here: All can contribute their knowledge if they desire to do so.


Below I will be slowly adding Important links regarding various tools and study websites so that they will not be lost in confusion between the posts.

STUDY:
1. MQL4 Tutorials - They provide basic knowledge about MQL4 programming rules.
2. MQL4 Reference - They provide details knowledge about each functions with example available in MQL4 programming.

TOOLS:
1. EA Builder - A powerful tool to develop good quality EA and Indicator very easily. Though it is not entirely free, it reduces most of the manual coding work.

2. Trades Copier - A FREE tool which copy trades from demo to real account & allow you to use all paid EA on mql5.com website for Free.

3. Multipair Analyzer - A PAID tool which analyze market structure and provide multiple market analysis to traders.

  • Post #2
  • Quote
  • Oct 7, 2016 12:18pm Oct 7, 2016 12:18pm
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
No Idea from where to begin with.....
Well let me divide EA designing into five main part.

1. First is you need to have your personal trading style. Your EA is just a shadow of you and is build in your own image.

2. Draw out your trading method or flow diagram in a paper so that you will not be confused while designing.

3. Think about how you can divide your trading method into small parts so that we can generate as much code as possible before actually writing it manually.

4. Assemble your small code part as per your flow diagram and turn it into a single program.

5. Build and start back-testing your code and again repeat from step-2 if testing results fail.

Next post I will elaborate in details
 
 
  • Post #3
  • Quote
  • Oct 7, 2016 5:07pm Oct 7, 2016 5:07pm
  •  AntiVi
  • Joined Dec 2015 | Status: Member | 277 Posts
How difficult would it be to make an EA that trades advanced patterns?
Since advanced patterns use Fibonacci tools to measure them I think the hardest part would be getting the EA to detect them and draw them out.
Then depending on your stops and targets it may be easy or difficult. I'd imagine that a 2x atr stop would be easy to make for example.

So lets say you'd trade a Cypher pattern:
1. Get the EA to detect them and draw them out.
2. Get parameters on the EA to tune the size it scans for the patterns so you don't get a giant pattern that should be traded on the weekly on the hourly chart for example.
3. Get the EA to put the right stops and targets let's say we take profits at the 61.8 retracement and we use a 1.5x ATR stop loss taken from the start of the Cypher pattern and get it to deal with spreads on top of that.

Something like that?

I have no coding knowledge nor any EA experience.

All I'm wondering is how difficult it would be?
 
 
  • Post #4
  • Quote
  • Oct 8, 2016 1:48am Oct 8, 2016 1:48am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting AntiVi
Disliked
How difficult would it be to make an EA that trades advanced patterns? Since advanced patterns use Fibonacci tools to measure them I think the hardest part would be getting the EA to detect them and draw them out. Then depending on your stops and targets it may be easy or difficult. I'd imagine that a 2x atr stop would be easy to make for example. So lets say you'd trade a Cypher pattern: 1. Get the EA to detect them and draw them out. 2. Get parameters on the EA to tune the size it scans for the patterns so you don't get a giant pattern that should...
Ignored
EA with advance pattern. Seems challenging. But It is not impossible. When you automate any trading knowledge, the part of trade which is determined by simple indicators controlled by numbers is easy to code and automate as numbers are definite. But the part which depends on human mood such as determining swing high and swing low for fibonacci tool is difficult to determine. For one person swing high may be a different area then yours, so these pattern reorganization is challenging and always conflict from person to person thoughts.
But after all every point in the trading screen is just each candle open close high or low you can say just numbers. There are functions available to take a bunch of numbers and give you your desired result.
ATR is just a number which cannot change from person to person in any period so playing with it is easy and can be easily implemented. Such as open and stop which depend on current value reaching certain per defined number is also easy to implement.

Making long story short applying pattern recognition is difficult part but other stuffs which solely depends on numbers is more easy then you can imagine. If properly broken down into small parts you can easily create your automated system.
 
 
  • Post #5
  • Quote
  • Oct 8, 2016 2:09am Oct 8, 2016 2:09am
  •  kbharunt
  • | Joined Nov 2015 | Status: Member | 38 Posts
I have an Ea.i want two more feature to add to the EA. 1. I want the lot size to double if there is two conseucative loosing trades.for example if my starting lot size is 1 lot it will become 2 lot after two conseucative loosing trades and 4 lot after two more loosing trades and so on.the lot size will come back to starting lot size that is 1 lot after a winning trade. 2.I want the EA to not open any new position between certain time.for example i dont want ea to open any position between 3 hrs to 4 hrs(chart time) 9 hrs to 10 hrs, 15 hrs to 16 hrs and so on.
please tell me how can i code this
 
 
  • Post #6
  • Quote
  • Oct 8, 2016 2:29am Oct 8, 2016 2:29am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting kbharunt
Disliked
I have an Ea.i want two more feature to add to the EA. 1. I want the lot size to double if there is two conseucative loosing trades.for example if my starting lot size is 1 lot it will become 2 lot after two conseucative loosing trades and 4 lot after two more loosing trades and so on.the lot size will come back to starting lot size that is 1 lot after a winning trade. 2.I want the EA to not open any new position between certain time.for example i dont want ea to open any position between 3 hrs to 4 hrs(chart time) 9 hrs to 10 hrs, 15 hrs to 16...
Ignored
These stuffs are very simple.... just about 4-7 line of code for both functionality that you have mentioned...

If you are using MT4 platform is is much easy.

keep a loss counter to count number of losses in your code. Reset the counter to zero on profit else when your counter reaches 2 just multiply your lot size controlling variable with 2 and start new trade. This will solve your first issue.

To put fix time there is a function already available Hour(), this returns you current server hour. so just implement as below
int h = Hour();
if(h >=10 && h <=15)
{
allowedTrading =true;
}
else
{
allowedTrading =false;
}

so before opening a new trade just check that allowedTrading value is "true" and open new else do not open.
 
 
  • Post #7
  • Quote
  • Oct 8, 2016 3:04am Oct 8, 2016 3:04am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Elaborating First point: Why we need our own trading method before designing our trading system.

There is nothing to elaborate here...
Simple reason i should trust my system in case of any unwanted situation. If I use a trading system which i don't know about its trading rule then i will never trust it completely, no matter how much profitable the system may be.

Trading is not for week hearten people, we play with money what we can afford to lose. So if your personal goal is to get rich quick without effort, then i suggest you to ask your family members to beat you black and blue from head to toe until evil spirit of money leaves you..

The main reason to have your own method is to handle problematic situation and can quick decision to deal with your open position because EA are not human so they can always follow rules. Situations where rule could not be applied should be handled by you else your EA will blow your account. And until you know the rule your EA follows you cannot determine if the current situation does not fit to the rule properly. Still we will learn to install safety measures which will protect our trade in extreme conditions when we are not available.

So please make your own trading rules first.

next post i will discuss what things must be covered while defining personal trading rules.
 
 
  • Post #8
  • Quote
  • Oct 8, 2016 4:30am Oct 8, 2016 4:30am
  •  AntiVi
  • Joined Dec 2015 | Status: Member | 277 Posts
Quoting D.s
Disliked
{quote} EA with advance pattern. Seems challenging. But It is not impossible. When you automate any trading knowledge, the part of trade which is determined by simple indicators controlled by numbers is easy to code and automate as numbers are definite. But the part which depends on human mood such as determining swing high and swing low for fibonacci tool is difficult to determine. For one person swing high may be a different area then yours, so these pattern reorganization is challenging and always conflict from person to person thoughts. But...
Ignored
I agree with what you're saying about human mood however I do it a little differently.
I personally took all subjectivity out of my way of trading a Cypher pattern. Basically if it looks like a Cypher it is a Cypher that will be traded. I also have a rule that states that if the cypher is bigger than my screen aka x amount of candles it becomes invalid or if it's too small meaning I won't be trading Cyphers that should be traded on a different timeframe. which is perfectly doable using an EA I think.
 
 
  • Post #9
  • Quote
  • Oct 8, 2016 5:57am Oct 8, 2016 5:57am
  •  kbharunt
  • | Joined Nov 2015 | Status: Member | 38 Posts
Quoting D.s
Disliked
{quote} These stuffs are very simple.... just about 4-7 line of code for both functionality that you have mentioned... If you are using MT4 platform is is much easy. keep a loss counter to count number of losses in your code. Reset the counter to zero on profit else when your counter reaches 2 just multiply your lot size controlling variable with 2 and start new trade. This will solve your first issue. To put fix time there is a function already available Hour(), this returns you current server hour. so just implement as...
Ignored
Sir,i dont know much about coding.it will be of great help if u can do it for me.i m attaching the Ea file here.

thanks
Attached File(s)
File Type: mq4 EA4.3.mq4   20 KB | 668 downloads
 
 
  • Post #10
  • Quote
  • Oct 8, 2016 7:05am Oct 8, 2016 7:05am
  •  SunGaard
  • | Joined Dec 2013 | Status: Member | 37 Posts
Quoting D.s
Disliked
Disclaimer: Please note that this thread has nothing to do with any particular EA nor it will provide any valuable trading knowledge. I could not find any thread where people are taught to build their own EA, so I started this thread.
Ignored
This really got me exited and i really hope this thread is not ending up in another "please build me an EA" thread.

I hope i dont sound to negative but i really looked forward to follow this thread and to learn more about building EA's...Please stay on track

@ D.s. thanks a lot in advance for taking the time to teach us how to build an EA

Sune
 
 
  • Post #11
  • Quote
  • Oct 8, 2016 7:51am Oct 8, 2016 7:51am
  •  Gumrai
  • Joined Oct 2012 | Status: Member | 1,959 Posts
Quoting SunGaard
Disliked
{quote} This really got me exited and i really hope this thread is not ending up in another "please build me an EA" thread. I hope i dont sound to negative but i really looked forward to follow this thread and to learn more about building EA's...Please stay on track @ D.s. thanks a lot in advance for taking the time to teach us how to build an EA Sune
Ignored
I don't think that you sound negative at all. What you say is valid as there has already been requests for coding. This could develop into a really good thread for those who are really interested to learn, but if it gets hijacked by people wanting free coding, it will end up confusing and a waste of the OP's time.
Please Do Not PM Me With Coding Enquiries
 
 
  • Post #12
  • Quote
  • Oct 8, 2016 8:08am Oct 8, 2016 8:08am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting kbharunt
Disliked
{quote} Sir,i dont know much about coding.it will be of great help if u can do it for me.i m attaching the Ea file here. thanks {file}
Ignored
This is what I an trying to make you learn. So that you can do it yourself. Think of it as DIY project..
Sorry dude if i Start accepting your request then very soon this thread will be flooded with more request.

I will teach you to learn things which can in return help you to modify your personal code.

Don't get upset... and have patience... you will surely able to modify your code yourself.
 
1
  • Post #13
  • Quote
  • Oct 8, 2016 8:21am Oct 8, 2016 8:21am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting AntiVi
Disliked
{quote} I agree with what you're saying about human mood however I do it a little differently. I personally took all subjectivity out of my way of trading a Cypher pattern. Basically if it looks like a Cypher it is a Cypher that will be traded. I also have a rule that states that if the cypher is bigger than my screen aka x amount of candles it becomes invalid or if it's too small meaning I won't be trading Cyphers that should be traded on a different timeframe. which is perfectly doable using an EA I think.
Ignored
Then in this case it is possible to design code that can recognize the pattern. You can previously set your fixed limit within which only a pattern will be searched. I even exactly have no idea what i am current typing.... but i think there is about 70% chance if you can set your boundary between which you want to search along with lower limit which you want to ignore then your desired pattern could be searched. If you are specially inclined towards Fibonacci tool we can search for the highest and lowest point within your limit and can apply the tool automatically.
Still you should understand, most pattern recognition code are complex then other. You may need neural network concept. It might sound more technical and difficult, which it is.... but certainly not impossible. After learning few tricks you may find a way around to compensate it.
 
 
  • Post #14
  • Quote
  • Oct 8, 2016 8:28am Oct 8, 2016 8:28am
  •  tmchrist
  • | Joined Sep 2016 | Status: Member | 14 Posts
I ran across this thread today and was glad I did. I am trying to code something myself and I have ZERO coding experience. Like ZERO. But I would rather learn the code than have someone do it for me. I took a programming class in high school many years ago and have looked over a few code scripts and it seems rather logical and learnable in a fairly short amount of time. By short amount of time I mean for what I am wanting to do with it. Basically I want to simply add an alert function to an already existing code. Seems simple enough. I am using pine editor for the code on the tradingview.com platform.

To get started I need a resource for the allowable syntax and some sort of easy to read tutorial. The end product would be to send me an alert whenever price hit a daily or weekly pivot point, not closing price just at any point in time. I want it to send me an alert only once in 5minute span for the condition though. Like if price touches a pivot on a 5 minute candle then retraces and touches it again on the same candle I only want one message to be sent to me in that 5 minute candle. The next 5 minute candle can send me another message.

Any help would be appreciated
 
 
  • Post #15
  • Quote
  • Oct 8, 2016 8:48am Oct 8, 2016 8:48am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting tmchrist
Disliked
I ran across this thread today and was glad I did. I am trying to code something myself and I have ZERO coding experience. Like ZERO. But I would rather learn the code than have someone do it for me. I took a programming class in high school many years ago and have looked over a few code scripts and it seems rather logical and learnable in a fairly short amount of time. By short amount of time I mean for what I am wanting to do with it. Basically I want to simply add an alert function to an already existing code. Seems simple enough. I am using...
Ignored
It can be fixed as pivot point are calculated from a candle open close high low, so calculating the numbers is not difficult. What you do with the calculated result is solely up to you. If you want to add alert then alert function is just a single line of code which can produce alert when used.

Below code is how pivot point is calculated The part i have made bold is the real calculation part other code are used if you want to draw an indicator or want to have advance calculation line so they are stored in a buffer( a storing region for multiple values) which can be rechecked latter. Then you can always scan the entire buffer with your current price value and if it hits any one value call your alert function. I know currently it will confusing and difficult for you to understand.. please bear with your disappointment..

for(i = limit; i >= 0; i--)
{
if(High[i+1] > LastHigh)
LastHigh = High[i+1];
//----
if(Low[i+1] < LastLow)
LastLow=Low[i+1];
if(TimeDay(Time[i]) != TimeDay(Time[i+1]))
{
P = (LastHigh + LastLow + Close[i+1]) / 3;
R1 = (2*P) - LastLow;
S1 = (2*P) - LastHigh;
R2 = P + (LastHigh - LastLow);
S2 = P - (LastHigh - LastLow);
R3 = (2*P) + (LastHigh - (2*LastLow));
S3 = (2*P) - ((2* LastHigh) - LastLow);

LastLow = Open[i];
LastHigh = Open[i];
//----
ObjectMove("Pivot", 0, Time[i], P);
ObjectMove("Sup1", 0, Time[i], S1);
ObjectMove("Res1", 0, Time[i], R1);
ObjectMove("Sup2", 0, Time[i], S2);
ObjectMove("Res2", 0, Time[i], R2);
ObjectMove("Sup3", 0, Time[i], S3);
ObjectMove("Res3", 0, Time[i], R3);
}
PBuffer[i] = P;
S1Buffer[i] = S1;
R1Buffer[i] = R1;
S2Buffer[i] = S2;
R2Buffer[i] = R2;
S3Buffer[i] = S3;
R3Buffer[i] = R3;
}
 
 
  • Post #16
  • Quote
  • Oct 8, 2016 9:19am Oct 8, 2016 9:19am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Things to consider while writing personal trading rules :
If you have a trading rule its good, if you don't build it partially and work on it until you perfect it.
After trading rule is been made and you seriously want to convert it into any type of automate system, you need to check your rule must at least follow some of these below conditions. The more conditions are match, the easier it will be to convert it into a system.

1. Does your trading rule only follows mathematics (i mean only indicator values) without emotions or does it follow certain pattern, channels, news etc... which contains human emotions ?

If your answer is more inclined towards emotional stuffs then I am sorry emotions cannot be coded accurately and your code will almost fail. In this emotions field human cannot be replaced with code.... an AI is not yet designed to understand our emotions. So make sure your rule contains maximum stuffs which can be proved and calculated mathematically.

2. What is your risk to reward ratio you can accept ?

This may not seems important, but it is. NO risk, NO gain. If you are unaware of your risk to reward ratio then you may find your trading tool much riskier and curse yourself. So make sure you exactly know how much can you risk before you activate certain trading rules. I personally use three level of risk limit. When my first risk limit is reached, my trading method changes to make a profit by taking more risk. On my second risk level I wait and hope it to get better so that i may escape, but when i reach my final risk level, I close my trades and accept defeat. Hope you understand.
So your rule should clearly mention your risk taking criteria.

3. How many indicators or tool that you use and you know about them ?

The more number of indicators you will use, the more unnecessary confusing signals they will generate. Implementing any indicator is very easy, but do you understand how the indicator work or what values the indicator produce... I suggest you should do more research about your indicator properties and nature before using them in your system. This will help exchange of data from one indicator to another easy as you will know what those numbers represent.

Once you are ready with these three answers I will post next on how to draw your automated system flow diagram.
 
 
  • Post #17
  • Quote
  • Oct 8, 2016 9:24am Oct 8, 2016 9:24am
  •  mr.brown
  • Joined Sep 2016 | Status: Its my biz to know what others dont | 1,146 Posts
Quoting D.s
Disliked
No Idea from where to begin with..... Well let me divide EA designing into five main part. 1. First is you need to have your personal trading style. Your EA is just a shadow of you and is build in your own image. 2. Draw out your trading method or flow diagram in a paper so that you will not be confused while designing. 3. Think about how you can divide your trading method into small parts so that we can generate as much code as possible before actually writing it manually. 4. Assemble your small code part as per your flow diagram and turn...
Ignored
couldnt agree more
"1. First is you need to have your personal trading style. Your EA is just a shadow of you and is build in your own image."
 
1
  • Post #18
  • Quote
  • Oct 8, 2016 10:55am Oct 8, 2016 10:55am
  •  dimmerpixel
  • | Joined Mar 2012 | Status: i'm not dead, just a dim one | 38 Posts
i am a windows programmer for over 10 years, here is my opinion:

- there in NO connection between trading strategy and programming
- trading strategy is about your very own style against/following markets
- EA, in the other hand, is about programming, how you talk to a machine, with a programming language, in this case is its you talk to MT4 in MQL language, so its all about LOGIC.

so in my opinion, learn MQL, learn math, sharpen your logic, with that you can build any EA based on your own strategy, or try to build one based on someone else idea

a thousand peoples can have a thousand ideas, no limit at all, but for an EA, your limit is your logic, your very own IQ

have a very good trading strategy, but did not know MQL ---> its ok (soros, buffet, you think they know how to programming?, nope)
master in software programming, but did not have strategy ---> me

see.., the is no connection, i hope someone understand for what i'm talking about

sorry for my English
 
 
  • Post #19
  • Quote
  • Oct 8, 2016 12:26pm Oct 8, 2016 12:26pm
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting dimmerpixel
Disliked
i am a windows programmer for over 10 years, here is my opinion: - there in NO connection between trading strategy and programming - trading strategy is about your very own style against/following markets - EA, in the other hand, is about programming, how you talk to a machine, with a programming language, in this case is its you talk to MT4 in MQL language, so its all about LOGIC. so in my opinion, learn MQL, learn math, sharpen your logic, with that you can build any EA based on your own strategy, or try to build one based on someone else idea...
Ignored
Yup I understood you. Me a programmer too. No offence bro.. But in case of trading, learning just to code will not do any help. its like you know the alphabets but have no idea why a sentence is formed..
Moreover there is no point in coding a EA if you don't know what are you coding for. This happens with lots of people they end up with a automated system which they have created without trading knowledge and at the end they themselves do not trust their own system. So they try to sell it to make profit.

If a person just want to create a automated system without the need of trading with that system, then Forex forum is not the right place. There are many programming forum available, they can easily learn there. I believe people who visit this forum are traders.
 
 
  • Post #20
  • Quote
  • Oct 8, 2016 2:37pm Oct 8, 2016 2:37pm
  •  Thebeard
  • | Joined Sep 2016 | Status: Member | 35 Posts
Hey D.

Great thread.

I Have EA that relies soley on maths/indicator/logic. I have been trying to build it in FxPro Quant builder.

It's drawn as flow chart with inputs, AND/OR logic and indicator values. And as such contains some code.

Now i can get a simple buy on first tick EA to open but when I add other things into the mix it doesn't work.

I don't know what bits of code do what.

How do I arrange all the bits together to form a working EA?

I understand it's a bit vague but I'm hoping this opens up questions so we can get into specifics.

Reason I'm using quant builder is I know more german than coding language and i don't speak german.
 
 
  • Commercial Content
  • /
  • How to Build your EA
  • Reply to Thread
    • Page 1 23456 10
    • Page 1 234 10
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023