Trying to send Limit orders using hotkeys and mouse

 

Hi, I'm trying to create an EA that  sends limit orders on MQL4 for MT4 , using SHIFT KEY + Left Click to set the entry price and CTRL + Left Click to set the stop loss price and then S or B Keys to indicate that is a Sell or Buy order type.

This is what I've done by now , I know is not much , but I'm really new to coding into mql4 and for metratrader in general :



#define KEY_SHIFT 16 

#define KEY_CTRL  17

#define KEY_B     66

#define KEY_S     83

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)

{

   if(id == CHARTEVENT_KEYDOWN)

   {

      switch(int(lparam))

      {

         case KEY_B:

         {

            Alert("The B key was pressed. and Order ID is :");

            int orderId = OrderSend(NULL,OP_BUYLIMIT,riskPerTrade,Ask,10,Ask-0.001, Ask+0.003);

           

            break;

         }

         case KEY_S:

         {

            Alert("The S key was pressed. and Order ID is: ");

            int orderId = OrderSend(NULL,OP_SELLLIMIT,riskPerTrade,Bid,10,Bid-0.001, Bid+0.003);

            

            //return orderId;

            break;

         }

         default: Alert("Dont recognise that key.");

      }

      ChartRedraw();

   }

}