Is there any way to Sell or Buy With Hot Keys?

 
Hello.
Is there any way to sell or Buy With Hot Keys?
For Example Ctr+B for Buy and Ctr+S for Sell.
 
F9 pulls up the New Order box.
That is all there is.
 
You can write appropriate scripts and assign them hot keys
 
You can write appropriate scripts and assign them hot keys



Thank's Slawa

Here is the Script + EA which I have written and work together:

1- Set the test.mq4 in EA folder.
2- Set the BUY.mq4 , SELL.mq4 and CLOSE.mq4 in Scripts folder.
3- Set Hot keys for BUY , SELL and CLOSE scripts. (I used Ctr+B for BUY, Ctr+S for SELL and Ctr+C for Close)
4-Run the test.mq4 in tester at Visual mode.
5- when you chose Ctr+B a buy position happens.
6- when you chose Ctr+S a sell position happens.
7- when you chose Ctr+C the last position close.



//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"



extern double TakeProfit = 50;
extern double Stoploss = 50;
extern double Lots = 0.1;
extern double TrailingStop = 30;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
int cnt,total;
//----
   //Comment(ObjectFind("BUY"));
   Comment(AccountEquity());
   if (ObjectFind("BUY")==0)
   {
   OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-Stoploss*Point,Ask+TakeProfit*Point,"TEST",16384,0,Green);
    ObjectDelete("BUY");
   }
  
     if (ObjectFind("SELL")==0)
   {
   OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+Stoploss*Point,Bid-TakeProfit*Point,"TEST",16384,0,Red);
    ObjectDelete("SELL");
   }
   total=OrdersTotal();
     
     if (ObjectFind("CLOSE")==0)
   {
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
            // should it be closed?
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                 ObjectDelete("CLOSE");
            // check for trailing stop
           }
         
         else // go to short position
           {
            // should it be closed?
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
               ObjectDelete("CLOSE");
            // check for trailing stop
           }
        }
       }
      }

  
  
  
   ObjectDelete("lable");
   ObjectCreate("lable", OBJ_REGRESSION, 0,iTime(NULL,0,240),0,iTime(NULL,0,0),0);
   ObjectsRedraw();

//----
   return(0);
  }
//+------------------------------------------------------------------+





//+------------------------------------------------------------------+
//|                                                         BUY.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
ObjectDelete("BUY");
ObjectCreate("BUY",OBJ_LABEL,0,0,0);
//----
   return(0);
  }
//+------------------------------------------------------------------+






//+------------------------------------------------------------------+
//|                                                       CLOSE.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   ObjectDelete("CLOSE");
   ObjectCreate("CLOSE",OBJ_LABEL,0,0,0);

//----
   return(0);
  }
//+------------------------------------------------------------------+








//+------------------------------------------------------------------+
//|                                                         SELL.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
ObjectDelete("SELL");
ObjectCreate("SELL",OBJ_LABEL,0,0,0);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
m_sakhai :
You can write appropriate scripts and assign them hot keys



Thank's Slawa

Here is the Script + EA which I have written and work together:

1- Set the test.mq4 in EA folder.
2- Set the BUY.mq4, SELL.mq4 and CLOSE.mq4 in Scripts folder.
3- Set Hot keys for BUY, SELL and CLOSE scripts. (I used Ctr+B for BUY, Ctr+S for SELL and Ctr+C for Close)
4-Run the test.mq4 in tester at Visual mode.
5- when you chose Ctr+B a buy position happens.
6- when you chose Ctr+S a sell position happens.
7- when you chose Ctr+C the last position close.



//+------------------------------------------------------------------+
//| test.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"



extern double TakeProfit = 50;
extern double Stoploss = 50;
extern double Lots = 0.1;
extern double TrailingStop = 30;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int cnt,total;
//----
//Comment(ObjectFind("BUY"));
Comment(AccountEquity());
if (ObjectFind("BUY")==0)
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-Stoploss*Point,Ask+TakeProfit*Point,"TEST",16384,0,Green);
ObjectDelete("BUY");
}

if (ObjectFind("SELL")==0)
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+Stoploss*Point,Bid-TakeProfit*Point,"TEST",16384,0,Red);
ObjectDelete("SELL");
}
total=OrdersTotal();

if (ObjectFind("CLOSE")==0)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
ObjectDelete("CLOSE");
// check for trailing stop
}

else // go to short position
{
// should it be closed?
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
ObjectDelete("CLOSE");
// check for trailing stop
}
}
}
}




ObjectDelete("lable");
ObjectCreate("lable", OBJ_REGRESSION, 0,iTime(NULL,0,240),0,iTime(NULL,0,0),0);
ObjectsRedraw();

//----
return(0);
}
//+------------------------------------------------------------------+





//+------------------------------------------------------------------+
//| BUY.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
ObjectDelete("BUY");
ObjectCreate("BUY",OBJ_LABEL,0,0,0);
//----
return(0);
}
//+------------------------------------------------------------------+






//+------------------------------------------------------------------+
//| CLOSE.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
ObjectDelete("CLOSE");
ObjectCreate("CLOSE",OBJ_LABEL,0,0,0);

//----
return(0);
}
//+------------------------------------------------------------------+







//+------------------------------------------------------------------+
//| SELL.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
ObjectDelete("SELL");
ObjectCreate("SELL",OBJ_LABEL,0,0,0);

//----
return(0);
}
//+------------------------------------------------------------------+



Oh man that is pretty cool.

I don't understand all the programming language but I have a script that closes all open positions that someone gave me.

How do I assign hotkeys to it?


That really seems great.

Omar

 

Oh man that is pretty cool.

I don't understand all the programming language but I have a script that closes all open positions that someone gave me.

How do I assign hotkeys to it?


That really seems great.

Omar

 
 

Hi..don't work in MT5...!

Is there a new script ? 

Ginus