how put one order if have signal - page 2

 
phipho:
Can you do for example about ErrorDescription ()  because i don't know how to write this 

Nope,  I would suggest that you don't use it . . ..  print the error number instead,  that way there is no possible misunderstanding about what the error is . . .

Now,  perhaps you might be good enough to answer my first question,  in post #2 of this thread . . .  if you do it will help you. 

 
RaptorUK:
Rõ ràng là bạn không có ErrorDescription () chức năng xác định. . . 

Can you do for example about ErrorDescription ()  because i don't know how to write this 

Read my comment again https://www.mql5.com/en/forum/142547 
 
i'm trying find mistake but i can't
 
i add fllow you Phi.nuts. but It still have a lot of order
//+------------------------------------------------------------------+
//|                                              phiiiiiiiiiiiii.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property link      "http://www.metaquotes.net"

#include <stdlib.mqh>
//--------------tham so dau vao
extern double MovingPeriod       = 100;
extern double MovingShift        = 0;
extern double MovingPeriod1       = 50;
extern double MovingShift1        = 0;
extern double Lots = 0.1;
extern double TakeProfit = 20;
extern double StopLoss = 30;
extern double TrailingStop = 50;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  double ma ;
   double ma1 ;
  int cnt, ticket, total;
//-------- get duong trung binh 
   ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_EMA,PRICE_CLOSE,0);
   ma1=iMA(NULL,0,MovingPeriod1,MovingShift1,MODE_EMA,PRICE_CLOSE,0);
//+------------------------------------------------------------------+
//| dieu kien Sell                              
//+------------------------------------------------------------------+
   if ( ma1 < ma )
   { 
   ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, Ask + StopLoss*Point, 
                               Bid - TakeProfit*Point, "adx sample", 16384, 0, Red);
   if (ticket < 0)    // -1 is returned on error . . . < -1 will never happen 
   {
   Print ("Order Send error : ",ErrorDescription(GetLastError()));
   }
    return(0); }
                               
   
   
  //+------------------------------------------------------------------+
//| dieu kien BUY                          
//+------------------------------------------------------------------+
 if ( ma1  > ma )
 {
 ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, Bid - StopLoss*Point, 
                               Ask + TakeProfit*Point, "adx sample", 16384, 0, Green);
                               if (ticket < 0)    // -1 is returned on error . . . < -1 will never happen 
   {
   Print ("Order Send error : ",ErrorDescription(GetLastError()));
   }
  return(0) ; 
  }


//----
   return(0);
  }
//+------------------------------------------------------------------+
 
hiccccc
 
RaptorUK:

Now,  perhaps you might be good enough to answer my first question,  in post #2 of this thread . . .  if you do it will help you. 

Yes ?
 
phipho:
i add fllow you Phi.nuts. but It still have a lot of order

Yes. There are 2 problems that causing that :

1. The EA did not count the trade - how mant trade the EA should open or how many trade already opened.

2. The EA open position based on one MA above (or below) the other MA. In other words : The EA should not open when one MA above (or below) the other.

We will discuss the number 1 later. Right now we discuss the number 2 : The EA should not open when one MA above (or below) the other. So the question is, when should the EA should open the trade ? To answer this, why don't you attach 2 MA with different periods on a chart and imagine that you are the EA riding that 2 MA

Can you solve it ? 

Here's help : WHRoeder already answered that on page 1. 

 
phipho:
hiccccc

I see that you are banned from mql5.com. Well, mql5.com is for mql5 code, mql4.com is for mql4 code.

And I see that you're not writing the code yourself, you just copy paste from your old topic https://www.mql5.com/en/forum/142274 

 
phi.nuts:

I see that you are banned from mql5.com. Well, mql5.com is for mql5 code, mql4.com is for mql4 code.

And I see that you're not writing the code yourself, you just copy paste from your old topic https://www.mql5.com/en/forum/142274 

Just like 90% of people that come here asking for help  ;-)
 
because i'm new guy learn write code mql4. I must learn write a easy EA.