Trading off your keyboard

This might be a stupid question but is it possible to open new trades using your keyboard instead of your mouse.

I thought I saw a script someone made where you just loaded it up or whatever and hit ‘B’ and a buy order was opened up but I never could figure it out. This just seems like a little bit faster way to open a trade so if any one knows if this is possible I’d appreciate a response.

Thanks
Cmac813

I [U]think[/U] IBFX has an ea that does that.

Thanks for the response, I’ll have to look at them later and see if they do or not.

Thanks again mytwopips, IBFX does have an EA where you open a long/short order and close and reverse or close all orders. You can also create hot keys so for instance all I do is hit CTRL + B and I open a buy order, it’s pretty cool.

Cmac813

Understand that you can set up keyboard shortcuts for almost any action on any platform using autohotkey found at autohotkey.com. I personally haven’t set it up to help me with opening and closing orders but will do so in the future. Right now I’m just enjoying it for being able to zip through my templates and timeframes painlessly from my keyboard.

The program basically helps you write powerful macros which allows for simple hotkey control of almost any action you constantly repeat.

Anyway works for me an a few other traders on bp.

I don’t have time to look fully through the website you gave yet but glanced it over. So basically you can set a hot key to open and close trades just like the IBFX script does?

I’d rather make my own since I already have another MT4 broker with all my charts and stuff updated on it and I’d rather not have to recreate news ones with IBFX.

I’ll look over that website later. Is it hard to create your own hotkeys? I’m not very computer literate so I hope it’s not too difficult to do, thank you for your response.

Cmac813

Unfortunately it was kind of tough to get set up, but I might try and do the dirty work as I would like to automate my orders here pretty soon.

That would be awesome if you ever end up creating any scripts and feel like helping us less computer savvy people. I looked at the website and I don’t really have a clue what is going on there so good luck if you try to automate your orders. Thanks for the website anyways.

cmac813

Hey guys if anyone is interested I found some scripts online that will open trades, reverse them and close them as well as a lot more. The website is
MQL4 Code Base: scripts for MetaTrader 4

You can look through there for the scripts, I’ve just practiced with them for like 2 seconds but they seemed to work. Hope this helps anyone if they were looking for them.

cmac813

Thanks i will look at those when i get some time.

FXCM - marketscope2.0

Sorry just realized the link was removed, didn’t realize it was against posting rules, my bad. You can just google MQL4 Code Base: scripts for MetaTrader 4 and it’s the first thing that comes up.

Also if you want the IBFX ones you can download them and copy them to another mt4 platform.

cmac813

Script for Closing all Open Trades for MT4:
Copy the below into your MT4 MetaEditor. by going: ‘file’ ‘new’ ‘script’ -next, put in a name, like close all trades or something
delete the defaults and copy paste this code below: then click ‘compile’ then it will appear in your scripts location in MT4.
right click it in the navigator window and select: ‘set hotkey’ and make it anything you like.

//±-----------------------------------------------------------------+
//| CloseAll.mq4 |
//| Version 3.01 (30-Sep-2011) |
//| CodersGuru |
//| Custom MetaTrader MQL4 MQL5 Programming - Expert Advisors - Indicators - Scripts |
//±-----------------------------------------------------------------+
#property copyright “CodersGuru”
#property link “http://www.xpworx.com
#property show_inputs
//±-----------------------------------------------------------------+
extern int option = 0;
//±-----------------------------------------------------------------+
// Set this prameter to the type of clsoing you want:
// 0- Close all (instant and pending orders) (Default)
// 1- Close all instant orders
// 2- Close all pending orders
// 3- Close by the magic number
// 4- Close by comment
// 5- Close orders in profit
// 6- Close orders in loss
// 7- Close not today orders
// 8- Close before day orders
//±-----------------------------------------------------------------+
extern int magic_number = 0; // set it if you’ll use closing option 3 - closing by magic number
extern string comment_text = “”; // set it if you’ll use closing option 4 - closing by comment
extern int before_day = 0; // set it if you’ll use closing option 8 - closing by before day
extern int Slippage = 5; //Slippage
//±-----------------------------------------------------------------+
int start()
{
CloseAll();
return(0);
}
//±-----------------------------------------------------------------+
int CloseAll()
{
int total = OrdersTotal();
int cnt = 0;

switch (option)
{
case 0:
{
for (cnt = 0 ; cnt <=total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL) CloseOrder(OrderTicket(),0,Slippage,5,500);
if(OrderType()>OP_SELL) OrderDelete(OrderTicket());
}
break;
}
case 1:
{
for (cnt = 0 ; cnt <total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL) CloseOrder(OrderTicket(),0,Slippage,5,500);
}
break;
}
case 2:
{
for (cnt = 0 ; cnt <total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderType()>OP_SELL) OrderDelete(OrderTicket());
}
break;
}
case 3:
{
for (cnt = 0 ; cnt <total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == magic_number)
{
if(OrderType()<=OP_SELL) CloseOrder(OrderTicket(),0,Slippage,5,500);
if(OrderType()>OP_SELL) OrderDelete(OrderTicket());
}
}
break;
}
case 4:
{
for (cnt = 0 ; cnt <total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if (StringFind(OrderComment(),comment_text)>-1)
{
if(OrderType()<=OP_SELL) CloseOrder(OrderTicket(),0,Slippage,5,500);
if(OrderType()>OP_SELL) OrderDelete(OrderTicket());
}
}
break;
}
case 5:
{
for (cnt = 0 ; cnt <total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderProfit() > 0)
{
if(OrderType()<=OP_SELL) CloseOrder(OrderTicket(),0,Slippage,5,500);
if(OrderType()>OP_SELL) OrderDelete(OrderTicket());
}
}
break;
}
case 6:
{
for (cnt = 0 ; cnt <total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderProfit() < 0)
{
if(OrderType()<=OP_SELL) CloseOrder(OrderTicket(),0,Slippage,5,500);
if(OrderType()>OP_SELL) OrderDelete(OrderTicket());
}
}
break;
}
case 7:
{
for (cnt = 0 ; cnt <total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(TimeDay(OrderOpenTime())!=TimeDay(TimeCurrent()))
{
if(OrderType()<=OP_SELL) CloseOrder(OrderTicket(),0,Slippage,5,500);
if(OrderType()>OP_SELL) OrderDelete(OrderTicket());
}
}
break;
}
case 8:
{
for (cnt = 0 ; cnt <total ; cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(TimeDay(OrderOpenTime())<before_day)
{
if(OrderType()<=OP_SELL) CloseOrder(OrderTicket(),0,Slippage,5,500);
if(OrderType()>OP_SELL) OrderDelete(OrderTicket());
}
}
break;
}
}
}
//±-----------------------------------------------------------------+
bool CloseOrder(int ticket, double lots, int slippage, int tries, int pause)
{
bool result=false;
double ask , bid;

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
RefreshRates();
ask = NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),MarketInfo(OrderSymbol(),MODE_DIGITS));
bid = NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),MarketInfo(OrderSymbol(),MODE_DIGITS));

  if(OrderType()==OP_BUY)
  {
     for(int c = 0 ; c &lt; tries ; c++)
     {
        if(lots==0) result = OrderClose(OrderTicket(),OrderLots(),bid,slippage,Violet);
        else result = OrderClose(OrderTicket(),lots,bid,slippage,Violet);
        if(result==true) break; 
        else
        {
           Sleep(pause);
           RefreshRates();
           ask = NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),MarketInfo(OrderSymbol(),MODE_DIGITS));
           bid = NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),MarketInfo(OrderSymbol(),MODE_DIGITS));      
           continue;
        }
     }
  }
  if(OrderType()==OP_SELL)
  {
     for(c = 0 ; c &lt; tries ; c++)
     {
        if(lots==0) result = OrderClose(OrderTicket(),OrderLots(),ask,slippage,Violet);
        else result = OrderClose(OrderTicket(),lots,ask,slippage,Violet);
        if(result==true) break; 
        else
        {
           Sleep(pause);
           RefreshRates();
           ask = NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK),MarketInfo(OrderSymbol(),MODE_DIGITS));
           bid = NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),MarketInfo(OrderSymbol(),MODE_DIGITS));  
           continue;
        }
     }
  }

}
return(result);
}
//±-----------------------------------------------------------------+

Awsome “Xno” thank you so much. Does it close the “first” or “last” trade first.

Cool this looks like it could be pretty handy, although I’d be worried about tapping on my keyboard and not realizing the i’m on :stuck_out_tongue:

A easier way around this, and sorry if its already been discussed would be to click the ‘Navigator’ icon in MT4. This will view all your indicators, both custom and standard, and it will also display your scripts. If you right click any of these you can assign a hot-key to them which starts with either Ctrl or Alt, and then your chosen letter keyboard key.