Get One Click Trading Lot Size MT4

Get One Click Trading Lot Size MT4

Manage alerts

Loading saved threads...

Sahil Bagdi · External communityPost link
External question — Stack Overflow Stack Exchange Author: Sahil Bagdi Original post: https://stackoverflow.com/questions/76023890 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I want to get lot size from one click trading in MT4, See below image to understand what I am talking about: Using MQL4 Of course Imports: #import "user32.dll" int FindWindowW(string className, string windowName); int FindWindowExW(int hwndParent, int hwndChildAfter, string className, string windowName); int GetWindowTextW(int hWnd, string lpString, int nMaxCount); int GetParent(int hWnd); int SendMessageW(int hWnd, int Msg, int wParam, string lParam); #import Function To get lot size: double GetLotSizeFromOneClickTrading() { int hwndMT4 = FindWindowW("MetaQuotes::MetaTrader::4.00", NULL); if (hwndMT4 == 0) return -1; int hwndMDIClient = FindWindowExW(hwndMT4, 0, "MDIClient", NULL); if (hwndMDIClient == 0) return -2; int hwndAboveChart = FindWindowExW(hwndMDIClient, 0, "Afx:00610000:b:00010003:00000006:000715CD", NULL); if (hwndAboveChart == 0) return -3; int hwndChart = FindWindowExW(hwndAboveChart, 0, "AfxFrameOrView140s", NULL); if (hwndChart == 0) return -4; int hwndEdit = FindWindowExW(hwndChart, 0, "Edit", NULL); if (hwndEdit == 0) return -5; // Get the lot size text from the edit box string lotSizeText; GetWindowTextW(hwndEdit, lotSizeText, 31); // Convert the text to a double and return it return StringToDouble(lotSizeText); } Afx:00610000:b:00010003:00000006:000715CD -> This value change on restart, I got this from WinSpy++ hwndEdit -> This variable will conatain the Edit box handle Now I just need text from it but I am unable to get it My tries: But I am unable to get the lot size, I have tried below: 1.) // Get the lot size text from the edit box string lotSizeText; GetWindowTextW(hwndEdit, lotSizeText, 31); Doesn't do anything and I do not get anything in my variable 2.) // Get the lot size text from the edit box string lotSizeText; const int WM_GETTEXT = 0x000D; SendMessageW(hwndEdit, WM_GETTEXT, 31, lotSizeText); Again, Doesn't do anything I was happy finally finding the Edit box handle but I can't get the text out of it, It's the worst Some help will be really appreaciated
Quote
Report
TTSS000 · External communityPost link
External answer — Stack Overflow Stack Exchange Author: TTSS000 Original post: https://stackoverflow.com/a/76985708 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I had a similar issue. I found that once I click the edit box manually, then GetWindowTextW(...) returns the value correctly. I tried to simulate the mouse click automatically. SendInput(...) is the only API I was able to obtain the same effect. But I don't think it's a beatiful solution.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Sahil Bagdi Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/76023890 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I want to get lot size from one click trading in MT4, See below image to understand what I am talking about: Using MQL4 Of course Imports: #import "user32.dll" int FindWindowW(string className, string windowName); int FindWindowExW(int hwndParent, int hwndChildAfter, string className, string windowName); int GetWindowTextW(int hWnd, string lpString, int nMaxCount); int GetParent(int hWnd); int SendMessageW(int hWnd, int Msg, int wParam, string lParam); #import Function To get lot size: double GetLotSizeFromOneClickTrading() { int hwndMT4 = FindWindowW("MetaQuotes::MetaTrader::4.00", NULL); if (hwndMT4 == 0) return -1; int hwndMDIClient = FindWindowExW(hwndMT4, 0, "MDIClient", NULL); if (hwndMDIClient == 0) return -2; int hwndAboveChart = FindWindowExW(hwndMDIClient, 0, "Afx:00610000:b:00010003:00000006:000715CD", NULL); if (hwndAboveChart == 0) return -3; int hwndChart = FindWindowExW(hwndAboveChart, 0, "AfxFrameOrView140s", NULL); if (hwndChart == 0) return -4; int hwndEdit = FindWindowExW(hwndChart, 0, "Edit", NULL); if (hwndEdit == 0) return -5; // Get the lot size text from the edit box string lotSizeText; GetWindowTextW(hwndEdit, lotSizeText, 31); // Convert the text to a double and return it return StringToDouble(lotSizeText); } Afx:00610000:b:00010003:00000006:000715CD -> This value change on restart, I got this from WinSpy++ hwndEdit -> This variable will conatain the Edit box handle Now I just need text from it but I am unable to get it My tries: But I am unable to get the lot size, I have tried below: 1.) // Get the lot size text from the edit box string lotSizeText; GetWindowTextW(hwndEdit, lotSizeText, 31); Doesn't do anything and I do not get anything in my variable 2.) // Get the lot size text from the edit box string lotSizeText; const int WM_GETTEXT = 0x000D; SendMessageW(hwndEdit, WM_GETTEXT, 31, lotSizeText); Again, Doesn't do anything I was happy finally finding the Edit box handle but I can't get the text out of it, It's the worst Some help will be really appreaciated

Cancel quote

Checking account access…