Emulation of ticks from an EA/indicator - page 5

 
Zhunko: Igor, this way of disconnecting from the internet is not good. A lot of things don't work in this mode. You don't need to disable internet access.

no, his cog - on the first page, works fine in winHp, you're wrong, but in win7 for some reason it did not want to work for me

Meat:There's an assumption that the code doesn't work where there's a 64bit win. I just have 32 so can't check.

no, i have win7 max 32bit

 
IgorM:

No, his cog - on the first page, works fine in winHP, you're wrong, but in win7 for some reason it did not want to work for me

Igor, I'm not talking about Alexey's code, I'm talking about disconnecting from the Internet.
 
Zhunko:

How do you trade from a ticking indicator? MQL4 does not provide that.

Really! Why do I need the addition of the ticking indicator that cannot trade, if I can do everything in a looped Expert Advisor? This will not require any difficulties with WinAPI, MT4 interface will not become slower, and the EA will operate three times faster. Why complicate things like that?

Well, let's leave this discussion, it will not lead to anything constructive anyway, most likely on the contrary. You have already started to distort (I don't know, intentionally or not) the meaning of what I have written, I have written in Russian that I trade not from an indicator, but from a metatrader, while you are again talking about some kind of trading from an indicator. If you have interpreted something wrong from what I have said, then I explain: the phrase "indicator is used in trading" does not mean that the deals are executed by an indicator.

 
Meat:

I have already started to distort (I don't know if intentionally or not) the meaning of what I have written. You have already started to distort (I do not know whether intentionally or not) the meaning of what I have written, I have written in Russian that I trade not from an indicator, but from a metatrader, and you are again about some trading from an indicator. If you misinterpreted something I said earlier, then I explain: the phrase "the indicator is used in trading" does not mean that the indicator performs the transaction.

So, an Expert Advisor that receives signals from an indicator trades? And of course, MT4 does all this? Is it correct? If so, my question remains. Why not let the Expert Advisor do all this? It's the rational thing to do.
 
Zhunko: Igor, I'm not talking about Alexey's code, I'm talking about disconnecting from the Internet.

yes, i understand, but his code works when the internet is switched off in winhr

The code, in principle, is needed, we make it as an inluder and have ticks in any code at the weekend, especially useful when working with graphical objects - people often ask to make "smart rulers" and so on, and at the weekend you have to make code "by eye".

 
IgorM:

yes, i understand, but his code works when the internet is switched off in winhr

And the code, in principle, is needed, make it as an inluder and on weekends have a tick in any code, in particular useful when working with graphical objects - people often ask to make "smart rulers" and so on, and on weekends have to make code "by eye".

Well, I posted code that works everywhere. One line. No timer. It works in all indicators and on any OS. It is enough for an experiment.

I also gave the code for the Expert Advisor above. The line that generates the tick for the Expert Advisor can be substituted in the code of the indicator. In this case, it will also affect the expert.

The library can be simplified. Everything is already implemented there.

 
Zhunko:
So, an Expert Advisor that receives signals from an indicator trades? And of course MT4 does all this? Is it correct? If so, my question remains. Why not let the Expert Advisor do all that? It's the rational thing to do.

If we were talking about automatic trading, then the question of indicators or ticks would not be raised at all, because they are not needed there. So you must have misunderstood the point of this thread from the start.

 

By the way, here's another thing. The line

TimerCode[byte/4] += (value[i]>>(8*j)&0xFF) <<(byte%4*8);

should be replaced by

TimerCode[byte/4] |= (value[i]>>(8*j)&0xFF) <<(byte%4*8);

Otherwise an error will occur when calling SetMyTimer again, or you can just initialize the array with zero before starting the loop.

As for Win7, I never managed to reproduce the problem there, everything works fine for me. And doing debugging blindly is unrealistic. I wonder if there's anyone else here who has this code also works on seventh? Because I'm getting the feeling that I'm running some kind of special Windows.

 

I think I found what the error was. Here is the corrected version of the SetMyTimer function.

int SetMyTimer(int interval)
{    
  int MT4InternMsg= RegisterWindowMessageA("MetaTrader4_Internal_Message");
  int hWnd= WindowHandle(Symbol(),Period());
  int PostMsgAddr= GetProcAddress(GetModuleHandleA("user32.dll"),"PostMessageA");
  if (PostMsgAddr==0) return(0);
  // push ebp; move ebp,esp; push 01; push 02; push MT4InternMsg; push hWnd; mov eax,PostMsgAddr; call eax; pop ebp; ret 0010;    
  int value[]={ 0x55, 0x8B,0xEC, 0x6A,01, 0x6A,02, 0x68,0000, 0x68,0000, 0xB8,0000, 0xFF,0xD0, 0x5D, 0xC2,0x10 };
  int len[]=  { 1,    1,   1,    1,   1,  1,   1,  1,   4,    1,   4,    1,   4,    1,   1,    1,    1,   2 };
  value[8]=MT4InternMsg;  value[10]=hWnd;  value[12]=PostMsgAddr; 
  int byte=0;  ArrayInitialize(TimerCode,0);
  for (int i=0;  i<ArraySize(value);  i++)
    for (int j=0;  j<len[i];  j++, byte++)
      TimerCode[byte/4] |= value[i]>>(8*j)&0xFF<<(byte%4*8);

  return ( SetTimer(hWnd, TimerId, interval, TimerCode) );
}

It should work fine now.

 

nope..., not working

no errors in the log, even the internet in the terminal, on the advice of Vadim, did not disconnect - there are no ticks on output anyway

Reason: