Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 945

 

Hi all. On page 943 I posted a script about the description of the work and examples of *dll libraries. I figured out a little bit why the script doesn't work.

1. #include<WinUser32.mqh> is not needed in this case.

2. Condition separately if(lastkey != 0) Alert("lastkey=",lastkey); stably correctly outputs the code of the key pressed. If you do a delay, there's no question about how it works.

3. Condition separately if(lastmouse != 0) Alert("lastmouse=",lastmouse); stably outputs 512, even if the mouse doesn't move. It's very rare for other numbers to pop up

In response to clicking mouse buttons.

4. if(lastwnd != 0) Alert("lastwnd=",lastwnd); returns an empty string, most likely because the library is old, not Unicode.

In help, read that the editor can work with *dll libraries, just drag and drop it in the editor window. It won't open.

Question. Will someone help to correct "IdleLib.dll" or better for money. If somewhere there is this topic(and other *dll) show the link.

 
Please advise how to prohibit AutoTrading in my EA (after some event), i.e. to set button of terminalAutoTrading to prohibit. I tried to call constant ACCOUNT_TRADE_ALLOWED and change its value to false, but compiler says that this will have no effect ( ACCOUNT_TRADE_ALLOWED == false; //expression has no effect)
 
Try this


#import "user32.dll"
int GetForegroundWindow();
int  PostMessageW(int  hWnd, int  Msg, int  wParam, string lParam);
#import
#define  WM_COMMAND                    0x0111

после определенного события PostMessageW(GetForegroundWindow(), WM_COMMAND, 33020, (string) 0);
 
amavladi:
Please advise how to prescribe (after a certain event) a ban on AutoTrading in an EA, i.e. to set programmatically button of terminalAutoTrading to prohibit. I tried to call constant ACCOUNT_TRADE_ALLOWED and change its value to false, but compiler says that this will have no effect ( ACCOUNT_TRADE_ALLOWED == false; //expression has no effect)

This task (to forbid the EA to trade) is very easily solved with semaphores (true/false.... allow/disallow trading).

Or is it important to press the "Auto Trade" button?

 
charter:

This task (to forbid the EA to trade) is very easily solved with semaphores (true/false.... allow/disallow trading).

Or is it so important to press the "AutoTrading" button?

If I cannot disableAutoTrading for the whole terminal, then of course I will do it. The matter is that I have several Expert Advisors running on my terminal and I

I want to use a separate EA to monitor Equity and disable AutoTrading for all EAs simultaneously in case of emergency, for example, when Aquity is reduced by 50%

 
amavladi:

If I cannot forbidAutoTrading for the whole terminal, I will surely do so. The thing is that I have several Expert Advisors running on my terminal and I

I wanted to use separate EA to monitor Account Profit and disable AutoTrading for all EAs at the same time in case of emergency, for example, when Account Profit drops by 50%

I have not checked it a bit. You have to replace WinUser32.mqh with attached one to make it work.

Checked it now, it works. And here are some more gimmicks

#include <WinUser32.mqh>

void OnTick()
{
 после определенного события wCommands(20); 
}

void wCommands(int com)
{
switch(com)
{
case  1:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33137, (string)0); return; //M1 |
case  2:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33138, (string)0); return; //M5 |
case  3:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33139, (string)0); return; //M15 |
case  4:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33140, (string)0); return; //M30 |
case  5:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33135, (string)0); return; //H1 |
case  6:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33136, (string)0); return; //H4 |
case  7:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33134, (string)0); return; //D1 |
case  8:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33141, (string)0); return; //W1 |
case  9:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33334, (string)0); return; //MN |
case 10:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33050, (string)0); return; //Удалить эксперт |
case 11:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 35426, (string)0); return; //Удалить скрипт |
case 12:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 57602, (string)0); return; //Закрыть окно текушего графика |
                                                                           57604              //Сохранить как
                                                                           57607              //Вызов диспетчера печати
                                                                           57608              //Печать графика
                                                                           57609              //Предварительный просмотр
case 13:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33048, (string)0); return; //Вызов свойств экстерта |
case 14:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33157, (string)0); return; //Вызов свойств графика |
case 15:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33025, (string)0); return; //Увеличение масштаба |
case 16:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33026, (string)0); return; //Уменьшение масштаба |
case 17:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33018, (string)0); return; //Переключение на бары |
case 18:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33019, (string)0); return; //Переключение на свечи |
case 19:        PostMessageA(WindowHandle(Symbol(), Period()), WM_COMMAND, 33022, (string)0); return; //Переключение на линию |

case 20:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 33020, (string)0); return; //Переключение кнопки советника |
case 21:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 35429, (string)0); return; //Окно логина и пароля |
case 22:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 37400, (string)0); return; //Пересканировать сервера |
case 23:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 35403, (string)0); return; //Глобальные переменные |
case 24:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 35419, (string)0); return; //Список индикаторов |
case 25:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 33265, (string)0); return; //Открывает окно настройки |
case 26:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 33262, (string)0); return; //Архив катировак |
case 27:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 33309, (string)0); return; //Обзор рынка |
case 28:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 33310, (string)0); return; //Навигатор |
case 29:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 33314, (string)0); return; //Терминал |
case 30:        PostMessageA(GetForegroundWindow(), WM_COMMAND, 33315, (string)0); return; //Тестер стратегий |
}
}


And I corrected previous post so that it works without replacing WinUser32.mqh

Files:
winuser32.mqh  71 kb
 

Greetings all... I know the problem is as follows. When I compile the code, the variable d takes the value 110 and the indicator shows everything correctly, but with the arrival of a new bar, the variable becomes 109 and, consequently, it completely screws up all of the indicator readings. I've already fucked up..... What the fuck????

int start()
  {
  int limit,Val,Oi;
  
   drawonce();
//limit=Bars;
if (b!=Bars){
b=Bars;
datetime ldt_BeginDay = iTime (NULL, PERIOD_D1,Q); 
int li_Bar = iBarShift (NULL, 0, ldt_BeginDay);
d=0;

 for(int i=li_Bar-10; i>=0; i--){  
 
 
if (curDay!=TimeDay(Time[i])) {

curDay=TimeDay(Time[i]);
OOO=iClose(NULL,PERIOD_D1,Q-d+1)-iOpen(NULL,PERIOD_D1,Q-d+1);
if (volarr[Q-d]!=0) Val=volarr[Q-d]-volarr[Q-d+1];
if (oiarr[Q-d]!=0)  Oi=oiarr[Q-d]-oiarr[Q-d+1];
d++;
}
Buffer1[i]=Val;
Buffer2[i]=Oi;
Buffer3[i]=OOO;

}   
   
   
}
   
   WindowRedraw();
   Comment(Q,"   ",d);
   return(0);
  }

Why during compilation one value is variable, but with the arrival of a new bar the variable changes?????

 
Well..... in my case even professionals without strong????
 
Can anyone explain the difference between compiling and the arrival of a new bar????
 
nikelodeon:
Can someone explain the difference between compiling and the arrival of a new bar????
And what's the difference between m\y "green" and "sweet"? ;)