Hi Guys
I wish to run/execute an mql4 file from a script. This mql4 file is an indicator. What is the syntax to run that file in a script? Would greatly appreciate if someone can help me out. Below is the code snippet. Thanks in advance
Hi Guys
I wish to run/execute an mql4 file from a script. This mql4 file is an indicator. What is the syntax to run that file in a script? Would greatly appreciate if someone can help me out. Below is the code snippet. Thanks in advance
// Import of functions from User32. If their purpose isn't pretty much immediately // clear, then documenting it here frankly isn't going to help much. Requires // "Allow DLL imports" to be turned on. #import "user32.dll" int RegisterWindowMessageA(string MessageName); int PostMessageA(int hwnd, int msg, int wparam, string Name); void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo); #import // The hWnd parameter for all these functions is obtained using WindowHandle(). // For example, an EA/script can get the handle of its own chart using // WindowHandle(Symbol(), 0). If the EA/script knows that another chart // is open, then its handle can be obtained using the known symbol and // timeframe. Unpredictable behaviour if there are multiple charts for // the same symbol and timeframe. AutomaticallyAcceptDefaults clears // the configuration window for the new indicator/EA/script by simulating // a press of the Enter key after a small wait. A longer wait might // prove to be more robust. None of this is for the faint-hearted... void StartStandardIndicator(int hWnd, string IndicatorName, bool AutomaticallyAcceptDefaults = false) { int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message"); PostMessageA(hWnd, MessageNumber, 13, IndicatorName); if (AutomaticallyAcceptDefaults) ClearConfigDialog(); } void StartCustomIndicator(int hWnd, string IndicatorName, bool AutomaticallyAcceptDefaults = false) { int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message"); PostMessageA(hWnd, MessageNumber, 15, IndicatorName); if (AutomaticallyAcceptDefaults) ClearConfigDialog(); } void StartEA(int hWnd, string EAName, bool AutomaticallyAcceptDefaults = false) { int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message"); PostMessageA(hWnd, MessageNumber, 14, EAName); if (AutomaticallyAcceptDefaults) ClearConfigDialog(); } void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = false) { int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message"); PostMessageA(hWnd, MessageNumber, 16, ScriptName); if (AutomaticallyAcceptDefaults) ClearConfigDialog(); } void ClearConfigDialog() { Sleep(100); keybd_event(13, 0, 0, 0); }
Hi Guys
I wish to run/execute an mql4 file from a script. This mql4 file is an indicator. What is the syntax to run that file in a script? Would greatly appreciate if someone can help me out. Below is the code snippet. Thanks in advance
//+------------------------------------------------------------------+ //| hariciEACagirma.mq4 | //| Copyright 2015, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| aswincmds.mqh | //| Copyright © 2010, A. Robert Strube | //| arstrube@gmx.de | //+------------------------------------------------------------------+ //int PostMessageA(int hWnd,int Msg,int wParam,int IParam) /* I don't recommend using this file as an actual #include in your code (although you can do so if desired( because it isn't anywhere near complete or finished. Rather, use it as a source of information for #define's in your own code. Still missing: Remove Script Feel free to add to this as you discover more commands. Please share the result. */ #property copyright "Copyright © 2010, A. Robert Strube" #property link "arstrube@gmx.de" //+------------------------------------------------------------------+ //| defines | //+------------------------------------------------------------------+ /* 00000-32999 not inspected */ /* 33000-33016 unknown */ #define MT4_WMCMD_AUTOSCROLL 33017 #define MT4_WMCMD_BARS 33018 #define MT4_WMCMD_CANDLES 33019 /* 33020 unknown */ #define MT4_WMCMD_GRID 33021 #define MT4_WMCMD_LINE 33022 #define MT4_WMCMD_SHIFT 33023 #define MT4_WMCMD_VOLUMES 33024 #define MT4_WMCMD_ZOOM_IN 33025 #define MT4_WMCMD_ZOOM_OUT 33026 /* 33027-33047 unknown */ #define MT4_WMCMD_EXPERT_INPUTS 33048 /* Open expert Inputs dialog */ /* 33049 unknown */ #define MT4_WMCMD_REMOVE_EXPERT 33050 /* Remove expert advisor from chart */ /* 33051-33053 unknown */ #define MT4_WMCMD_SAVE_AS_PICTURE 33054 /* 33055-33133 unknown */ #define MT4_WMCMD_PERIOD_D1 33134 /* 33135 unknown */ #define MT4_WMCMD_PERIOD_H4 33136 #define MT4_WMCMD_PERIOD_M1 33137 #define MT4_WMCMD_PERIOD_M5 33138 #define MT4_WMCMD_PERIOD_M15 33139 #define MT4_WMCMD_PERIOD_M30 33140 #define MT4_WMCMD_PERIOD_W1 33141 /* 33142-33156 unknown */ #define MT4_WMCMD_PROPERTIES 33157 /* Chart Properties (F8) */ /* 33158-33176 apparently unused */ #define MT4_WMCMD_PERIOD_SEPARATE 33177 /* Show/hide period separators */ /* 33178-33196 unknown */ #define MT4_WMCMD_MOVE_RIGHT 33197 /* Move right (right/down arrow) */ #define MT4_WMCMD_MOVE_LEFT 33198 /* Move left (left/up arrow) */ /* 33199-33219 unknown */ #define MT4_WMCMD_SAVE_TEMPLATE 33220 /* Save template... */ /* 33221-33229 unknown */ #define MT4_WMCMD_33230 33230 /* Arrow Down */ #define MT4_WMCMD_33231 33231 /* Arrow Up */ #define MT4_WMCMD_33232 33232 /* icons-ticks */ #define MT4_WMCMD_MOUSE_CROSS 33233 /* crosshair */ #define MT4_WMCMD_MOUSE_CURSOR 33234 /* the cursor */ #define MT4_WMCMD_33235 33235 /* Box-cyclical Line */ #define MT4_WMCMD_33236 33236 /* equidistant channel */ #define MT4_WMCMD_33237 33237 /* Fibonacci lines */ #define MT4_WMCMD_33238 33238 /* Box-Fibonacci-arc */ #define MT4_WMCMD_33239 33239 /* Box-Fibonacci-fan */ #define MT4_WMCMD_33240 33240 /* Box Channels, Fibonacci */ #define MT4_WMCMD_33241 33241 /* Box-Gann-grid Hanna */ #define MT4_WMCMD_33242 33242 /* Box-Gann-line Hanna */ #define MT4_WMCMD_33243 33243 /* Box-Gann-fan Hanna */ #define MT4_WMCMD_HLINE 33244 /* horizontal line */ /* 33245 unknown */ #define MT4_WMCMD_33246 33246 /* Box Andrews pitchfork */ #define MT4_WMCMD_33247 33247 /* Box-shape-rectangle */ #define MT4_WMCMD_33248 33248 /* Box-channels-linear regression */ /* 33249-33250 apparently unused */ #define MT4_WMCMD_33251 33251 /* Box-icons-stop */ /* 33252 unknown */ #define MT4_WMCMD_33253 33253 /* text */ #define MT4_WMCMD_33254 33254 /* Box-icons-bad */ #define MT4_WMCMD_33255 33255 /* Box-icons-well */ #define MT4_WMCMD_33256 33256 /* Box-Fibonacci-time-zone */ #define MT4_WMCMD_TRENDLINE 33257 /* trend line */ #define MT4_WMCMD_33258 33258 /* Box-Line-trend line for the corner */ #define MT4_WMCMD_33259 33259 /* Box-figure-triangle */ #define MT4_WMCMD_VLINE 33260 /* Vertical Line */ #define MT4_WMCMD_LABEL 33261 /* text label */ /* 33262-33323 unknown */ #define MT4_WMCMD_UPDATE_DATA 33324 /* This doesn't cause experts start() to run */ /* 33325-33333 unknown */ #define MT4_WMCMD_PERIOD_MN1 33334 /* timeframe MN */ /* 33335-34299 unknown */ #define MT4_WMCMD_34300 34300 /* 34300-34699 custom indicators in alphabetical order */ #define MT4_WMCMD_34700 34700 /* Indicators-moving average of oscillator */ #define MT4_WMCMD_34701 34701 /* Indicators-accelerator oscillator */ #define MT4_WMCMD_34702 34702 /* Indicators-accumulation/distribution */ #define MT4_WMCMD_34703 34703 /* Indicators-alligator */ #define MT4_WMCMD_34704 34704 /* indicators-average directional movement index */ #define MT4_WMCMD_34705 34705 /* indicators-average true range */ #define MT4_WMCMD_34706 34706 /* Indicators-awesome oscillator */ #define MT4_WMCMD_34707 34707 /* Indicators-bears power */ #define MT4_WMCMD_34708 34708 /* indicator-bollinger bands */ #define MT4_WMCMD_34709 34709 /* Indicators-bulls power */ #define MT4_WMCMD_34710 34710 /* Indicators-commodity channel index */ #define MT4_WMCMD_34711 34711 /* Indicators-demarker */ #define MT4_WMCMD_34712 34712 /* Indicators-envelopes */ #define MT4_WMCMD_34713 34713 /* Indicators-force index */ #define MT4_WMCMD_34714 34714 /* Indicators-fractals */ #define MT4_WMCMD_34715 34715 /* Indicators-gator oscillator */ #define MT4_WMCMD_34716 34716 /* Indicators-ichimoku kinko hyo */ #define MT4_WMCMD_34717 34717 /* Indicators-macd */ #define MT4_WMCMD_34718 34718 /* indicators-market facilitation index */ #define MT4_WMCMD_34719 34719 /* Indicators-momentum */ #define MT4_WMCMD_34720 34720 /* indicators-money flow index */ #define MT4_WMCMD_34721 34721 /* indicators-moving averages */ #define MT4_WMCMD_34722 34722 /* Indicators-on balance volume */ #define MT4_WMCMD_34723 34723 /* Indicators-parabolic sar */ #define MT4_WMCMD_34724 34724 /* indicators-relative strength index */ #define MT4_WMCMD_34725 34725 /* indicators-relative vigor index */ #define MT4_WMCMD_34726 34726 /* Indicators-standard deviation */ #define MT4_WMCMD_34727 34727 /* Indicators-stochastic oscillator */ #define MT4_WMCMD_34728 34728 /* Indicators-volumes */ #define MT4_WMCMD_34729 34729 /* Indicators-william's percent range */ /* 34730-34799 unknown */ #define MT4_WMCMD_LOAD_TEMPLATE 34800 /* 34800-34899 load template in alphabetical order */ #define MT4_WMCMD_REMOVE_TEMPLATE 34900 /* 34900-34998 Remove Template in alph. order (conf. dialog) */ #define MT4_WMCMD_KILL_TEMPLATES 34999 /* remove *.tpl (confirmation dialog) */ /* 35000-35399 unknown */ #define MT4_WMCMD_PERIOD_H1 35400 /* timeframe H1 */ #define MT4_WMCMD_OBJECTS_LIST 35402 /* open objects list window */ #define MT4_WMCMD_ORDER_BUYLIMIT 35454 /* order buy limit */ #define MT4_WMCMD_ORDER_BUYSTOP 35455 /* order buy stop */ #define MT4_WMCMD_ORDER_SELLLIMIT 35456 /* order sell limit */ #define MT4_WMCMD_ORDER_SELLSTOP 35457 /* order sell stop */ #define MT4_WMCMD_ORDER_MARKET 35458 /* new order (F9) */ #define MT4_WMCMD_35464 35464 /* right price tag */ #define MT4_WMCMD_35511 35511 /* Graphic template-download template */ /* 35512-37011 unknown */ /* 37012-40000 not inspected */ #define MT4_WMCMD_57602 57602 /* close the current chart */ #define MT4_WMCMD_57603 57603 /* Save as (ascii/csv) */ #define MT4_WMCMD_57604 57604 /* Save as (ascii/csv) - apparently same */ #define MT4_WMCMD_PRINT_DIALOG 57607 /* Open Print... Dialog */ #define MT4_WMCMD_PRINT_DIRECT 57608 /* Print immediately */ #define MT4_WMCMD_PRINT_PREVIEW 57609 /* Open Print Preview dialog */ /* 57610-59675 unknown (re-checked up to 58011) */ /* 59675-... not inspected */ //+------------------------------------------------------------------+ #import "user32.dll" int RegisterWindowMessageA(string MessageName); int PostMessageA(int hwnd, int msg, int wparam, string Name); void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo); #import //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- string ScriptName="aa1"; StartScript(WindowHandle( Symbol(), Period()), ScriptName, false); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ // Import of functions from User32. If their purpose isn't pretty much immediately // clear, then documenting it here frankly isn't going to help much. Requires // "Allow DLL imports" to be turned on. #import "user32.dll" int RegisterWindowMessageA(string MessageName); int PostMessageA(int hwnd, int msg, int wparam, string Name); void keybd_event(int VirtualKey, int ScanCode, int Flags, int ExtraInfo); #import // The hWnd parameter for all these functions is obtained using WindowHandle(). // For example, an EA/script can get the handle of its own chart using // WindowHandle(Symbol(), 0). If the EA/script knows that another chart // is open, then its handle can be obtained using the known symbol and // timeframe. Unpredictable behaviour if there are multiple charts for // the same symbol and timeframe. AutomaticallyAcceptDefaults clears // the configuration window for the new indicator/EA/script by simulating // a press of the Enter key after a small wait. A longer wait might // prove to be more robust. None of this is for the faint-hearted... void StartStandardIndicator(int hWnd, string IndicatorName, bool AutomaticallyAcceptDefaults = false) { int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message"); PostMessageA(hWnd, MessageNumber, 13, IndicatorName); if (AutomaticallyAcceptDefaults) ClearConfigDialog(); } void StartCustomIndicator(int hWnd, string IndicatorName, bool AutomaticallyAcceptDefaults = false) { int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message"); PostMessageA(hWnd, MessageNumber, 15, IndicatorName); if (AutomaticallyAcceptDefaults) ClearConfigDialog(); } void StartEA(int hWnd, string EAName, bool AutomaticallyAcceptDefaults = false) { int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message"); PostMessageA(hWnd, MessageNumber, 14, EAName); if (AutomaticallyAcceptDefaults) ClearConfigDialog(); } void StartScript(int hWnd, string ScriptName, bool AutomaticallyAcceptDefaults = false) { int MessageNumber = RegisterWindowMessageA("MetaTrader4_Internal_Message"); Alert(MessageNumber); PostMessageA(hWnd, 33050, 16, ScriptName); // PostMessageA(hWnd, MessageNumber, 16, ScriptName); if (AutomaticallyAcceptDefaults) ClearConfigDialog(); } void ClearConfigDialog() { Sleep(100); keybd_event(13, 0, 0, 0); } /// önemeli //int PostMessageA(int hWnd,int Msg,int wParam,int IParam)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Guys
I wish to run/execute an mql4 file from a script. This mql4 file is an indicator. What is the syntax to run that file in a script? Would greatly appreciate if someone can help me out. Below is the code snippet. Thanks in advance