Simple EA problem

 

Hello


I'm trying to write a simple EA using the RSI.


The EA should buy whenever RSI is under 45 and sell when it's over 55. The EA also should close open long position when RSI is over 55, and close an open short position when RSI is under 45.


Simple enough! I'm just trying to learn how to code from the book by "S. Kovalyov" along with some other articles on mql4.com. So I decided to make a first EA. I copied the structure of the MACD Sample EA.


When I attach it to the chart it doesn't trade correctly (how I wanted it to) on an ODL demo account it doesn't open any orders. On an Metaquotes demo it does make the first trade buy it doesn't close the trade until the TP or the SL is hit.


Any Help would be greatly appreciated, books tell you a lot but sometimes I can't find the info.


Any links to good MQL4 learning sites would be helpful as well.

Files:
rsi.mq4  4 kb
 

Any links to good MQL4 learning sites would be helpful as well.

Reason: