Download MetaTrader 5

This is my first EA and I don't know why it not send an order

To add comments, please log in or register
polamin singhasuwich
9
polamin singhasuwich  

Hi everyone,

This is my first post about my first Ea.

These code modified from "Moving Average.mql4" default file from Metatrader4. 

   double rsi;
   double lastRSI;
   int    res;
//--- go trading only for first tiks of new bar
   if(Volume[0]>1) return;
//--- get Moving Average 
   rsi     = iRSI(NULL,0,MovingPeriod,PRICE_CLOSE,0);
   lastRSI = iRSI(NULL,0,MovingPeriod,PRICE_CLOSE,1);
if(rsi <= 30 && lastRSI > 30)
     {
      res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Open[0] - StopLoss,0,"",MAGICMA,0,Blue);
      Alert("OPEN BUY" ,Open[0]);
      return;
     }

 

In backtest it works fine but when doing real trade it doesn't work.

I did tick the "Allow automated trading" and  "Allow live trading" and Smiley face on the screen.

Alert doesn't even show up when RSI goes below 30 now I'm really confusing. 

Alain Verleyen
Moderator
31203
Alain Verleyen  

In backtest it works fine but when doing real trade it doesn't work.

"Doesn't work" is not really helpful. Check your log. Give more information.

DeanDeV
330
DeanDeV  
polamin:

Hi everyone,

This is my first post about my first Ea.

These code modified from "Moving Average.mql4" default file from Metatrader4. 

 

In backtest it works fine but when doing real trade it doesn't work.

I did tick the "Allow automated trading" and  "Allow live trading" and Smiley face on the screen.

Alert doesn't even show up when RSI goes below 30 now I'm really confusing. 

if(rsi <= 30 && lastRSI > 30)
     {
      res=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Open[0] - StopLoss,0,"",MAGICMA,0,Blue);
      if(res<0) Print();
      Alert("OPEN BUY" ,Open[0]);
      return;
     }
Use print function to get error codes. Only then can we help you.
whroeder1
14785
whroeder1  
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. Check your return codes (OrderSend) and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
To add comments, please log in or register