Using Order Scripts through an EA via Hotkeys

 

Hi Everyone,

I am new to coding and would like to create an EA that would work with scripts that are triggered using hotkeys.  These scripts would be placing and closing orders. I am not quite sure how the connections are to be made between the script and the EA to make that happen. Any assistance would be greatly appreciated. If anyone has any codes that would assist, they would be most welcome.


Thanks in advance for your help ;).

 
Goldengirl9: I am new to coding and would like to create an EA that would work with scripts that are triggered using hotkeys.  These scripts would be placing and closing orders. I am not quite sure how the connections are to be made between the script and the EA to make that happen. Any assistance would be greatly appreciated. If anyone has any codes that would assist, they would be most welcome.

You can apply a Hotkey to a script by right-clicking it in the "Navigator" panel and choosing "Set hotkey" on both MT4 and MT5.


 

Thanks Fernando for the reply.

I know how to set the hotkeys, but I want the scripts to work through an EA. Not sure how to make that connection.  

 
Goldengirl9 #: Thanks Fernando for the reply. I know how to set the hotkeys, but I want the scripts to work through an EA. Not sure how to make that connection.  

Why complicate things? Just make a single EA with the functionalities of the various scripts and just monitor the keystrokes from the OnChartEvent() handler in order to trigger each functionality. You can also use a panel or dashboard to click on instead of keystrokes.

 
Fernando Carreiro #:

Why complicate things? Just make a single EA with the functionalities of the various scripts and just monitor the keystrokes (or a dashboard or panel) in order to trigger each functionality.

Hi Fernando,

Not sure how to monitor the keystrokes as you have mentioned. Please explain.  Thanks.

 
Fernando Carreiro #:

Why complicate things? Just make a single EA with the functionalities of the various scripts and just monitor the keystrokes from the OnChartEvent() handler in order to trigger each functionality. You can also use a panel or dashboard to click on instead of keystrokes.

Okay. I will look into the OnChartEvent() handler. I have never used it before.  How can a panel or dashboard be set up?
 
Goldengirl9 #: Not sure how to monitor the keystrokes as you have mentioned. Please explain.  Thanks.
It's in the documentation. Check for an "CHARTEVENT_KEYDOWN" event, read the keystroke and run the necessary code according to the keystroke, by calling a function for example.
Documentation on MQL5: Event Handling / OnChartEvent
Documentation on MQL5: Event Handling / OnChartEvent
  • www.mql5.com
OnChartEvent - Event Handling - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Goldengirl9 #: Okay. I will look into the OnChartEvent() handler. I have never used it before.  How can a panel or dashboard be set up?

There are several examples of trading panels in the CodeBase. Here is one I found available on both MT4 and MT5, but there are more, so run a search.

 
Fernando Carreiro #:

There are several examples of trading panels in the CodeBase. Here is one I found available on both MT4 and MT5, but there are more, so run a search.

Thanks Fernando.  Will check these out. Appreciated ;).
 
Goldengirl9 #:
Thanks Fernando.  Will check these out. Appreciated ;).

Hi again Fernando.  Not sure I want the control panel/dashboard as it seems as though details still need to be entered.  I want the trades to be executed once the hotkey is pressed on the keyboard. I am thinking the OnChartEvent is the way to go. The handler may be the connecter.  Will work with it and see if I can make it happen.

 
Will take a closer look at the dashboard style again. Thankx.
Reason: