0
Views
0
Downloads
0
Favorites
Alerter
//+------------------------------------------------------------------+
//| Alerter.mq4 |
//| Copyright © 2009, ÏàâåëÈâàíîâè÷ (api) |
//| p231970@hotmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, ÏàâåëÈâàíîâè÷ (api)"
#property link "p231970@hotmail.com"
#import "user32.dll"
int GetAncestor (int hWnd, int gaFlags);
int GetParent (int hWnd);
int GetDlgItem (int hDlg, int nIDDlgItem);
int GetWindowRect(int hDlg, int& ltrb[]);
int SendMessageA (int hWnd, int Msg, int wParam, int lParam);
int PostMessageA (int hWnd, int Msg, int wParam, int lParam);
int GetLastActivePopup (int hWnd);
int GetFocus();
int SetDlgItemTextA(int hWnd, int nIDDlgItem, string text);
#import
#import "kernel32.dll"
int lstrcat(string dst, string src);
#import
#define WM_COMMAND 0x0111
#define WM_KEYDOWN 0x0100
#define WM_LBUTTONDOWN 0x0201
#define BM_SETCHECK 0x00F1
#define VK_TAB 0x09
#define VK_INSERT 0x2D
#define BST_CHECKED 0x0001
#define CB_SETCURSEL 0x014E
#define CB_SELECTSTRING 0x014D
#define CBN_SELCHANGE 1
int hMain=0;
double Value;
string oName = "line-handler";
color LineColor=Red;
int LineWidth=2;
int Counter;
int start()
{
Value = Bid;
double StartVal = Bid;
ObjectCreate(oName,OBJ_HLINE,0,0,Value);
ObjectSetText(oName,"Price alert level",0);
ObjectSet(oName,OBJPROP_COLOR,LineColor);
ObjectSet(oName,OBJPROP_WIDTH,LineWidth);
WindowRedraw();
while(!IsStopped())
{
RefreshRates();
double newval = ObjectGet(oName,OBJPROP_PRICE1);
if(newval!=Value)
{
Counter=0;
Value=newval;
}
Counter++;
if(Counter>=10 && newval!=StartVal) break;
Sleep(100);
}
if(IsStopped())
{
ObjectDelete(oName);
return(0);
}
hMain=GetAncestor(WindowHandle(Symbol(),Period()),2);
int hWnd = FindAlertTab();
if(hWnd!=0)
{
int hCtrl = GetLastActivePopup(hMain);
PostMessageA(hWnd,WM_KEYDOWN,VK_INSERT,0);
while(!IsStopped() && GetLastActivePopup(hMain)==hCtrl) Sleep(100);
hWnd = GetLastActivePopup(hMain);
hCtrl = GetDlgItem(hWnd,0x461);
if(hCtrl!=0)
{
// Óñòàíîâêà ðàçðåøåíèÿ ñèãíàëà
PostMessageA(hCtrl,BM_SETCHECK,BST_CHECKED,0);
}
hCtrl = GetDlgItem(hWnd,0x3EA);
if(hCtrl!=0)
{
// Óñòàíîâêà âûáðàííîãî äåéñòâèÿ
PostMessageA(hCtrl,CB_SETCURSEL,0,0);
Sleep(200);
PostMessageA(hWnd,WM_COMMAND,(CBN_SELCHANGE<<16)+0x3EA,hCtrl);
}
hCtrl = GetDlgItem(hWnd,0x546);
if(hCtrl!=0)
{
SendMessageA(hCtrl,CB_SELECTSTRING,-1,lstrcat(Symbol(),""));
}
hCtrl = GetDlgItem(hWnd,0x427);
if(hCtrl!=0)
{
// Óñòàíîâêà óñëîâèÿ
if(Value<Bid)
PostMessageA(hCtrl,CB_SETCURSEL,0,0);
else
PostMessageA(hCtrl,CB_SETCURSEL,1,0);
Sleep(200);
PostMessageA(hWnd,WM_COMMAND,(CBN_SELCHANGE<<16)+0x427,hCtrl);
}
// Óñòàíîâêà çíà÷åíèÿ
SetDlgItemTextA(hWnd, 0x4DA, DoubleToStr(Value,Digits));
hCtrl = GetDlgItem(hWnd,0x520);
if(hCtrl!=0)
{
// Óñòàíîâêà çâóêà
PostMessageA(hCtrl,CB_SETCURSEL,0,0);
}
hCtrl = GetDlgItem(hWnd,0x555);
if(hCtrl!=0)
{
// Óñòàíîâêà òàéìàóòà
PostMessageA(hCtrl,CB_SETCURSEL,0,0);
}
hCtrl = GetDlgItem(hWnd,0x49A);
if(hCtrl!=0)
{
// Óñòàíîâêà ïîâòîðîâ
PostMessageA(hCtrl,CB_SETCURSEL,0,0);
}
Sleep(200);
PostMessageA(hWnd,WM_COMMAND,1,0);
}
ObjectDelete(oName);
return(0);
}
int FindAlertTab()
{
int hWnd=GetDlgItem(hMain,0xE81E);
int hRet = hWnd;
if(hWnd!=0)
{
hWnd=GetDlgItem(hWnd,0x51);
hRet = hWnd;
if(hWnd!=0)
{
hRet = GetDlgItem(hRet,0x81b6);
}
}
return(hRet);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---