paladin80: Must close on a stop loss. Forex opens at 00:00 GMT.
But will close not at the stopLoss price, but at the first price, which may be much lower than the stopLoss! And TakeProfit will close for sure. Therefore it is better not to leave with StopLoss, and even better not to leave positions for the weekend!
How can I find out the address of my user function? That is, if my listing says
int start()
...
int num=myFunc()//вызов функции
...
int myFunc()//описание моей функции
{
...
}
then how do I get the address of myFunc? I need it to find out how to find out address of WndProc (I describe with custom function) for passing further to class parameter.
How can I find out the address of my user function? That is, if my listing says
then how do I get the address of myFunc? I need it to find out how to find out address of WndProc (I describe with custom function) for passing further to class parameter.
Who says it even has an address? it's an MQL4-function: it's not even compiled in the literal sense of the word, but runs through the interpreter at runtime.
Who said that it even has an address? It's an MQL4 function: it's not even compiled in the literal sense of the word, but runs through an interpreter at runtime.
That's where the dog is buried. I'm just sorry for 2 or 3 weeks of wasting my time, because I've chosen an independent windowing interface for my robot within just MQL4+WinAPI without any self-written dlls. I'm sorry I didn't realize it earlier, I'm sorry for my own code and developments.
To summarize. You cannot create an overlapped (i.e. not a child) window without copying the code into your dll, because when describing WNDCLASS (or WNDCLASSEX)
typedef struct tagWNDCLASSEX {// это с MSDN
UINT cbSize;
UINT style;
WNDPROC lpfnWndProc;//<-
int cbClsExtra;
int cbWndExtra;
HINSTANCE hInstance;
HICON hIcon;
HCURSOR hCursor;
HBRUSH hbrBackground;
LPCTSTR lpszMenuName;
LPCTSTR lpszClassName;
HICON hIconSm;
} WNDCLASSEX, *PWNDCLASSEX;
lines indicated by the arrow when packing the structure into an int array
lpwcx[0]=0x30;//cbSize// это на MQL4
lpwcx[1]=0x0A23;//style//lpwcx[2]=lpfnWndProc;<-
lpwcx[3]=0;//cbClsExtra
lpwcx[4]=0;//cbWndExtra
lpwcx[5]=GetModuleHandleA(lpModuleName);//hInstance
lpwcx[6]=LoadIconA(hInstance,IDI[0]);//hIcon
lpwcx[7]=LoadCursorA(hInstance,IDC[0]);//hCursor
lpwcx[8]=GetStockObject(WHITE_BRUSH);//hbrBackground
lpwcx[9]=StrStrA(lpszMenuName,lpszMenuName);
lpwcx[10]=StrStrA(lpszClassName,lpszClassName);
lpwcx[11]=0;//hIconSm//передаём структуру в упакованном интовом массиве и регистрируем класс
atom=RegisterClassExA(lpwcx[12]);
array, the address of window procedure, i.e. mouse and keyboard handler for this window, is passed. The window procedure in MQL4 can be implemented as a user-defined function, but it is impossible to get its address within the interpreter, so there is nothing to pass. The maximum that is possible in MQL4 is to use the standard window classes, but they will be used only as the child windows. To put it simply, a window created by the indicator cannot be grasped with a mouse and placed over the terminal border (since it will be a child window), while an overlapped window can be placed over the terminal border. The child window on standard window classes is already implemented in mt4gui.dll, if anyone needs. But the overlapped window with its own mouse and keyboard handler is impossible.
I ask moderators to post this dialog and all related messages to a separate topic like "how to create a window in MQL4", so that others won't make the same mistakes and will be able to find it in a search engine.
Does the broker read the ip address of the trader's computer only in online mode or is it technically possible to upload the history from some folder in MT4?
I decided to implement "hotkeys" (without using the control keys like Ctrl, Alt, Shift). But the code doesn't work.
#property indicator_chart_window#import "user32.dll"bool RegisterHotKey(int hWnd, int id, int fsModifiers, int vk);
bool PeekMessage (int& lpMsg[7], int hWnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
bool UnregisterHotKey (int hWnd, int id);
#importexternstring s0="идентификатор горячей клавиши";
externint id;
externstring s1="код клавиши (список см. winuser.h)";
externint vk;
externstring s2="номер окна (от нуля до WindowsTotal()-1)";
externint aWindowNumber;
bool PM;
int init()
{
ObjectCreate("Smile",OBJ_LABEL,aWindowNumber,0,0);
ObjectSet("Smile",OBJPROP_XDISTANCE,0);
ObjectSet("Smile",OBJPROP_YDISTANCE,0);
ObjectSetText("Smile", StringSetChar("", 0, 75), 50, "WingDings", Red);
return(RegisterHotKey(WindowHandle(Symbol(), Period()), id, 0, vk));
}
int deinit()
{
ObjectDelete("Smile");
WindowRedraw();
return(UnregisterHotKey(WindowHandle(Symbol(), Period()), id));
}
int start()
{
int lpMsg[7];
/*
Структура lpMsg для WM_HOTKEY:
0 - хэндл окна//HWND(MSDN)//int(MQL4)
1 - WM_HOTKEY (0x0312)//UINT(MSDN)//int(MQL4) 2 - заданный id//WPARAM(MSDN)//int(MQL4) 3 - млардшее слово - ноль (модификатор, - не задаём), старшее - код виртуальной клавиши//LPARAM(MSDN)//int(MQL4) 4 - время//DWORD(MSDN)//int(MQL4) 5 - координата х мышки//структура POINT. LONG(MSDN)//int(MQL4) 6- координата у мышки//LONG(MSDN)//int(MQL4)
*/
PM=PeekMessage(lpMsg, WindowHandle(Symbol(), Period()), 0, 0, 1);//1 = PM_REMOVEif (lpMsg[1]==0x0312){
if(lpMsg[2]==id){
switch(StringGetChar(ObjectDescription("Smile"),0)){
case74 : ObjectSetText("Smile", StringSetChar("", 0, 75), 50, "WingDings", Red);
case75 : ObjectSetText("Smile", StringSetChar("", 0, 74), 50, "WingDings", Red);
}
}
}
return(0);
}
Why would it not work? In theory, the smiley is supposed to change. I set 81 (Q key code), but you can set anything there. Here are the key codes:
123456784950515253545556
Q W E R T Y U I
8187698284898573
A S D F G H J K
6583687071727475
Z X C V B N M ,
90886786667877188
Added: can't call PeekMessage - system error 127 "specified procedure not found". RegisterHotKey returns 1 (true). I tried to look calling RtlGetLastWin32Error() with NativeAPI after PeekMessage, it does not even come to it. And to point
Must close on a stop loss. Forex opens at 00:00 GMT.
But will close not at the stopLoss price, but at the first price, which may be much lower than the stopLoss! And TakeProfit will close for sure. Therefore it is better not to leave with StopLoss, and even better not to leave positions for the weekend!
How can I find out the address of my user function? That is, if my listing says
then how do I get the address of myFunc? I need it to find out how to find out address of WndProc (I describe with custom function) for passing further to class parameter.
Must close on a stop loss. Forex opens at 00:00 GMT.
It is far from certain, it may well close at the first quote. You have to read the documents, and the brokerage companies write whatever they want.
How can I find out the address of my user function? That is, if my listing says
then how do I get the address of myFunc? I need it to find out how to find out address of WndProc (I describe with custom function) for passing further to class parameter.
Who says it even has an address? it's an MQL4-function: it's not even compiled in the literal sense of the word, but runs through the interpreter at runtime.
Why doesn't the expert modify orders?
Here's the function:
Called at the start like this:
Who said that it even has an address? It's an MQL4 function: it's not even compiled in the literal sense of the word, but runs through an interpreter at runtime.
That's where the dog is buried. I'm just sorry for 2 or 3 weeks of wasting my time, because I've chosen an independent windowing interface for my robot within just MQL4+WinAPI without any self-written dlls. I'm sorry I didn't realize it earlier, I'm sorry for my own code and developments.
To summarize. You cannot create an overlapped (i.e. not a child) window without copying the code into your dll, because when describing WNDCLASS (or WNDCLASSEX)
lines indicated by the arrow when packing the structure into an int array
array, the address of window procedure, i.e. mouse and keyboard handler for this window, is passed. The window procedure in MQL4 can be implemented as a user-defined function, but it is impossible to get its address within the interpreter, so there is nothing to pass. The maximum that is possible in MQL4 is to use the standard window classes, but they will be used only as the child windows. To put it simply, a window created by the indicator cannot be grasped with a mouse and placed over the terminal border (since it will be a child window), while an overlapped window can be placed over the terminal border. The child window on standard window classes is already implemented in mt4gui.dll, if anyone needs. But the overlapped window with its own mouse and keyboard handler is impossible.
I ask moderators to post this dialog and all related messages to a separate topic like "how to create a window in MQL4", so that others won't make the same mistakes and will be able to find it in a search engine.
Good day!
Does the broker read the ip address of the trader's computer only in online mode or is it technically possible to upload the history from some folder in MT4?
I decided to implement "hotkeys" (without using the control keys like Ctrl, Alt, Shift). But the code doesn't work.
Why would it not work? In theory, the smiley is supposed to change. I set 81 (Q key code), but you can set anything there. Here are the key codes:
Added: can't call PeekMessage - system error 127 "specified procedure not found". RegisterHotKey returns 1 (true). I tried to look calling RtlGetLastWin32Error() with NativeAPI after PeekMessage, it does not even come to it. And to point
- the compilation error will appear.