What is the index of "previous bar" ?
Alain Verleyen:
What is the index of "previous bar" ?
I have it set to One in the 'Close' array.What is the index of "previous bar" ?
The original post showed it set to zero because I had been playing with the numbers to understand what was happening. Forgot to set it back before posting. Sorry for confusion, I made an edit to correct it.
wayneae #: Any idea why I get this error when trying to compile the MT5 script in this thread. Regards. Wayne
-
Because zero is not one of the ENUM_TRADE_REQUEST_ACTIONS ; exactly what the message says.
-
Because you are calling OrderSend and not checking its return code; exactly what the message says.
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am attempting to create a simple EA that uses only the Close Price of the Previous bar compared to an MA of 'x' periods.
Parameters:
If the Close Price of the Previous bar is Higher than MA, then Buy. Close the trade when the Close Price of the Previous bar is below the MA.
If the Close Price of the Previous bar is Lower than the MA, then Sell. Close the trade when the Close Price of the Previous bar is above the MA.
So far, the Opening and Closing of the Trades is happening at the wrong times. I cannot tell why. I suspect it has something to do with my MA creation.
Any help is appreciated.
Thank you
The following is my code: