A question to get some guidance creating my EA in MT4

 

Hey guys, I have a question before starting to create my EA. I have taken some MQL4 coding courses and they have proven to be insightful and helpful in understanding some of the basics of learning to start coding my own EA. What I need is an EA that automatically draws/identifies channels, and then takes a trade when it hits either side of the channel for 10 pips. I would like to do it myself if I can.


Could anyone tell me how I need to go about starting to code this type of EA? All help is appreciated!

 
tyfred:

Hey guys, I have a question before starting to create my EA. I have taken some MQL4 coding courses and they have proven to be insightful and helpful in understanding some of the basics of learning to start coding my own EA. What I need is an EA that automatically draws/identifies channels, and then takes a trade when it hits either side of the channel for 10 pips. I would like to do it myself if I can.


Could anyone tell me how I need to go about starting to code this type of EA? All help is appreciated!

Hi

I wouldn't answer this question because I never worked on channels, But As nobody answered you yet, I will try to help.

Hopefully professionals will add some better comments.

After you found the points you want to draw the channel based on, you can use use the OBJ_CHANNEL in ObjectCreate function to draw a channel.

Or you can  draw two OBJ_TREND (2 Trend lines ) to make the channel.

As I told you I didn't work on the channels, But if you use 2 trend lines (which are slanted lines), every point of the line has a double value which is the price of that point.

(Not exactly each point, but each point of the line that vertically is int the same place with one of the candles).

You can get the value of the trend line on the current bar and if the price passed it as much as you want then go for buy or sell. 
For Example if price >= value of higher trend line + 100*Point then Buy.

But, I think you don't need to go with the trend lines and high probability the OB_CHANNEL also will give you the value.

You also need to avoid the EA to repeat opening the positions when it takes a trade.

If you want to have just one open trade at time, you can make a function to count the trades you have on this symbol & magic number and then in your main conditions you can check it, if it is equal to zero then go for checking the other conditions.

Hope it can help you 
 

ObjectCreate - Object Functions - MQL4 Reference
ObjectCreate - Object Functions - MQL4 Reference
  • docs.mql4.com
The function creates an object with the specified name, type, and the initial coordinates in the specified chart subwindow of the specified chart. There are two variants of the function: [in]  Number of the chart subwindow. 0 means the main chart window. The specified subwindow must exist (window index must be greater or equal to 0 and less...
 

You can get the value of the trend line on the current bar and if the price passed it as much as you want then go for buy or sell. 

 

Or You may check the Bar 1 to make sure that the candle is closed after the price you want

Reason: