Yes, it is possible! Use the OnChartEvent handler for that.
Documentation on MQL5: Event Handling / OnChartEvent
- www.mql5.com
The function is called in indicators and EAs when the ChartEvent event occurs. The function is meant for handling chart changes made by a user or...
thanks i look but not work for me not draw nothing , but if i clik in terminal o look i click but if i use a combine not work
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { // Rileva pressione/rilascio del tasto S if(id == CHARTEVENT_KEYDOWN) { if(lparam == 83) // codice ASCII di 'S' S_Pressed = true; } if(id == CHARTEVENT_KEYUP) { if(lparam == 83) S_Pressed = false; } // Aggiorno lo stato dei tasti/mouse if(id == CHARTEVENT_MOUSE_MOVE) { state = (uint)lparam; // memorizza lo stato dei tasti e mouse //DEBUG Print("Mouse state updated: ", state); } //--- Show the event parameters on the chart // Comment(__FUNCTION__, ": id=", id, " lparam=", lparam, " dparam=", dparam, " sparam=", sparam); if(id==CHARTEVENT_OBJECT_CLICK){ string message = ""; if(sparam=="Invia_a_VIP"){ if(PositionSelect(_Symbol)) { // Ottieni il tipo (BUY/SELL) long type = PositionGetInteger(POSITION_TYPE); double price = PositionGetDouble(POSITION_PRICE_OPEN); ulong ticket = PositionGetInteger(POSITION_TICKET); string side; if(type == POSITION_TYPE_BUY) side = "BUY"; else if(type == POSITION_TYPE_SELL) side = "SELL"; message= Symbol() + " " + side + " " + DoubleToString(price, _Digits) + "\nSeconda riga\nTerza riga"; } if(SendMessageToTelegram(message, chatId, botToken)) { // Print("Greeting message sent successfully."); } else { Print("Failed to send greeting message."); } } //-------------------------------- LINEA 1 ---------------------------------------------- if(sparam=="Invia_a_FREE"){ if(PositionSelect(_Symbol)) { // Ottieni il tipo (BUY/SELL) long type = PositionGetInteger(POSITION_TYPE); double price = PositionGetDouble(POSITION_PRICE_OPEN); ulong ticket = PositionGetInteger(POSITION_TICKET); string side; if(type == POSITION_TYPE_BUY) side = "BUY"; else if(type == POSITION_TYPE_SELL) side = "SELL"; message= Symbol() + " " + side + " " + DoubleToString(price, _Digits) + "\nSeconda riga\nTerza riga"; } if(SendMessageToTelegram(message, chatId, botToken)) { // Print("Greeting message sent successfully."); } else { Print("Failed to send greeting message."); } } } // Evento click su chart if(id == CHARTEVENT_CLICK) { int x = (int)lparam; int y = (int)dparam; datetime dt; double price; int window; Print("Click sul grafico: X=", x, " Y=", y, " State=", state); // Verifica se ALT + tasto destro sono premuti if(S_Pressed && (state & MOUSE_LEFT) == MOUSE_LEFT) { Print("s + tasto sinistro premuti"); if(ChartXYToTimePrice(0, x, y, window, dt, price)) { Print("ChartXYToTimePrice ok - Prezzo: ", price); string lineName = "StopLossLine"; if(ObjectFind(0, lineName) != -1) { Print("Linea esistente trovata, elimino..."); ObjectDelete(0, lineName); } if(ObjectCreate(0, lineName, OBJ_HLINE, window, 0, price)) { Print("Linea creata al prezzo: ", price); ObjectSetInteger(0, lineName, OBJPROP_COLOR, clrRed); ObjectSetInteger(0, lineName, OBJPROP_STYLE, STYLE_SOLID); ObjectSetInteger(0, lineName, OBJPROP_WIDTH, 2); // Aggiorna la editbox StopLossEdit con il prezzo ObjectSetString(0,"StopLOssEdit",OBJPROP_TEXT,DoubleToString(price,_Digits)); Print("EditBox StopLossEdit aggiornato: ", DoubleToString(price, _Digits)); } else { Print("Errore nella creazione della linea! Errore: ", GetLastError()); } } else { Print("ChartXYToTimePrice fallito!"); } } else { Print("ALT + tasto destro NON premuti"); } } }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi in mql5 in s possible intercept keyboard +mouse left, example: i want take alt+ right mouse button , if happen this i want draw in chart a line is possible ? thanks