Erros, bugs, perguntas - página 2142

 
Rashid Umarov:

Já passaram quase 10 anos desde que foi publicado https://www.mql5.com/ru/code/8007

informação do mercado em mt5 não funciona ...

Honestamente, estou confuso....


AccountInfoInteger(ACCOUNT_LOGIN)

Quando o terminal inicia, dá 0 e deve dar o número de conta....

0 dá 0 durante alguns segundos, mesmo que o terminal já esteja ligado à rede.

 

Outra questão sobre PlaySound

é utilizado no indicador.

A melodia deve tocar durante 3 segundos.

OnTimer não é adequado porque 3 segundos é muito e se menos do que isso, a melodia ladra

OnChartEvent não é adequado porque é necessário um clique do rato ou do teclado

OnCalculyate não é adequado porque a melodia ladra e não vai acabar


O sal de toda a canção Sleep não pode ser usado nas mesas giratórias ...


Pergunta aos conhecedores, como fazer tocar PlaySound mais de 2-3 segundos no indicador ???

 
Vladimir Pastushak:

Pergunta para os conhecedores, como fazer PlaySound tocar durante mais de 2-3 segundos no indicador ???

Executar o guião no objecto OBJ_CHART. Desta forma, é possível fazer um leitor de áudio completo no indicador.

 
fxsaber:

Executar o guião sobre um objecto OBJ_CHART. Desta forma, é possível fazer um leitor de áudio completo no indicador.

Como fazê-lo ? Não percebo...

 

Erros de compilação

class A {
public:                         //(*)
static void g1() {}
protected:                      //(**)
static void g2() {}
};
class B : A {};                 //(***)
class C : public B {
public:                         //                Основание:
       void f1() { this.g1(); } //(1) ошибка      ***    препятствуют
static void f2() {   A::g1(); } //(2) ошибка ???  *** не действуют (прямой доступ) +
                                //                  * не препятствует              +
                                //                    противоречие с (5)- там нормально
       void f3() { this.g2(); } //(3) ошибка      ***    препятствуют
static void f4() {   A::g2(); } //(4) ошибка ???  *** не действуют (прямой доступ) +
                                //                 ** не препятствует
};
void OnStart()
{                               //                Основание:
    A::g1();                    //(5) нормально
    A::g2();                    //(6) ошибка       **    препятствуют
}

Os erros (2) e (4) não são justificados pelo menos devido à contradição entre (2) e (5)

  • (2) C::f2 não tem acesso a A::g1
  • (5) OnStart tem acesso a A::g1

e a sintaxe é a mesma, então como é que a OnStart é melhor?

Os compiladores C++ podem produzir resultados diferentes

 
Access violation at 0x00000001407742FB read to 0xFFFFFFFFFFFFFFFF
              0000000140774020 48895 C2418        mov        [rsp+0x18], rbx
              0000000140774025 57                push       rdi
              0000000140774026 4156              push       r14
              0000000140774028 4157              push       r15
              000000014077402 A 4883 EC20          sub        rsp, 0x20
              000000014077402 E 8 B7A08            mov        edi, [rdx+0x8]
              0000000140774031 488 BDA            mov        rbx, rdx
              0000000140774034 0 FB75202          movzx      edx, word [rdx+0x2]
              0000000140774038 4 C8BF1            mov        r14, rcx
              000000014077403 B 0 FB6C2            movzx      eax, dl
              000000014077403 E 0 FB6CA            movzx      ecx, dl
              0000000140774041 C0E803            shr        al, 0x3
              0000000140774044 A801              test       al, 0x1
              0000000140774046 0 F845E010000      jz         dword 0x1407741aa

              000000014077404 C 498 B8638020000    mov        rax, [r14+0x238]
              0000000140774053 4 C8B80300B0000    mov        r8, [rax+0xb30]
              000000014077405 A 4 D85C0            test       r8, r8
              000000014077405 D 0 F8447010000      jz         dword 0x1407741aa

              0000000140774063 4533 FF            xor        r15d, r15d
              0000000140774066 6683 CA01          or         dx, 0x1
              000000014077406 A 66895302          mov        [rbx+0x2], dx
              000000014077406 E 418 BFF            mov        edi, r15d
              0000000140774071 4 C897B1C          mov        [rbx+0x1c], r15
              0000000140774075 458 B08            mov        r9d, [r8]
              0000000140774078 4585 C9            test       r9d, r9d
              000000014077407 B 0 F84A0020000      jz         dword 0x140774321

              0000000140774081 498 B9638020000    mov        rdx, [r14+0x238]
              0000000140774088 4885 D2            test       rdx, rdx
              000000014077408 B 7430              jz         0x1407740bd

              000000014077408 D 488 B8AC80E0000    mov        rcx, [rdx+0xec8]
              0000000140774094 4885 C9            test       rcx, rcx
              0000000140774097 7419              jz         0x1407740b2

              0000000140774099 488 B82300B0000    mov        rax, [rdx+0xb30]
              00000001407740 A0 4885 C0            test       rax, rax
              00000001407740 A3 740 D              jz         0x1407740b2

              00000001407740 A5 3 B38              cmp        edi, [rax]
              00000001407740 A7 7309              jae        0x1407740b2
              00000001407740 A9 448 BC7            mov        r8d, edi
              00000001407740 AC 4 A8B04C1          mov        rax, [rcx+r8*8]
              00000001407740 B0 EB06              jmp        0x1407740b8

              00000001407740 B2 498 BC7            mov        rax, r15
              00000001407740 B5 448 BC7            mov        r8d, edi
              00000001407740 B8 483 BC3            cmp        rax, rbx
              00000001407740 BB 7416              jz         0x1407740d3

              00000001407740 BD FFC7              inc        edi
              00000001407740 BF 413 BF9            cmp        edi, r9d
              00000001407740 C2 72 C4              jb         0x140774088

              00000001407740 C4 488 B5C2450        mov        rbx, [rsp+0x50]
              00000001407740 C9 4883 C420          add        rsp, 0x20
              00000001407740 CD 415 F              pop        r15
              00000001407740 CF 415 E              pop        r14
              00000001407740 D1 5 F                pop        rdi
              00000001407740 D2 C3                ret        

              00000001407740 D3 4885 C9            test       rcx, rcx
              00000001407740 D6 7437              jz         0x14077410f

              00000001407740 D8 488 B82300B0000    mov        rax, [rdx+0xb30]
              00000001407740 DF 4885 C0            test       rax, rax
              00000001407740 E2 742 B              jz         0x14077410f

              00000001407740 E4 3 B38              cmp        edi, [rax]
              00000001407740 E6 7327              jae        0x14077410f
              00000001407740 E8 4 A8B04C1          mov        rax, [rcx+r8*8]
              00000001407740 EC 4885 C0            test       rax, rax
              00000001407740 EF 741 E              jz         0x14077410f

              00000001407740 F1 4 C89781C          mov        [rax+0x1c], r15
              00000001407740 F5 488 B82C80E0000    mov        rax, [rdx+0xec8]
              00000001407740 FC 4 A8B0CC0          mov        rcx, [rax+r8*8]
              0000000140774100 44897908          mov        [rcx+0x8], r15d
              0000000140774104 488 B82C80E0000    mov        rax, [rdx+0xec8]
              000000014077410 B 4 E893CC0          mov        [rax+r8*8], r15
              000000014077410 F 4538 BE4F290000    cmp        [r14+0x294f], r15b
              0000000140774116 0 F8505020000      jnz        dword 0x140774321

              000000014077411 C 498 B8638020000    mov        rax, [r14+0x238]
              0000000140774123 F780280700000000  test       dword [rax+0x728], 0x1000000
                               0001
              000000014077412 D 0 F84EE010000      jz         dword 0x140774321

              0000000140774133 B93C050000        mov        ecx, 0x53c
              0000000140774138 66398826070000    cmp        [rax+0x726], cx
              000000014077413 F 0 F82DC010000      jb         dword 0x140774321

              0000000140774145 498 B8E98000000    mov        rcx, [r14+0x98]
              000000014077414 C 4885 C9            test       rcx, rcx
              000000014077414 F 0 F84CC010000      jz         dword 0x140774321

              0000000140774155 488 B01            mov        rax, [rcx]
              0000000140774158 488 B9090070000    mov        rdx, [rax+0x790]
              000000014077415 F 488 D054ACDFBFF    lea        rax, [rip-0x432b6]
              0000000140774166 483 BD0            cmp        rdx, rax
              0000000140774169 0 F85E0010000      jnz        dword 0x14077434f

              000000014077416 F 488 B050A5F4C00    mov        rax, [rip+0x4c5f0a]
              0000000140774176 0 FB68098420000    movzx      eax, byte [rax+0x4298]
              000000014077417 D 84 C0              test       al, al
              000000014077417 F 0 F849C010000      jz         dword 0x140774321

              0000000140774185 448 BCF            mov        r9d, edi
              0000000140774188 4 C8D0529FC2C00    lea        r8, [rip+0x2cfc29]
              000000014077418 F BA01000000        mov        edx, 0x1
              0000000140774194 498 BCE            mov        rcx, r14
              0000000140774197 488 B5C2450        mov        rbx, [rsp+0x50]
              000000014077419 C 4883 C420          add        rsp, 0x20
              00000001407741 A0 415 F              pop        r15
              00000001407741 A2 415 E              pop        r14
              00000001407741 A4 5 F                pop        rdi
              00000001407741 A5 E9C6560000        jmp        0x140779870

              00000001407741 AA F6C101            test       cl, 0x1
              00000001407741 AD 0 F847D010000      jz         dword 0x140774330

              00000001407741 B3 F6C206            test       dl, 0x6
              00000001407741 B6 0 F8574010000      jnz        dword 0x140774330

              00000001407741 BC 4533 FF            xor        r15d, r15d
              00000001407741 BF 48896 C2440        mov        [rsp+0x40], rbp
              00000001407741 C4 488 B6B1C          mov        rbp, [rbx+0x1c]
              00000001407741 C8 44897 B18          mov        [rbx+0x18], r15d
              00000001407741 CC 44897 B08          mov        [rbx+0x8], r15d
              00000001407741 D0 4885 ED            test       rbp, rbp
              00000001407741 D3 0 F8443010000      jz         dword 0x14077431c

              00000001407741 D9 4885 FF            test       rdi, rdi
              00000001407741 DC 0 F84FE000000      jz         dword 0x1407742e0

              00000001407741 E2 440 FB703          movzx      r8d, word [rbx]
              00000001407741 E6 664183 F859        cmp        r8w, 0x59
              00000001407741 EB 7411              jz         0x1407741fe

              00000001407741 ED 4 C397B2C          cmp        [rbx+0x2c], r15
              00000001407741 F1 750 B              jnz        0x1407741fe

              00000001407741 F3 664183 F85D        cmp        r8w, 0x5d
              00000001407741 F8 0 F85E2000000      jnz        dword 0x1407742e0

              00000001407741 FE B901000000        mov        ecx, 0x1
              0000000140774203 488 D530C          lea        rdx, [rbx+0xc]
              0000000140774207 8 B02              mov        eax, [rdx]
              0000000140774209 85 C0              test       eax, eax
              000000014077420 B 740 F              jz         0x14077421c

              000000014077420 D 480 FAFF8          imul       rdi, rax
              0000000140774211 FFC1              inc        ecx
              0000000140774213 4883 C204          add        rdx, 0x4
              0000000140774217 83 F904            cmp        ecx, 0x4
              000000014077421 A 7 CEB              jl         0x140774207

              000000014077421 C 664183 F85D        cmp        r8w, 0x5d
              0000000140774221 7517              jnz        0x14077423a

              0000000140774223 4 C8D04FD00000000  lea        r8, [rdi*8+0x0]
              000000014077422 B 33 D2              xor        edx, edx
              000000014077422 D 488 BCD            mov        rcx, rbp
              0000000140774230 E82BEEA0FF        call       0x140183060  ; #14396 (terminal64.exe)
              0000000140774235 E9A6000000        jmp        0x1407742e0

              000000014077423 A 664183 F859        cmp        r8w, 0x59
              000000014077423 F 7517              jnz        0x140774258

              0000000140774241 498 D8E98010000    lea        rcx, [r14+0x198]
              0000000140774248 448 BC7            mov        r8d, edi
              000000014077424 B 488 BD5            mov        rdx, rbp
              000000014077424 E E86D48FEFF        call       0x140758ac0  ; #29073 (terminal64.exe)
              0000000140774253 E988000000        jmp        0x1407742e0

              0000000140774258 4889742448        mov        [rsp+0x48], rsi
              000000014077425 D 488 BF7            mov        rsi, rdi
              0000000140774260 4885 FF            test       rdi, rdi
              0000000140774263 7426              jz         0x14077428b

              0000000140774265 6666660 F1F840000  o16 nop        [rax+rax+0x0]
                               000000
              0000000140774270 4 C8B432C          mov        r8, [rbx+0x2c]
              0000000140774274 488 BD5            mov        rdx, rbp
              0000000140774277 498 BCE            mov        rcx, r14
              000000014077427 A E86CD783FF        call       0x13ffb19eb  ; #5243 (terminal64.exe)
              000000014077427 F 8 B4304            mov        eax, [rbx+0x4]
              0000000140774282 4803 E8            add        rbp, rax
              0000000140774285 4883 EF01          sub        rdi, 0x1
              0000000140774289 75 E5              jnz        0x140774270

              000000014077428 B F6430220          test       byte [rbx+0x2], 0x20
              000000014077428 F 744 A              jz         0x1407742db

              0000000140774291 488 B542438        mov        rdx, [rsp+0x38]
              0000000140774296 498 BCE            mov        rcx, r14
              0000000140774299 E8B2540000        call       0x140779750  ; #29352 (terminal64.exe)
              000000014077429 E 4885 C0            test       rax, rax
              00000001407742 A1 7438              jz         0x1407742db

              00000001407742 A3 B9EC020000        mov        ecx, 0x2ec
              00000001407742 A8 66398826070000    cmp        [rax+0x726], cx
              00000001407742 AF 722 A              jb         0x1407742db

              00000001407742 B1 488 B7B1C          mov        rdi, [rbx+0x1c]
              00000001407742 B5 4885 F6            test       rsi, rsi
              00000001407742 B8 7421              jz         0x1407742db

              00000001407742 BA 660 F1F440000      o16 nop        [rax+rax+0x0]
              00000001407742 C0 488 B17            mov        rdx, [rdi]
              00000001407742 C3 498 D8E38010000    lea        rcx, [r14+0x138]
              00000001407742 CA E82151FEFF        call       0x1407593f0  ; #29085 (terminal64.exe)
              00000001407742 CF 8 B4304            mov        eax, [rbx+0x4]
              00000001407742 D2 4803 F8            add        rdi, rax
              00000001407742 D5 4883 EE01          sub        rsi, 0x1
              00000001407742 D9 75 E5              jnz        0x1407742c0

              00000001407742 DB 488 B742448        mov        rsi, [rsp+0x48]
              00000001407742 E0 0 FB703            movzx      eax, word [rbx]
              00000001407742 E3 B980000000        mov        ecx, 0x80
              00000001407742 E8 663 BC1            cmp        ax, cx
              00000001407742 EB 721 B              jb         0x140774308

              00000001407742 ED B900800000        mov        ecx, 0x8000
              00000001407742 F2 663 BC1            cmp        ax, cx
              00000001407742 F5 7311              jae        0x140774308
              00000001407742 F7 488 B531C          mov        rdx, [rbx+0x1c]
   crash -->  00000001407742 FB 486342 FC          movsxd     rax, dword [rdx-0x4]
              00000001407742 FF 482 BD0            sub        rdx, rax
              0000000140774302 4889531 C          mov        [rbx+0x1c], rdx
              0000000140774306 EB04              jmp        0x14077430c

              0000000140774308 488 B531C          mov        rdx, [rbx+0x1c]
              000000014077430 C 498 D8EA0000000    lea        rcx, [r14+0xa0]
              0000000140774313 E8A805FEFF        call       0x1407548c0  ; #29022 (terminal64.exe)

00: 0x00000001407742FB
01: 0x000000000000000A
 
Vladimir Pastushak:

Como assim? Não percebo...

Reproduzir qualquer duração do ficheiro de som do indicador.

Script Scripts\PlaySound.mq5

#include <GlobalVariables.mqh> // https://www.mql5.com/ru/forum/189649#comment_4854618

void OnStart()
{
  const string SoundName = "SOUND";

  if (GlobalVariableCheck(SoundName))
  {
    PlaySound(_GlobalVariableGet<string>(SoundName));
  
    _GlobalVariableDel(SoundName);
  }
}


Indicador

#property indicator_chart_window

#property indicator_buffers 0
#property indicator_plots indicator_buffers

#include <fxsaber\Expert.mqh>  // https://www.mql5.com/ru/code/19003
#include <GlobalVariables.mqh> // https://www.mql5.com/ru/forum/189649#comment_4854618

class PLAYER
{
public:
  const string Name;
  const long Chart;
  const long chartID;
  
  PLAYER( const long iChart = 0 ) : Name(__FILE__), Chart(iChart ? iChart : ::ChartID()),
                                    chartID(::ObjectCreate(this.Chart, this.Name, OBJ_CHART, 0, 0, 0)   &&
                                            ::ObjectSetInteger(this.Chart, this.Name, OBJPROP_XSIZE, 0) &&
                                            ::ObjectSetInteger(this.Chart, this.Name, OBJPROP_YSIZE, 0) ?
                                            ::ObjectGetInteger(this.Chart, this.Name, OBJPROP_CHART_ID) : this.Chart)
  {
  }
  
  ~PLAYER()
  {
    if (this.chartID != this.Chart)
      ::ObjectDelete(this.Chart, this.Name);
  }
  
  void PlaySound( string FileName, const string ScriptName = "Scripts\\PlaySound.ex5" ) const
  {
    static const string SoundName = "SOUND";
    
    if (_GlobalVariableSet(SoundName, FileName))
    {
      MqlParam Params[1];
      
      Params[0].string_value = ScriptName;
      
      if (!EXPERT::Run(this.chartID, Params))      
        _GlobalVariableDel(SoundName);
    }    
  }
};

int OnCalculate( const int rates_total , const int prev_calculated, const int, const double& [] )
{  
  if (!prev_calculated)
  {
    const PLAYER Player;
    
    Player.PlaySound("email.wav");
  }

  return(rates_total);
}
 

PlaySound( NULL ) não funciona

void OnStart()
{
    if ( !PlaySound( "timeout.wav" ) ) Print( "1:", GetLastError());
    if ( !PlaySound( NULL          ) ) Print( "2:", GetLastError());
}

Resultado: 2:4002

e não pára a reprodução

 
fxsaber:

Reproduzir qualquer comprimento de ficheiro de som a partir do indicador.

Script Scripts\PlaySound.mq5


Indicador

Será que entendi correctamente, executou o guião para reproduzir o ficheiro?

 
fxsaber:

Olá, isto é um acidente terminal ou um acidente com um meta-editor? Em que circunstâncias ocorreu o acidente?

Qual é a taxa de bits/versão do terminal/CA?