develop own MT5 specific array of buttons to control MT5

 
Hi guys. To simplify and accelerate my trading I want to develop and construct an array of buttons for different actions in MT5. First I thought about using an electric piano and use midi control to buy/sell/close instrument witch each key designated for a defined action. But I intend now to build a vaste set of buttons into my desk so I can e.g. buy a predefined amount of oil with the push of a single button. I will use for this an arduino which I gonna connect to my PC with an USB cable and hook all the buttons up to the arduino (or a raspberry PI) I'm good in electronics and can also program C++ and Java. My BIG question is: Has this done anybody before or will I be the pioneer for you guys since I will certainly share my Ideas and progress in this blog. Final product should be around 200 buttons on a selfmade 'keyboard' or directly integrated in my desk to control all my actions in MT5. Thank you for your answers and/or ideas how to proceed. 

Greetings Claudio from Switzerland
 

Maybe it's best if you give that amount of attention to things like when to push the button in stead of pushing the button itself.

It might be of more importance than the actual button itself.

Of course you can build your own flight deck trading desk, but that, and that skill set does not make you a good trader per se, and it isn't really needed to be a successful trader. 

 
:D Allright but I want to build one because I am a perfectionist and I like to develop stuff in my spare time. Thanks for the hint and I was just browsing through different flight simulator forums, they solve the main part of my questions. I am going to keep you updated. Peace
 
Claudio: To simplify and accelerate my trading I want to develop and construct an array of buttons for different actions in MT5. First I thought about using an electric piano and use midi control to buy/sell/close instrument witch each key designated for a defined action. But I intend now to build a vaste set of buttons into my desk so I can e.g. buy a predefined amount of oil with the push of a single button. I will use for this an arduino which I gonna connect to my PC with an USB cable and hook all the buttons up to the arduino (or a raspberry PI) I'm good in electronics and can also program C++ and Java. My BIG question is: Has this done anybody before or will I be the pioneer for you guys since I will certainly share my Ideas and progress in this blog. Final product should be around 200 buttons on a selfmade 'keyboard' or directly integrated in my desk to control all my actions in MT5. Thank you for your answers and/or ideas how to proceed.

Just use another normal keyboard or a smaller keypad via USB (or Bluetooth), stick some printed labels on the keys and use a Key Macro application or code a small mapping driver for it using "Microsoft Keyboard Layout Creator 1.4" which is totally free.

Making a Powerful Programmable Keypad for Less Than $30.
Making a Powerful Programmable Keypad for Less Than $30.
  • johnofe
  • www.instructables.com
Products like the X-Keys programmable keypads are a great companion for anyone who uses hot-key heavy software like PhotoShop. They allow you to lay out all your hot keys on one small board complete with labels and with a push of a button activate any macro or keystroke programmed into the software. But those products cost in excess of $100.00...
 
Hmm I intend to use programmable USB keypads. They are cheap and will save me a lot of constructing and programming. I intend to use several Accuratus S24A - USB Keypad with 24 Fully programmable Cherry MX Keys with 6x4 keys so I can use 1 Instrument for each row with commands: Buy predefined lot/short predefined lot/close last opened postion and close all positions. What do you think abou it? Thx for any inputs.
 
Thank you Fernando for your Inputs! Much appreciated :) Greetings Claudio
 
Claudio:
:D Allright but I want to build one because I am a perfectionist

https://www.turtletrader.com/perfectionism/

Perfectionism Is Not Your Friend
Perfectionism Is Not Your Friend
  • www.turtletrader.com
A couple interesting excerpts to ponder from, http://trenders.blogspot.com: Perfectionism can be a great help to people in many professions, but can be fatal to a trader. Perfectionists, always trying to find the Holy Grail of trading go from one service to another, from one system to another, looking for a way that they can be right all the...
 
Cheers Anthony! Greetings Claudio
 

You don't need programmable keyboard because you will be doing the programming in MT5 itself.

You can use your normal single keyboard and assign all the operations to its keys, maybe including a master key to turn this on and off and some visual feedback on your screen.

Here is an example code that changes timeframes through predefined values on pressing [ and ] and defaults to 3 minutes on pressing ' or reaching end of the row:

void OnChartEvent(const int id,
                  const long& lparam,
                  const double& dparam,
                  const string& sparam
                  )
  {
   if(id==CHARTEVENT_KEYDOWN)
     {
      if(lparam==219) TimeFrameDown();
      if(lparam==221) TimeFrameUp();
      if(lparam==222) TimeFrameInTheMiddle();
     }

   ChartRedraw();
  }

void TimeFrameUp()
  {
   ENUM_TIMEFRAMES timeframe;
   switch(_Period)
     {
      case PERIOD_M1:   timeframe=PERIOD_M2;    break;
      case PERIOD_M2:   timeframe=PERIOD_M3;    break;
      case PERIOD_M3:   timeframe=PERIOD_M5;    break;
      case PERIOD_M5:   timeframe=PERIOD_M10;   break;
      case PERIOD_M10:  timeframe=PERIOD_M15;   break;
      case PERIOD_M15:  timeframe=PERIOD_M30;   break;
      case PERIOD_M30:  timeframe=PERIOD_H1;    break;
      case PERIOD_H1:   timeframe=PERIOD_H4;    break;
      case PERIOD_H4:   timeframe=PERIOD_D1;    break;
      case PERIOD_D1:   timeframe=PERIOD_W1;    break;
      case PERIOD_W1:   timeframe=PERIOD_MN1;   break;
      default:    timeframe=PERIOD_M3;
     }
   ChartSetSymbolPeriod(0,_Symbol,timeframe);
  }

void TimeFrameDown()
  {
   ENUM_TIMEFRAMES timeframe;
   switch(_Period)
     {
      case PERIOD_M2:   timeframe=PERIOD_M1;    break;
      case PERIOD_M3:   timeframe=PERIOD_M2;    break;
      case PERIOD_M5:   timeframe=PERIOD_M3;    break;
      case PERIOD_M10:  timeframe=PERIOD_M5;    break;
      case PERIOD_M15:  timeframe=PERIOD_M10;   break;
      case PERIOD_M30:  timeframe=PERIOD_M15;   break;
      case PERIOD_H1:   timeframe=PERIOD_M30;   break;
      case PERIOD_H4:   timeframe=PERIOD_H1;    break;
      case PERIOD_D1:   timeframe=PERIOD_H4;    break;
      case PERIOD_W1:   timeframe=PERIOD_D1;    break;
      case PERIOD_MN1:  timeframe=PERIOD_W1;    break;
      default:    timeframe=PERIOD_M3;
     }
   ChartSetSymbolPeriod(0,_Symbol,timeframe);
  }

void TimeFrameInTheMiddle()
  {
   ChartSetSymbolPeriod(0,_Symbol,PERIOD_M3);
  }

It is better to include and use VirtualKeys.mqh than directly writing the key codes.

Reason: