• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 8:34pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 8:34pm
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
  •  
  • 1 23Page 456 10
  • 1 3Page 45 10
  •  
  • Post #61
  • Quote
  • Oct 25, 2016 5:50am Oct 25, 2016 5:50am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting lordgbengs
Disliked
{quote} Many thanks for yourresponse, I appreciate. This is how the indicator shows now; {image} Below is what I want to show with the fibo levels label; {image}
Ignored
If the straight light blue lines are the required level you want to draw then its simple. Using the day date and time functions provided by mql4, you just need to know the current candle details and then put your period over it to know the exact candles you need to scan back to calculate your pivot levels. Then on finding the pivot points within that period, you can use the object creating function available with mql4 to draw the lines at that level.

What i don't not understand is significance of the deep blue circle you have drawn.
 
 
  • Post #62
  • Quote
  • Edited 8:46am Oct 25, 2016 8:28am | Edited 8:46am
  •  Kissa
  • | Joined Aug 2012 | Status: Member | 432 Posts
Quoting D.s
Disliked
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.
Ignored
I trade short term, pretty much price orientated, a good trade for me is around 2 hours.
Multiple entries, straight to BE+cost+some_profit.
From there on it is considered a new trade with a different trade management strategy.
Entry to all is by the smallest time frame that is visually readable.

Main strategy.
Trend starts where the buy or sell arrow is, a stop loss takes care of disagreements.

Quote
Disliked
2. Draw out your trading method or flow diagram in a paper so that you will not be
confused while designing.
Quote
Disliked
Things to consider while writing personal trading rules :
Does your trading rule only follows mathematics
Mostly mathematical, the visual patterns I use are translated into math on the fly, as long as the EA does not have axes to fundamental trading forums, all should be good.
Quote
Disliked
What is your risk to reward ratio you can accept ?
For a mechanical system 1:3
Quote
Disliked
How many indicators or tool that you use and you know about them ?
1 visible oscillator and at times candle sticks for the rest I use mathematical data printed on the screen (trying to merge 5 indicators to do this simple task, on a spread sheet it would be just a couple of lines, ie dont have the right indicator No:2 but piking parts from many different indies and that is totally not cool) Also at the moment running 2 separate EA just to collect data + a trade manager EA, so hoping to merge 4 into 1.
Quote
Disliked
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.
Here i need some help before i go further, i have been learning and playing with include and icustom, still need to figure out more about libraries and import from txt/cvs.
As i can only copy paste MQL4 or use visual editors like jForex visual where i can do pretty much anything with the right logic flow (the math is easy just copy paste a working formula from a spread sheet into a math this stuff up module and select send to the next module that needs the result).
Q: if I implement modules for every part of the EA, just "include" everything in say 20 modules will it bog down the computer running it in every tick mode. 4 and5 later.
 
 
  • Post #63
  • Quote
  • Oct 26, 2016 7:03am Oct 26, 2016 7:03am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting Kissa
Disliked
{quote} I trade short term, pretty much price orientated, a good trade for me is around 2 hours. Multiple entries, straight to BE+cost+some_profit. From there on it is considered a new trade with a different trade management strategy. Entry to all is by the smallest time frame that is visually readable. Main strategy. Trend starts where the buy or sell arrow is, a stop loss takes care of disagreements. {quote} {quote} Mostly mathematical, the visual patterns I use are translated into math on the fly, as long as the EA does not have axes to fundamental...
Ignored
Unless you are a high frequency trader, it does not matter much. You may get delayed by few milliseconds, but that not an big issue.
 
 
  • Post #64
  • Quote
  • Oct 26, 2016 3:26pm Oct 26, 2016 3:26pm
  •  lordgbengs
  • Joined Jan 2008 | Status: Member | 632 Posts
Quoting D.s
Disliked
{quote} If the straight light blue lines are the required level you want to draw then its simple. Using the day date and time functions provided by mql4, you just need to know the current candle details and then put your period over it to know the exact candles you need to scan back to calculate your pivot levels. Then on finding the pivot points within that period, you can use the object creating function available with mql4 to draw the lines at that level. What i don't not understand is significance of the deep blue circle you have drawn.
Ignored
The significance of the blue circle is to highlight to youwant i want the indicator to achieve i.e ability to move from period to period.

Chart 1 above is what the indicator currently does

|Chart 2 above is what i want it to do (moving from period to period).

Kindly help
D labour of a fool wearieth him cos he doesn't know how to enta d city
 
 
  • Post #65
  • Quote
  • Oct 27, 2016 3:15am Oct 27, 2016 3:15am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting lordgbengs
Disliked
{quote} The significance of the blue circle is to highlight to youwant i want the indicator to achieve i.e ability to move from period to period. Chart 1 above is what the indicator currently does |Chart 2 above is what i want it to do (moving from period to period). Kindly help
Ignored
Ok understood.
Then just liik into these specific bar related functions https://docs.mql4.com/series
You can use these functions to search for a specific bar at a certain time, or you can shift and count the bars you want to move. What i mean is these default functions already available with mql4 will help you to calculate your pivot levels within your period. For example you can take bar time as 60 min (hourly candles) and number of bars to calculate as 24 and just put your pivot point formula to calculate your desired levels.

1. Run a loop from your beginning candle index position to the last candle(in this case 24) you need to consider.
2. Scan for your required values such as highest point, lowest point and so on using the bar related functions.
3. Put your formula to calculate the levels using those values obtained in step 2.
4. Use any line drawing function to draw lines on your levels calculated with step 3

Thats all. Repeat same process with next set of bars.

If you have coded your mql4 file you have attached previously, then you can easily implement these steps within in. But if the code belong to someone else, then in that case you need to understand the entire code properly, before you can do any modifications in it.
 
 
  • Post #66
  • Quote
  • Oct 27, 2016 2:14pm Oct 27, 2016 2:14pm
  •  Baronial
  • | Joined Jun 2013 | Status: Member | 19 Posts
Hello
I need an EA or script, anyway you think possible.
I want that EA or script follow a already executed trade when ever that trade executed it Execute another trade on same pair with different volume defined by user and close the trade whenever the first trade it follows get close no matter it have TP or SL or manually got closed.
Please look at that matter thanks
 
 
  • Post #67
  • Quote
  • Oct 28, 2016 2:35am Oct 28, 2016 2:35am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting Baronial
Disliked
Hello I need an EA or script, anyway you think possible. I want that EA or script follow a already executed trade when ever that trade executed it Execute another trade on same pair with different volume defined by user and close the trade whenever the first trade it follows get close no matter it have TP or SL or manually got closed. Please look at that matter thanks
Ignored
This can be done. You can create an EA which will scan for all the opened trades magic numbers ( A magic number is something that will help you to identify a trade uniquely). Then you need to provide your own unique magic number to the trades you want to open automatically for the previously opened trade.
An array will help you to map both the open trades magic numbers( one which you open and other which get opened automatically according to the settings).
Now just constantly scan for all the open trades available and make sure the magic numbers are mapped. The moment you find one missing magic number just search your array for the other magic number to which it is mapped and close the trade with that magic number.
This will solve your problem.
The function or code to Open and close trades can be generated using automated EA building tools i have mentioned earlier.
 
1
  • Post #68
  • Quote
  • Oct 28, 2016 10:44am Oct 28, 2016 10:44am
  •  Baronial
  • | Joined Jun 2013 | Status: Member | 19 Posts
Quoting D.s
Disliked
{quote} This can be done. You can create an EA which will scan for all the opened trades magic numbers ( A magic number is something that will help you to identify a trade uniquely). Then you need to provide your own unique magic number to the trades you want to open automatically for the previously opened trade. An array will help you to map both the open trades magic numbers( one which you open and other which get opened automatically according to the settings). Now just constantly scan for all the open trades available and make sure the magic...
Ignored
Hi D.s, Can you help me with the code, I never worked on any EA. please write me the code, Thanks
 
 
  • Post #69
  • Quote
  • Oct 28, 2016 10:47am Oct 28, 2016 10:47am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting Baronial
Disliked
{quote} Hi D.s, Can you help me with the code, I never worked on any EA. please write me the code, Thanks
Ignored
Sorry... I help all in general... I don't write code for any specific person. When you face any specific issue, i can help you resolve. Please use tools i mentioned, you don't need to write code. You can simply select and create your code
 
1
  • Post #70
  • Quote
  • Oct 28, 2016 3:07pm Oct 28, 2016 3:07pm
  •  Bk55
  • | Joined Jun 2016 | Status: Member | 2,646 Posts
Hi Ds

I use a 2 ma cross with arows and alerts ea, I would like to add buy and sell option to this ea a buy on bullish arrow and sell on bearish.
how difficult would that be ?
Turn your wounds into wisdom
 
 
  • Post #71
  • Quote
  • Oct 29, 2016 12:20am Oct 29, 2016 12:20am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting Bk55
Disliked
Hi Ds I use a 2 ma cross with arows and alerts ea, I would like to add buy and sell option to this ea a buy on bullish arrow and sell on bearish. how difficult would that be ?
Ignored
Its the most easiest thing you can do. Just create or generate two functions one to open trade and another to close trade. Open trade function which take input as the lot amount and (buy or sell) and just call the function the moment new arrow is generated. same time close trade will just close all opened trade available.

On a new arrow or after an alert is displayed( only if you get alert every time a new arrow is formed), First call the close trade function to close any old open trade with that pair. then call the open trade function. This will do it all.

Approximately 10-15 lines of code will do all your task.
 
 
  • Post #72
  • Quote
  • Oct 31, 2016 3:42pm Oct 31, 2016 3:42pm
  •  Baronial
  • | Joined Jun 2013 | Status: Member | 19 Posts
Hi D.s, I am trying to make an EA on FxPro Quant just as you recommended here I am to achieve that EA scan previous trades or already running trades or whenever any trade get execute it Execute another trade on same pair with different volume defined by user and close the trade as soon as the first trade get close no matter it have TP or SL or manually got closed.

But after many tries this EA don't anything I definitely doing something wrong or missing something please guide me.
Thanks
Attached Image (click to enlarge)
Click to Enlarge

Name: Capture.PNG
Size: 10 KB
 
 
  • Post #73
  • Quote
  • Nov 1, 2016 6:38am Nov 1, 2016 6:38am
  •  Bk55
  • | Joined Jun 2016 | Status: Member | 2,646 Posts
Quoting D.s
Disliked
{quote} Its the most easiest thing you can do. Just create or generate two functions one to open trade and another to close trade. Open trade function which take input as the lot amount and (buy or sell) and just call the function the moment new arrow is generated. same time close trade will just close all opened trade available. On a new arrow or after an alert is displayed( only if you get alert every time a new arrow is formed), First call the close trade function to close any old open trade with that pair. then call the open trade function....
Ignored
Thanks D.s


appreciate the help
Turn your wounds into wisdom
 
 
  • Post #74
  • Quote
  • Nov 1, 2016 7:11am Nov 1, 2016 7:11am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting Baronial
Disliked
Hi D.s, I am trying to make an EA on FxPro Quant just as you recommended here I am to achieve that EA scan previous trades or already running trades or whenever any trade get execute it Execute another trade on same pair with different volume defined by user and close the trade as soon as the first trade get close no matter it have TP or SL or manually got closed. But after many tries this EA don't anything I definitely doing something wrong or missing something please guide me. Thanks {image}
Ignored
Wonderful... You are trying. Seems you have missed crucial parts. First you need to search for old information. Then ccheck the old information to be a buy order or sell order as order status and status 2. On accurately identifying your old order you can generate new magic index and open a new position(buy or sell) as required and same time close other positions as required.

Below snapshot is just an example for you to understand.
Watch a video in youtube about using the tool you chose or switch to any better tool, i have mentioned few more, and you will be doing fine.
Attached Image
 
1
  • Post #75
  • Quote
  • Nov 1, 2016 7:56am Nov 1, 2016 7:56am
  •  Baronial
  • | Joined Jun 2013 | Status: Member | 19 Posts
Quoting D.s
Disliked
{quote} Wonderful... You are trying. Seems you have missed crucial parts. First you need to search for old information. Then ccheck the old information to be a buy order or sell order as order status and status 2. On accurately identifying your old order you can generate new magic index and open a new position(buy or sell) as required and same time close other positions as required. Below snapshot is just an example for you to understand. Watch a video in youtube about using the tool you chose or switch to any better tool, i have mentioned few more,...
Ignored
I am happy to see your feedback D.s you really helping people here, Today I started to Learn MQL4 programming on MQL editor but I want to know from your own Experience that as MQL language base on C++ do I first need to learn C++ programming or just start learning MQL to build a good EA?
 
 
  • Post #76
  • Quote
  • Nov 1, 2016 8:40am Nov 1, 2016 8:40am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting Baronial
Disliked
{quote} I am happy to see your feedback D.s you really helping people here, Today I started to Learn MQL4 programming on MQL editor but I want to know from your own Experience that as MQL language base on C++ do I first need to learn C++ programming or just start learning MQL to build a good EA?
Ignored
Not C++, its more like Java. But you don't have to learn any other language, just Mql4 is enough. Though I have knowledge of most common programming language available but when i started MQL4, i found the help button (F2 key in editor) available provides everything i need to know. Just google about your issue, know the function name which have the potential to solve your problem then open help and you can see the programming help with example for that function. Then just apply and see what it does. Its fun. Many time when i need complex programs i generate partially using any tool available and try to modify generated code according to my need.

So learning other language is not required.
 
1
  • Post #77
  • Quote
  • Nov 1, 2016 9:20am Nov 1, 2016 9:20am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Describing details of one of the function as my post series started long back.

From all the required functions to generate an EA , let me describe code in the function OPEN_TRADE() function which generates a buy or sell order when used.
Code below:
int OPEN_TRADE(double lot,double Dir) // Comment: Dir as 1 means buy and 2 as sell
{
int n;
Refresh();
if(Dir==1)
{
n= OrderSend(Symbol_Name,OP_BUY,lot,Ask_Price,5,0.0,0.0,Symbol_Name,Magic,0,clrGreen);
}
else
{
n= OrderSend(Symbol_Name,OP_SELL,lot,Bid_Price,5,0.0,0.0,Symbol_Name,Magic,0,clrRed);
}
return n;
}
---------------------------------------------------------------
Its bit confusing so let me describe each lines
int - is the return type of the function means the function will return a integer value after execution
OPEN_TRADE - is the exact function name i want
double - it means the number can have decimal value
lot - its the variable which will store the lot size while the function is called
Dir - Its self made, instead of writing buy or sell i assume 1 means buy and 2 means sell so i easily store buy or sell in Dir
n - it is also a variable which will store integer number as required
Refresh(); - Its a different function which update me with latest bid and ask price and other values which change often. so i called it during crucial moment before opening new trade.

if(Dir==1) - it just means if I want to buy or open a buy order
n= OrderSend(Symbol_Name,OP_BUY,lot,Ask_Price,5,0.0,0.0,Symbol_Name,Magic,0,clrGreen); - the OrderSend is a function provided by MQL4 to open a order so i provided it with the data i want to use to open a order. and after opening an order it will return a decimal number which tells us about order opened successfully or failed and will be stored in n
OP_BUY - means a buy order
OP_SELL - means sell order
return n; - it basically return me the success or fail number if i need yto do anything with it.

And basically that's all. You learned about a very crucial function. I generated using tools mentioned and just modified it slightly according to mu need. Actually buy and sell function are generated separately so after generating i just merged then as required.

Let me know your doubts and check out the tools available at the beginning which can help you.

Next post i will describe about assembling your partial generated or designed code to form the complete EA
 
 
  • Post #78
  • Quote
  • Nov 1, 2016 11:40am Nov 1, 2016 11:40am
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Hay Guys... Look I saw you trying you best and learning and growing... that's great i love your enthusiasm , but I find few of you are getting frustrated and struggling. So I took all my useful functions required to setup an EA from my files and created a library like a template and provided a link to it it in the first post.
The code contained are all the important necessary functions required for an EA. If interested you can download it.
You can use the code while building your EA and I guarantee you it will save a lot of your time. Let me know what you think.

Starting post contain the code download link. Interested persons can download.
 
 
  • Post #79
  • Quote
  • Nov 1, 2016 2:37pm Nov 1, 2016 2:37pm
  •  fegeme
  • | Joined Feb 2013 | Status: Member | 50 Posts
Quoting D.s
Disliked
Describing details of one of the function as my post series started long back. From all the required functions to generate an EA , let me describe code in the function OPEN_TRADE() function which generates a buy or sell order when used. Code below: int OPEN_TRADE(double lot,double Dir) // Comment: Dir as 1 means buy and 2 as sell { int n; Refresh(); if(Dir==1) { n= OrderSend(Symbol_Name,OP_BUY,lot,Ask_Price,5,0.0,0.0,Symbol_Name,Magic,0,clrGreen); } else { n= OrderSend(Symbol_Name,OP_SELL,lot,Bid_Price,5,0.0,0.0,Symbol_Name,Magic,0,clrRed); } return...
Ignored
Is the procedure for pending "buy stop" and "sell stop" orders the same as for the "sell market" and "buy market" orders?
 
 
  • Post #80
  • Quote
  • Nov 1, 2016 10:35pm Nov 1, 2016 10:35pm
  •  D.s
  • | Commercial Member | Joined Jul 2016 | 252 Posts
Quoting fegeme
Disliked
{quote} Is the procedure for pending "buy stop" and "sell stop" orders the same as for the "sell market" and "buy market" orders?
Ignored
 
Yes it is same you just need to change the OP_BUY and OP_SELL.
 
 
  • Commercial Content
  • /
  • How to Build your EA
  • Reply to Thread
    • 1 23Page 456 10
    • 1 3Page 45 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