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

Back to topics list To post a new topic, please log in or register
avatar
1
polamin 2015.06.19 08:34
 

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. 

avatar
Moderator
3206
angevoyageur 2015.06.19 12:10 #
 

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.

avatar
120
DeanDeV 2015.06.19 15:14 #
 
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.
avatar
12992
WHRoeder 2015.06.19 15:49 #
 
  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
Back to topics list  

To add comments, please log in or register