What's wrong with my first EA?

 

It doesn't want to buy. Expert Advisors/Allow Trading are enabled, smiley on the top, seems ok.

Please help, thanks

Files:
rsiea.mq4  1 kb
 

What error do you get ? does RSI1 ever equal 30 ? not over or under but exactly equal to 30 ?

Did you mean to set your SL at 30.0 ? not 30 pips below Ask, you have set it to 30.0

Also . . . you don't close a BUY at Ask, Buy at Ask, Sell at Bid . . . a BUY order is closed by Selling . . . at Bid.

 
RaptorUK:

What error do you get ? does RSI1 ever equal 30 ? not over or under but exactly equal to 30 ?

Did you mean to set your SL at 30.0 ? not 30 pips below Ask, you have set it to 30.0

Also . . . you don't close a BUY at Ask, Buy at Ask, Sell at Bid . . . a BUY order is closed by Selling . . . at Bid.

What he said ... plus

The OrderClose is using the Magic Number not the ticket number. You have the ticket number as ticket, but it needs to be held globally, not as a local variable, or the start function will forget its value between ticks.

To emphasize the comment about RSI==30. A double is unlikely to equal an int. Think how many values are close to 30 but not 30. Imagine two digits of precision so you have 30.00, 30.01, 30.02, 30.03 etc. Now consider 8 digits and you will see its pretty unlikely that 30.0000000 will ever be reached. You could try MathRound on the RSI but my feeling is you need a larger band (eg 28 < RSI < 32 )