Errors, bugs, questions - page 1401

 
Ilya Malev:

This script is for MetaTrader 4 :)

In MT4 just all the data is precisely calculated by the terminal before it is received in mql4 programs

Yes, I checked afterwards

ZS: I wonder if these message codes that work for MT4 will not work for MT5 )

 
Alexandr Bryzgalov:
Yes, I checked afterwards.
Why don't you post the version for MT5? ) I don't know what it's for in MT4, but in MT5 it would be of real use - in view of the hopelessness of the situation I wrote above.
 
Ilya Malev:
Can you post version for MT5? ) I don't know what it's for in MT4, but in MT5 it will be of real use - in view of the hopelessness of the situation I wrote above.

Basically here is for MT5, but I'm not sure (or rather I'm sure it's not the right one) that the command code(

PostMessageA(hwnd,WM_COMMAND,33324,0);

) is correct.

Compiles without errors, runs without errors.

//+------------------------------------------------------------------+
//|                                                 ChartRefresh.mq5 |
//|                                                      sanyooooook |
//|                                                 http://sn-bot.ru |
//+------------------------------------------------------------------+
#property copyright "sanyooooook"
#property link      "http://sn-bot.ru"
#property version   "1.00"
#property strict
#include <WinUser32.mqh>
int      hwnd=0,cnt=0;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   datetime last_time=TimeCurrent()-5;
   while(!IsStopped())
     {
      datetime cur_time=TimeCurrent();
      if(hwnd==0)
        {
         hwnd=WindowHandleMQL4(Symbol(),Period());
         if(hwnd!=0)
            Print("Chart window detected");
        }
      //--- refresh window not frequently than 1 time in 2 seconds
      if(hwnd!=0 && cur_time-last_time>=2)
        {
         //PostMessageA(hwnd,WM_COMMAND,33324,0); 
         PostMessageW(hwnd,WM_COMMAND,33324,0);//так наверное правильней
         last_time=cur_time;
        }
      Sleep(100);
     }
  }
//+--------------------------------
int WindowHandleMQL4(string symbol,
                     int tf)
  {
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   long currChart,prevChart=ChartFirst();
   int i=0,limit=100;
   while(i<limit)
     {
      currChart=ChartNext(prevChart);
      if(currChart<0) break;
      if(ChartSymbol(currChart)==symbol
         && ChartPeriod(currChart)==timeframe)
         return((int)currChart);
      prevChart=currChart;
      i++;
     }
   return(0);
  }
  ENUM_TIMEFRAMES TFMigrate(int tf)
  {
   switch(tf)
     {
      case 0: return(PERIOD_CURRENT);
      case 1: return(PERIOD_M1);
      case 5: return(PERIOD_M5);
      case 15: return(PERIOD_M15);
      case 30: return(PERIOD_M30);
      case 60: return(PERIOD_H1);
      case 240: return(PERIOD_H4);
      case 1440: return(PERIOD_D1);
      case 10080: return(PERIOD_W1);
      case 43200: return(PERIOD_MN1);
      
      case 2: return(PERIOD_M2);
      case 3: return(PERIOD_M3);
      case 4: return(PERIOD_M4);      
      case 6: return(PERIOD_M6);
      case 10: return(PERIOD_M10);
      case 12: return(PERIOD_M12);
      case 16385: return(PERIOD_H1);
      case 16386: return(PERIOD_H2);
      case 16387: return(PERIOD_H3);
      case 16388: return(PERIOD_H4);
      case 16390: return(PERIOD_H6);
      case 16392: return(PERIOD_H8);
      case 16396: return(PERIOD_H12);
      case 16408: return(PERIOD_D1);
      case 32769: return(PERIOD_W1);
      case 49153: return(PERIOD_MN1);      
      default: return(PERIOD_CURRENT);
     }
  }
 

mouse commands definitely work )

#define  MOUSEEVENTF_MOVE              0x0001 // mouse move
#define  MOUSEEVENTF_LEFTDOWN          0x0002 // left button down
#define  MOUSEEVENTF_LEFTUP            0x0004 // left button up
#define  MOUSEEVENTF_RIGHTDOWN         0x0008 // right button down
#define  MOUSEEVENTF_RIGHTUP           0x0010 // right button up
#define  MOUSEEVENTF_MIDDLEDOWN        0x0020 // middle button down
#define  MOUSEEVENTF_MIDDLEUP          0x0040 // middle button up
#define  MOUSEEVENTF_WHEEL             0x0800 // wheel button rolled
#define  MOUSEEVENTF_ABSOLUTE          0x8000 // absolute move
              mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,25000,35000, 0, 0); 
              Sleep(50);
              mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTDOWN,25000,35000, 0, 0); 
              Sleep(50);
              mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTUP,25000,35000, 0, 0); 
              Sleep(500);     
 
Alexandr Bryzgalov:

Basically here is for MT5, but I'm not sure (or rather I'm sure it's not the right one) that the command code(

) is correct.

Compiles without errors, runs without errors.

For some reason it doesn't work. If you want, you can continue the discussion in your script branch.

 
Ilya Malev:

For some reason it's not working. If you want, you can continue the discussion in your script branch.

Yes, it doesn't work, the code(33324) is not suitable for MT5.

I'll leave it at that for now, busy with other things.

ZS: all that remains is to find the right command code. )

 

For what purposedoes the testerdelete the files in the tester\Agent\MQL5\Files folder before testing the indicator?

 

What does the error mean in tester 2015.10.15 19:22:44.860 1999.05.26 00:00:00 debug version of 'SomeIndicator.ex5', please recompile it ?

P.S. After recompiling it seems to load, but want to understand what was wrong.

 
Compilation error: 'const' - name expected
struct S { int i; }
      s1 = { 1 }, //нормально
      s2 = { 2 }, //нормально
сonst s3 = { 3 }; //'const' - name expected
Rare, but encountered
 
Ilya Malev:

What does the error mean in tester 2015.10.15 19:22:44.860 1999.05.26 00:00:00 debug version of 'SomeIndicator.ex5', please recompile it ?

P.S. After recompiling it seems to load, but want to understand what was wrong.

The EX5 passed to the strategy tester was prepared for debugging (debug version), please recompile it.
Reason: