Download MetaTrader 5
To add comments, please log in or register
All activity of the MQL5.community members is displayed on a single page!
polamin singhasuwich
9
polamin singhasuwich 2015.06.19 06: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. 

Alain Verleyen
Moderator
28522
Alain Verleyen 2015.06.19 10: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.

DeanDeV
330
DeanDeV 2015.06.19 13: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.
whroeder1
13596
whroeder1 2015.06.19 13: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
/
To add comments, please log in or register