Is there way to disable or enable auto trade or live trade via custom indicator? MQL4

 

Hi guys. I have EA (ex4 file) I want to add some filter on it so I have decided to make indicator that will calculate some algo and after it enable or disable auto trader or live trade. witch one will be possible.
Please help me. Thank you.

 
int main = GetAncestor(WindowHandle(Symbol(), Period()), 2);

PostMessageA(main, WM_COMMAND,  MT4_WMCMD_EXPERTS, 0 ) ;    // // Toggle Expert Advisor button

 

You don't need to create another indicator, you can still use it on the EA and it will work

 
Mafuta Landou:

 

You don't need to create another indicator, you can still use it on the EA and it will work

I don't have Source code of ea. so I can't edit it. because of it I decide make this kind of indicator

 
Revazi Tchitanava:

I don't have Source code of ea. so I can't edit it. because of it I decide make this kind of indicator

As an Indicator also is fine.

 
Mafuta Landou:

As an Indicator also is fine.

I get errors:

'GetAncestor' - function not defined

'WM_COMMAND' - undeclared identifier

'MT4_WMCMD_EXPERTS' - undeclared identifier

'PostMessageA' - function not defined

Please help me


 
I thought you knew the basics.
#include <WinUser32.mqh>
#import "user32.dll"
 
int GetAncestor(int, int);
#define MT4_WMCMD_EXPERTS  33020 
 
Mafuta Landou:
I thought you knew the basics.

I get:

'GetAncestor' - function must have a body

and what MT4_WMCMD_EXPERTS 33020 means?


Thank you a lot. 

 
O I figure it out. Thank you again. bye
 
You are welcome
 
Mafuta Landou:
You are welcome

O one question:

how to just click on auto trade button when it is disabled?

I don't want to click it when it is enabled
 
You don't need click it. If your condition is met that command will toggle the button. (Toggle means if it was activated will change to deactivated and vice versa). I use it to enable trading at certain  time and it works perfectly and I don't click.