![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
True story, i am new, to the site, to coding as well. Never coded before.
start here
Thanks for that information.
To be honest i came to the traders/coding forum to get the answer from someone who has done it already and could possibly help me out, not learn how to code everything myself from scratch.
Thanks for that information.
To be honest i came to the traders/coding forum to get the answer from someone who has done it already and could possibly help me out, not learn how to code everything myself from scratch.
Thanks for that information.
To be honest i came to the traders/coding forum to get the answer from someone who has done it already and could possibly help me out, not learn how to code everything myself from scratch.
Thanks Guys!
Following your advice, I wrote smth like this inside my EA:
In a certain situation, defined by MyCondition, this plays my alert, so I can hear that I have to check what is going on.
A message box pops out, asking if I want to run the script - which is a close all positions script.
When I click the [YES] button, the script executes - closes all positions - and disables the [Experts] button in MT4.
Of course, you do not need to disable Experts, unless you have a reason to do that.
If on the next loop your EA does not find the condition, it will not trigger the script.
Obviously, this is only a workaround and not a perfect solution, because the EA keeps looping on every tick.
And you cannot disable Experts until the script has been executed, because the script is inside the EA, not stand alone.
P.S.
In order for this to work, you need to include the following in the begining of your EA:
#include <WinUser32.mqh>
I have just thought of another solution!!!
You can assign a shortcut key (HOTKEY) to your script.
Thus, you can emulate the keyboard event.
So, better:
if(MyCondition) { EnableScript(); DisableAllEA(); Sleep(3000); }
You can include your alert.wav in the stand alone script, and the message box, as well.
And, you can decide wheather to enable Experts or not, after your action on the situation.
This way, you do not risk overstacking.
Of course, this needs more study on key events.
The function for Ctrl+E keyboard event is:
With a bit of googling, you can find number codes for every key.
Or, you can use this link: https://www.mql5.com/en/code
Of course, keybd_event is not part of mql4, that is why you need:
#include <WinUser32.mqh>
And, by the way!
Has anybody ever tired to implement an EA on the chart as an indicator?
It should work just as well!
And you can have any number of indicators running on a chart!
I have tried implementing scripts as indicators, and that works just fine!
And, by the way!
Has anybody ever tired to implement an EA on the chart as an indicator?
It should work just as well!
You can't place trades from an Indicator, only from Scripts and EAs.
You can't place trades from an Indicator, only from Scripts and EAs.
So, an EA could run as a script? In a loop?
Only, when in an infinite loop, the computer will eventually crash.
Is there a way to trigger a script in a loop controlled by some ticker, like every 50ms or smth like that?
Not by MT4 ticks?
You can't place trades from an Indicator, only from Scripts and EAs.
And another thought:
So you can use the keyboard event function to place orders by Script.
1. Write a Script to automatically place orders.
2. Asssign a HOTKEY to it.
3. In the EA running as Indicator define the keyboard event.
Then, you can do the same for closing orders.
There you have it! An EA running as an Indicator and doing its job!
The only downside to this way is that you can not disable an Indicator with a keyboard event - only manually remove it from chart.