Download MetaTrader 5

develop an EA using pending orders according to the position on the screen.

To add comments, please log in or register
soleteluna
131
soleteluna  

Good afternoon,

I would like to develop an EA using pending orders according to the position of objects on the screen. Is there any article in the forum is a demonstration of how to do it? thanks

Anthony

 Buenas tardes,

me gustaría desarrollar un EA mediante ordenes pendientes según la posición de objetos en la pantalla. ¿Existe algún artículo en el foro que halla alguna demostración de como hacerlo? Gracias

Antonio

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
onewithzachy
2271
onewithzachy  
soleteluna:

Good afternoon,

I would like to develop an EA using pending orders according to the position of objects on the screen. Is there any article in the forum is a demonstration of how to do it? thanks

Anthony

 Buenas tardes,

me gustaría desarrollar un EA mediante ordenes pendientes según la posición de objetos en la pantalla. ¿Existe algún artículo en el foro que halla alguna demostración de como hacerlo? Gracias

Antonio

Hi soleteluna,

Where does this object come from anyway ?

Use for loop to iterate though Object list and use  Object Function's ObjectGetDouble() function with ENUM_OBJECT_PROPERTY_DOUBLE's OBJPROP_PRICE like this

  string My_Object_Name;
  double Open_Price;
  
  for (int pos = ObjectsTotal(0) - 1; pos >= 0; pos --)
    {
    if (ObjectName (0, pos) == My_Object_Name)
       {
       Open_Price =  ObjectGetDouble(0, My_Object_Name, OBJPROP_PRICE);
       break;
       }
    }
  
  //   Use open price to open your pending orders

Compiled, not tested.

:D 

Moses Olawale  Ajayi
2398
Moses Olawale Ajayi  
onewithzachy:

Hi soleteluna,

Where does this object come from anyway ?

Use for loop to iterate though Object list and use  Object Function's ObjectGetDouble() function with ENUM_OBJECT_PROPERTY_DOUBLE's OBJPROP_PRICE like this

Compiled, not tested.

:D 

Hi onewithzachy:, your comment realy help me more.

Thanks

Tri Noviantoro
983
Tri Noviantoro  

i had scripts for drop pending order in mt4 version.

#property show_inputs
//#property show_confirm

extern double Lots    = 0.1;
extern int Slippage   = 3;
extern int Stop_Loss  = 2000;
extern int Take_Profit = 20;

//+------------------------------------------------------------------+
//| script "Open a new Buy Order"                                    |
//+------------------------------------------------------------------+
int start()
  {
   double Price = WindowPriceOnDropped();
   bool   result;
   int    cmd,total,error,slippage;
   int et = TimeCurrent()+(PERIOD_D1)*40;
//----
   int NrOfDigits = MarketInfo(Symbol(),MODE_DIGITS);   // Nr. of decimals used by Symbol
   int PipAdjust;                                       // Pips multiplier for value adjustment
      if(NrOfDigits == 5 || NrOfDigits == 3)            // If decimals = 5 or 3
         PipAdjust = 10;                                // Multiply pips by 10
         else
      if(NrOfDigits == 4 || NrOfDigits == 2)            // If digits = 4 or 3 (normal)
         PipAdjust = 1;            
//----   
   
   slippage = Slippage * PipAdjust;
   string waktu= CharToStr(Day());
   double stop_loss = Price - Stop_Loss * Point * PipAdjust;
   double take_profit = Price + Take_Profit * Point * PipAdjust;
   
   if(Ask > Price)
   {
   result = OrderSend(Symbol(),OP_BUYLIMIT,Lots,Price,slippage,stop_loss,take_profit,"DX",0,et,CLR_NONE);
   }
   if(Ask < Price)
   {
   result = OrderSend(Symbol(),OP_BUYSTOP,Lots,Price,slippage,stop_loss,take_profit,"DX",0,et,CLR_NONE);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+



#property show_inputs
//#property show_confirm

extern double Lots    = 0.1;
extern int Slippage   = 3;
extern int Stop_Loss  = 2000;
extern int Take_Profit = 20;

//+------------------------------------------------------------------+
//| script "Open a new Sell Order"                                    |
//+------------------------------------------------------------------+
int start()
  {
   double Price = WindowPriceOnDropped();
   bool   result;
   int    cmd,total,error,slippage;
   int et = TimeCurrent()+(PERIOD_D1)*40;
//----
   int NrOfDigits = MarketInfo(Symbol(),MODE_DIGITS);   // Nr. of decimals used by Symbol
   int PipAdjust;                                       // Pips multiplier for value adjustment
      if(NrOfDigits == 5 || NrOfDigits == 3)            // If decimals = 5 or 3
         PipAdjust = 10;                                // Multiply pips by 10
         else
      if(NrOfDigits == 4 || NrOfDigits == 2)            // If digits = 4 or 3 (normal)
         PipAdjust = 1;           
//----  
  
   slippage = Slippage * PipAdjust;
   string waktu= CharToStr(Day());
   double stop_loss = Price + Stop_Loss * Point * PipAdjust;
   double take_profit = Price - Take_Profit * Point * PipAdjust;
  
   if(Bid > Price)
   {
   result = OrderSend(Symbol(),OP_SELLSTOP,Lots,Price,slippage,stop_loss,take_profit,"DX",0,et,CLR_NONE);
  
   }
   if(Bid < Price)
   {
   result = OrderSend(Symbol(),OP_SELLLIMIT,Lots,Price,slippage,stop_loss,take_profit,"DX",0,et,CLR_NONE);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+


perhaps somebody can convert into mt5

thanks

To add comments, please log in or register