Hello mql4 community, here is my first EA and i have a few problem with it althought it is very simple. the idea is to open a position when high or low of the previous hour is broken.
Can someone have a look on it and tell me why when backtesting it does not open a trade.
thank in advance
Hi Logan113, I recommend that you study CodersGuru EA to start with. I would foward it to you but I only have the PDF file format and this site will not accept the PDF format. Look for it here https://www.forex-tsd.com/
Hi Logan113, I recommend that you study CodersGuru EA to start with. I would foward it to you but I only have the PDF file format and this site will not accept the PDF format. Look for it here https://www.forex-tsd.com/
ok i'll have a look right now. thank you very much.
Anyone else please??
I can see what is happening.
If you look at the journal output you'll probably see that you are getting error 130 (invalid stops).
The reason is that you have coded the stops in the OrderSend() to be relative values.
These need to be absolute prices so you need to factor the entry price into the calculation.
In other words rather than telling OrderSend() to open a trade with a stop of 50 pips, you need to first calculate what that exit price will be.
It would help if you built into your code some error processing (reporting and handling), not least so we don't have to resort to guesswork to solve your problems.
CB
I can see what is happening.
If you look at the journal output you'll probably see that you are getting error 130 (invalid stops).
The reason is that you have coded the stops in the OrderSend() to be relative values.
These need to be absolute prices so you need to factor the entry price into the calculation.
In other words rather than telling OrderSend() to open a trade with a stop of 50 pips, you need to first calculate what that exit price will be.
It would help if you built into your code some error processing (reporting and handling), not least so we don't have to resort to guesswork to solve your problems.
CB
A great thank to you cloudbreaker, it's not so easy to catch tese kind of mitakes when your a "noob" :) .Do You mean to put getlasterror() for example after each important function?
It would help if you built into your code some error processing (reporting and handling), not least so we don't have to resort to guesswork to solve your problems.
CB
Do You mean to put getlasterror() after each important function? for example after this ordersend()?
thank you again :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello mql4 community, here is my first EA and i have a few problem with it althought it is very simple. the idea is to open a position when high or low of the previous hour is broken.
Can someone have a look on it and tell me why when backtesting it does not open a trade.
thank in advance