how i can call theses button
There is several methods - for one such method look here: https://www.mql5.com/en/docs/eventfunctions/eventchartcustom
Indicators can not trade. Stop trying to shoe horn mt4 to your way of thinking. Likely hundreds of lines of code.
Use it how MQ designed it. Create a script or EA. Have the EA monitor the indicator via iCustom. When the condition occurs, close the orders (OrderSelect loop/OrderClose.) Likely a dozen or so lines of code.
hello thank you my friends
i know that we can not trade by indicator,can you close open trade with
PostMessageA(GetAncestor(WindowHandle(Symbol(),Period()),2),WM_COMMAND,35451,0);
but you will not delete the pending trade with it .
Now i want to call automatically a script, i will create a script by via indicator like same file and i will compile it by command prompt, please please help me for can call script automatically
maria2014:
please please help me for can call script automatically
ok, if you do want to do some messaging..
1. you have to do this:
#import "user32.dll" int SendMessageA(int, int, int, char&[]); int RegisterWindowMessageA(char&[]); #import
2. you have to do this:
char sz_mt4imsg[]; char sz_script[]; string scriptname = "startme"; // name of the script int mt4imsg;
3. you have to do this in OnInit():
StringToCharArray("MetaTrader4_Internal_Message", sz_mt4imsg); StringToCharArray(scriptname, sz_script); mt4imsg = RegisterWindowMessageA(sz_mt4imsg);
4. you have to do this in OnCalculate() to start script:
SendMessageA(WindowHandle(Symbol(), Period()), mt4imsg, 16, sz_script);
Here an example:
// indicator code #property strict #import "user32.dll" int SendMessageA(int, int, int, char&[]); int RegisterWindowMessageA(char&[]); #import char sz_mt4imsg[]; char sz_script[]; string scriptname = "startme"; // call the script to be started "startme" int mt4imsg; int OnInit() { StringToCharArray("MetaTrader4_Internal_Message", sz_mt4imsg); StringToCharArray(scriptname, sz_script); mt4imsg = RegisterWindowMessageA(sz_mt4imsg); return 0; } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { // start script SendMessageA(WindowHandle(Symbol(), Period()), mt4imsg, 16, sz_script); return rates_total; }
hello 2cent thank you very much you are great programer
please i want to ask you with https://www.mql5.com/en/docs/eventfunctions/eventchartcustom
i did not find how we can close order from indicator i found only a buttons, please we can close and delete the pending orders by it ?
if not please give me function detects if script name runs on chart or no and function for delete this script name
thank you very much
an attached EA that implements OnChartEvent() function can thus be notified this way and perform trading actions.
ok, here an example of how an indicator can trigger an expert advisor (run both on the same chart):
first the expert code:
// EA code #property strict void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { if(id == CHARTEVENT_CUSTOM) Print(sparam); }
now the indicator:
// indicator code #property strict #property indicator_chart_window string message = "Indi triggers EA!"; int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { EventChartCustom(0, 0, 0, 0, message); return(rates_total); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello
please help me i want to find method for close my trades from my indicator by Win API or find method for call script or EA by indicator
thank you