The EA operates within the context of the chart in which it has been attached and of the platform instance (and therefore account) in which that chart is open.
Not sure if that answers your question; perhaps you can explain your issue in more detail?
CB
Maybe I was ambiguous.
So, there are four, five or more open charts with diffrent currency in one MetaTrader. I used to attach my EAs or scripts by hotkeys.
That's why I would like to make an indicator which will shows a big sign on the active chart. Then I won't miss the chart I wish to run my EAs or scripts on.
Hi,Relative .
This is a sample indicator. :-)
#property indicator_chart_window #import "user32.dll" int GetParent(int hWnd); int SendMessageA(int hWnd,int Msg,int wParam,int lParam); #import #define WM_MDIGETACTIVE 0x0229 int start() { int Parent = GetParent(GetParent(WindowHandle(Symbol(),Period()))); int MyWND = GetParent(WindowHandle(Symbol(),Period())); int ActiveMDI = SendMessageA(Parent, WM_MDIGETACTIVE, 0, 0); if(ActiveMDI == MyWND ){ Comment("Active"); }else{ Comment(""); } return(0); }
hi Relative,
I have been using the snippet that you posted here for some time and its wonderful but I thought that you could help solve this problem...
I am trying to use the same logic to hook the left mouse click (along with a hotkey, have that covered though) to execute this code to modify take profit on an order...
//---------------------------------
#import "user32.dll"
bool GetAsyncKeyState(int nVirtKey);// this is for the hot keys
int GetParent(int hWnd);//this is to define if window is active
int SendMessageA(int hWnd, int Msg,int wParam,int lParam);//this is to define if window is active
#import
#import "kernel32.dll"
int WinExec(string NameEx, int dwFlags);
#import
//---------------------------------
//define
#define WM_MDIGETACTIVE 0x0229
#define WM_NCLBUTTONUP 0x00A2//metaquotes user32.dll
//Active window check
//The Active Widow Part of the Code is working great...
int start ()
{
int Parent = GetParent(GetParent(WindowHandle(Symbol(),Period())));
int MyWND = GetParent(WindowHandle(Symbol(),Period()));
int ActiveMDI = SendMessageA(Parent, WM_MDIGETACTIVE, 0, 0);
if(ActiveMDI == MyWND ){
//fire mouse hook if in active window (notworking)
int MouseHookProc(int hWnd,int nCode, Word wParam, dWord lParam);// mouse click
if(nCode >=0 && (wParam==WM_MOUSEMOVE || wParam==WM_NCMOUSEMOVE)) {
if(!WindowHandle(Symbol(),Period())) hwnd=FindWindow(0, MyWND);
MSLLHOOKSTRUCT *mhs=(MSLLHOOKSTRUCT*)lParam;
int PostMessage(int hwnd, int WM_MOUSEHOOK, int wParam, 0);
return CallNextHookEx(hHook,nCode,wParam,lParam); }
//I need this to return to WindowOnDropped( ) for this script
int digits = MarketInfo(Symbol(),MODE_DIGITS);
double value = NormalizeDouble(WindowPriceOnDropped(),digits);
for(int i=OrdersTotal()-1;i>=0;i--){
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderType()==OP_BUY)
if(value<Bid)
OrderModify(OrderTicket(),OrderOpenPrice(),value, OrderTakeProfit(),OrderExpiration(),CLR_NONE);
}
}
}//End if(nCode >=0
return(0);
}
t
Thank You,
Stan

- 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 Programmers!
Can I check whether the chart used by the EA is the active chart in the MetaTrader?
Thank you.
Relative