Is it possible to code this EA?

 
Is it possible to code an EA that will enter the trade if the EMA line (Green line) goes through a candle stick in a way that the output of the line (Yellow highlight) divides the candle into two parts (A, B), and the length of A must shorter than B.  
plz take a look at the picture below to understand what I say
Files:
dsdsd.JPG  7 kb
 
La Toi: Is it possible to code an EA that will enter the trade if the EMA line (Green line) goes through a candle stick in a way that the output of the line (Yellow highlight) divides the candle into two parts (A, B), and the length of A must shorter than B.  plz take a look at the picture below to understand what I say
Yes!
 
Fernando Carreiro #:
Yes!

oh great! could you give me some ideas what function should I use to call out the yellow highlight

 
  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Book and Documentation
  • Remember also, that you can debug your code with MetaEditor's own debugging functionality.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.
 

The function you mention doesn't tell you anything but more momentum on the short side from period 1, this type of function doesn't identify the start of a trend nor should it. 

If you are treating this as a leading indicator, then your moving average is set to 0, this type of function carries some complexity with trying to predict the range from open to close of the current candle and predicting the end of the current moving average (which gets shifted to 1 at the close), not impossible but carries a huge amount of inaccuracies. 

If you decide that this should be a lagging indicator, I encourage you not to use this solely as a tool for entry as market dynamics aren't dependent on moving averages. Even if you think that the more indicators you try is to validate the entry, then the more liable you are to incur systematic drawdowns that can last for long periods. 

 
Adj007 #:

The function you mention doesn't tell you anything but more momentum on the short side from period 1, this type of function doesn't identify the start of a trend nor should it. 

If you are treating this as a leading indicator, then your moving average is set to 0, this type of function carries some complexity with trying to predict the range from open to close of the current candle and predicting the end of the current moving average (which gets shifted to 1 at the close), not impossible but carries a huge amount of inaccuracies. 

If you decide that this should be a lagging indicator, I encourage you not to use this solely as a tool for entry as market dynamics aren't dependent on moving averages. Even if you think that the more indicators you try is to validate the entry, then the more liable you are to incur systematic drawdowns that can last for long periods. 

Yes, you're totally correct. Fortunately, I know how inaccuracy the indicator could be, so I added some indicators to determine the entry, and these indicators are no problem to code.

However, the thing is I am stuck with the issue of how to call out exactly the value of the outcome tip of the EMA through a candle (the yellow part), I know that you can call out the value of EMA by using iMA function, but with this, it only takes the average value (the centre point of the candle).

 And I know that particular yellow part can fluctuate over time, so I wonder if it is possible to do that or any kind of function can define the value in a specific time, For ex: take the yellow value 10 seconds before the candle closed, and then, all my problems about comparing part A and B can be solved.  

 
La Toi #:

Yes, you're totally correct. Fortunately, I know how inaccuracy the indicator could be, so I added some indicators to determine the entry, and these indicators are no problem to code.

However, the thing is I am stuck with the issue of how to call out exactly the value of the outcome tip of the EMA through a candle (the yellow part), I know that you can call out the value of EMA by using iMA function, but with this, it only takes the average value (the centre point of the candle).

 And I know that particular yellow part can fluctuate over time, so I wonder if it is possible to do that or any kind of function can define the value in a specific time, For ex: take the yellow value 10 seconds before the candle closed, and then, all my problems about comparing part A and B can be solved.  

Okay so you found out how to code the strategy and now want to find the yellow value 10 seconds before a candle close ? You can code a function conditioning the yellow value onto:

Seconds() 

and take it from there ? 

 
Adj007 #:

Okay so you found out how to code the strategy and now want to find the yellow value 10 seconds before a candle close ? You can code a function conditioning the yellow value onto:

and take it from there ? 

Yeah... more like I want to know how to call out the yellow one, about the 10s part, I think I can make it works some how... But hey, thank you so much for the recommendation

Reason: