Hi there guys, i just wanted to share this Expert i've created for buying and selling on semi-auto trading using hotkeys that will allow you to open trades in both direction using only letter "Q" and letter "E" on your keyboard. Lot is fixed to 1.00 but you can adjust that in your code preference.
If someone wants to edit code here available to everyone that will be awesome. What im missing is time current -1 because first trade when you open position using this EA does not show magic number and also option to adjust this lot numbers in the settings of the Expert itself, however i've made this like this to remain fixed because i do use leverage trading so multiple smaller positions works for me.
//+------------------------------------------------------------------+//| Buy or Sell Hotkeys.mq5 |//| Copyright 2025, Schumacher Drive |//| https://www.mql5.com/en/users/schumacher.drive |//+------------------------------------------------------------------+#property copyright"Copyright 2025, Schumacher Drive"#property link"https://www.mql5.com/en/users/schumacher.drive"#property version"1.00"//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+inputstring K ="General Settings";
inputint Magic = 1234;
#include <Trade/Trade.mqh>
#define KEY_Q 81#define KEY_E 69
CTrade trade;
intOnInit()
{
return(INIT_SUCCEEDED);
}
voidOnDeinit(constint reason)
{
}
voidOnTick()
{
datetime LastTickTime=TimeCurrent();
}
voidOnChartEvent(constint id, constlong& lparam, constdouble& dparam, conststring& sparam)
{
if (id == CHARTEVENT_KEYDOWN){
if(lparam == KEY_E){
Print("Q was pressed!");
trade.Buy(1.00);
trade.SetExpertMagicNumber(Magic);
}
if(lparam == KEY_Q) {
Print("E was pressed!");
trade.Sell(1.00); }
trade.SetExpertMagicNumber(Magic);
{
}
}
}
If someone wants to edit code here available to everyone that will be awesome. What im missing is time current -1 because first trade when you open position using this EA does not show magic number and also option to adjust this lot numbers in the settings of the Expert itself, however i've made this like this to remain fixed because i do use leverage trading so multiple smaller positions works for me.