Download MetaTrader 5
To add comments, please log in or register
Have you developed a profitable strategy? Launch your trading signal and make profit from it!
duplan
5
duplan 2014.07.25 23:26 

Hi !

I am glad to adress all of you.

I have an issue with my MT4 platform.

I've programmed an EA. and tested it. But it never opened any position.

I though first  it was , maybe, my conditions were too tight, that's why I've tried to run an other EA. A very simple one I knew ( because I saw it in action on youtube), and here, my platform didn't opened any position either.

So, now imagine how confusd I am ! :D

Could you test my EA for me ? Just in order to know if my EA sucks, or if I don't know how to use my platform. ( I precise, I 've doubts about that, because I've tryed other EA years ago on an other computer). (but I am very willing to receive advices...)

( I've learn programmation by myself, and it is very hard , when isolated, to receive backup and increase competences in any field of knowledge, it takes longer time to solve problem).


Here is the code.

//+------------------------------------------------------------------+
//|                                                  fxeabuilder.mq4 |
//|                                                      fxeabuilder |
//|                                       http://www.fxeabuilder.com |
//+------------------------------------------------------------------+

#property copyright "fxeabuilder.com"
#property link "www.fxeabuilder.com"

// External variables
extern double LotSize = 1;
extern double StopLoss = 600;
extern double TakeProfit = 5000;
extern double TrailingStopLimit = 30;
extern double TrailingStopStop = 30;
extern int MagicNumber = 23310;


// Global variables
int LongTicket;
int ShortTicket;
double RealPoint;



// Init function
int init()
        {
      RealPoint = RealPipPoint(Symbol());
     
        }


// Start function
int start()
        {
        //Variables
        
                
                // Long
                
                OrderSelect(LongTicket,SELECT_BY_TICKET);
                
                
                if(OrderCloseTime() != 0 || LongTicket == 0)
                {
                
                    
bool buy_condition_1 = iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 1)  < iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 0)   ;
bool buy_condition_2 = iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 0)  >  50  ;
bool buy_condition_3 = iMA(NULL, PERIOD_H4, 18, 1, MODE_SMA, PRICE_CLOSE, 1)  < iMA(NULL, PERIOD_H4, 9, 1, MODE_SMMA, PRICE_CLOSE, 1)  ;


                                 
                if( buy_condition_1  &&  buy_condition_2  &&  buy_condition_3   )
                        {
                                
                                OrderSelect(ShortTicket,SELECT_BY_TICKET);
                                
                                if(OrderCloseTime() == 0 && ShortTicket > 0)
                                        {
                                                                                        
                                                bool Closed = OrderClose(ShortTicket,OrderLots(),Ask,0,Red);
                                        }                               

                                
                                
                                
                                
                                LongTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,"Buy Order",MagicNumber,0,Green);
                                
                                
                                OrderSelect(LongTicket,SELECT_BY_TICKET); 
                                double OpenPrice = OrderOpenPrice();
                                
            
             
            if(StopLoss > 0) double LongStopLoss = OpenPrice - (StopLoss * RealPoint);
            if(TakeProfit > 0) double LongTakeProfit = OpenPrice + (TakeProfit * RealPoint);
            
            
                                if(LongStopLoss > 0 || LongTakeProfit > 0) 
                                {
               bool LongMod = OrderModify(LongTicket,OpenPrice,LongStopLoss, LongTakeProfit,0);
                                }
                                
                                                        
                                ShortTicket = 0;
                        }
                
                }
                                
                //Close long
      if (OrdersTotal() > 0)
                {              
                
                    
                
                    
                    
bool close_buy_condition_1 = iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 0)  >=  70  ;
bool close_buy_condition_2 = iRSI(NULL, PERIOD_H4, 21, PRICE_OPEN, 0)  <=  50  ;
bool close_buy_condition_3 = iMA(NULL, PERIOD_H4, 18, 1, MODE_SMA, PRICE_CLOSE, 0)  > iMA(NULL, PERIOD_H4, 9, 1, MODE_SMMA, PRICE_CLOSE, 0)  ;

                    
                
                 if( close_buy_condition_1  ||  close_buy_condition_2  ||  close_buy_condition_3   )
                        {
                                OrderSelect(LongTicket,SELECT_BY_TICKET);
                
                                if(OrderCloseTime() == 0 && LongTicket > 0)
                                        {

                                                Closed = OrderClose(LongTicket,OrderLots(),Bid,0,Red);
                                                
                                                
                                                LongTicket = 0;
                                        }               
                    }
                }
                               
                
                // Short
                
                OrderSelect(ShortTicket,SELECT_BY_TICKET);
                if(OrderCloseTime() != 0 || ShortTicket == 0)
                {
                 
                
                                    
bool sell_condition_1 = iMA(NULL, PERIOD_H4, 18, 1, MODE_SMA, PRICE_CLOSE, 1)  > iMA(NULL, PERIOD_H4, 9, 1, MODE_SMMA, PRICE_CLOSE, 1)   ;
bool sell_condition_2 = iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 0)  > iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 1)   ;
bool sell_condition_3 = iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 0)  <=  50 ;
  
                                    
                if( sell_condition_1  &&  sell_condition_2  &&  sell_condition_3   )
                        {
                           
                                OrderSelect(LongTicket,SELECT_BY_TICKET);
                
                                if(OrderCloseTime() == 0 && LongTicket > 0)
                                        {

                                                Closed = OrderClose(LongTicket,OrderLots(),Bid,0,Red);
                                        }               
                                
                                
                                
                                
                                
                                ShortTicket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,"Sell Order",MagicNumber,0,Red);
                                
                                OrderSelect(ShortTicket,SELECT_BY_TICKET); 
                                OpenPrice = OrderOpenPrice();
                                
            
            
            if(StopLoss > 0) double ShortStopLoss = OpenPrice + (StopLoss * RealPoint);
            if(TakeProfit > 0) double ShortTakeProfit = OpenPrice - (TakeProfit * RealPoint);
            
                                if(ShortStopLoss > 0 || ShortTakeProfit > 0) 
                                {
               bool ShortMod = OrderModify(ShortTicket,OpenPrice,ShortStopLoss, ShortTakeProfit,0);
                                }
                                
                                                                
                                LongTicket = 0;
                        }
                
                
                }
                             

                
                 //Close Short
                 if (OrdersTotal() > 0)
                {
                 
                 
                                     
bool close_sell_condition_1 = iMA(NULL, PERIOD_H4, 18, 0, MODE_SMA, PRICE_CLOSE, 1)  > iMA(NULL, PERIOD_H4, 9, 1, MODE_SMMA, PRICE_CLOSE, 1)   ;
bool close_sell_condition_2 = iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 0)  <=  30  ;
bool close_sell_condition_3 = iRSI(NULL, PERIOD_H4, 21, PRICE_CLOSE, 0)  >=  50 ;

                 
                 if( close_sell_condition_1  ||  close_sell_condition_2  ||  close_sell_condition_3   )
                        {
                                OrderSelect(ShortTicket,SELECT_BY_TICKET);
                
                                if(OrderCloseTime() == 0 && ShortTicket > 0)
                                        {

                                                Closed = OrderClose(ShortTicket,OrderLots(),Ask,0,Red);
                                                
                                                
                                                ShortTicket = 0;
                                        }               
                        }
                }
       
                
                
if (TrailingStopLimit > 0 && TrailingStopStop > 0)
         {
                     double TrailingStopLimitReal = TrailingStopLimit * RealPoint;
                     double TrailingStopStopReal = TrailingStopStop * RealPoint;
                     
                     OrderSelect(LongTicket, SELECT_BY_TICKET);             
                     if (OrderType() == OP_BUY && OrderCloseTime() == 0)
                        {
                           
                           if(Bid - OrderOpenPrice() > TrailingStopLimitReal) 
                              {

                                 if(OrderStopLoss() < Bid - (TrailingStopLimitReal * 2)) 
                                    {
                                       double LongTrailingStopLoss = OrderStopLoss() + TrailingStopStopReal;
                                       OrderModify(OrderTicket(), OrderOpenPrice(), LongTrailingStopLoss, OrderTakeProfit(), 0, MediumSeaGreen);        
                                    }
                              }
                        }
                        
                     OrderSelect(ShortTicket, SELECT_BY_TICKET);   
                     if (OrderType() == OP_SELL && OrderCloseTime() == 0)
                         {
                           
                           if(OrderOpenPrice()- Ask > TrailingStopLimitReal) 
                              {

                                 if(OrderStopLoss() > Ask + (TrailingStopLimitReal * 2)) 
                                    {
                                       double ShortTrailingStopLoss = OrderStopLoss() - TrailingStopStopReal;
                                       OrderModify(OrderTicket(), OrderOpenPrice(), ShortTrailingStopLoss, OrderTakeProfit(), 0, MediumSeaGreen);       
                                    }
                              }
                          }     
                        
                
                }               
                
                return(0);
        }


// Pip Point Function
double RealPipPoint(string Currency)
        {
                int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
                if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
                else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
                return(CalcPoint);
        }
        
Files:
whroeder1
13641
whroeder1 2014.07.26 00:41  
  1. OrderSelect(LongTicket,SELECT_BY_TICKET);
    if(OrderCloseTime() != 0 || LongTicket == 0)
    
    OrderSelect fails, If statement is unknown. What are Function return values ? How do I use them ? - MQL4 forum
  2. #property link "www.fxeabuilder.com"
    
    1. We hate EA builder
    2. You couldn't be bothered to learn mql4, therefor there is no common language for us to communicate.
    3. There are only two choices: learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem, but we are not going to debug your hundreds lines of code.
    4. EA builder makes bad code counting up while closing multiple orders.
    5. EA builder makes bad code Bars is unreliable (max bars on chart) volume is unreliable (miss ticks) Always use time
    6. EA builder makes bad code Not adjusting for 4/5 digit brokers
    7. EA builder makes bad code not adjusting for ECN brokers.
    8. EA builder makes bad code not checking return codes. See #1
/
To add comments, please log in or register