Errors, bugs, questions - page 2228

 
Konstantin:

All code output and for those who can't structure code by hand, ME has a styliser:


The styler didn't help, see if the code isn't written correctly
 
Impreza:

Please help what the problem is I can't understand....

Since you didn't provide complete information, let's turn on the telepathy.

You have incorrectly declared function mouse_event in your WinUser32.mqh file.

Correct it to this:

#define _WIN64  // Только для 64-разрядного терминала!

#include <WinDef.mqh>

#import "User32.dll"
  void mouse_event( DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData, ULONG_PTR dwExtraInfo );
#import

Files:
WinDef.mqh  2 kb
 
Koldun Zloy:

Since you haven't provided full information, let's turn on the telepathy.

Your WinUser32.mqh file does not declare the mouse_event function correctly.

Correct it to this:


would you be allowed to provide full information?
 
Impreza:
would it be possible to provide you with full information?

I meant theWinUser32.mqh file, the size of the terminal, the code in which the error is reproduced, the line in which the error occurs.

Is it a secret?

 
Impreza:
The styler didn't help, see if the code isn't written correctly

I'm sure it's not written correctly, try writing it standing up instead of sitting down, sometimes tambourine dancing helps ))

you were asked for complete code to reproduce the error, you've ignored it, the weekend is over, so move on ))

 
Koldun Zloy:

I meant theWinUser32.mqh file, the size of the terminal, the code in which the error is reproduced, the line in which the error occurs.

Is this a secret?

Still not working, I change more errors become, maybe it's in the library, how it affects it who knows? Everything worked on another computer, nothing was changed...
 
Impreza:
It's still not working, I change more errors, maybe it's the library, who knows how it affects this? Everything worked on the other computer, nothing was changed...

So it is a secret after all.

Good for you. Hold on! Don't give up!

 
Impreza:


Use Alt+S to insert formatted code. https://www.mql5.com/ru/articles/24#editor

MQL5.community - Памятка пользователя
MQL5.community - Памятка пользователя
  • www.mql5.com
Теперь вы можете не только читать статьи и скачивать программы на языке MQL5, но и участвовать в обсуждении интересующих вас тем на Форуме, оставлять комментарии к статьям и опубликованным кодам. Кроме того, вы можете не только выкладывать собственные разработки в Code Base, но и публиковать Статьи, за которые мы предлагаем вознаграждение...
 
Sergey Savinkin:

Use Alt+S to insert formatted code. https://www.mql5.com/ru/articles/24#editor

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                                   Copyright 2017 |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property version   "1.00"
#property strict
#property indicator_buffers 1
#property indicator_plots   0
//#property indicator_color1 Lime
datetime Tim=D'2018.10.10 23:00:00';
double y[];
datetime tine=0; string typ="";

input int   bye_x=1525; // Bye - x
input int   bye_y=432; // Bye - y
input int   sell_x=1525; // Sell - х
input int   sell_y=468; // Sell - у
input int   Stop_Limit=5; // Stop_Limit
input int   delta=2; // Spike

#include <WinUser32.mqh>
#import "user32.dll" 
bool  SetCursorPos(int PosX,int PosY);
#import 
input bool Allert=true; // Allert

const long allowed_accounts[]={ 8432237,240712,50188344,50186534,50187101,9675587,50224049,5000007084,50211205}; // 465438
int password_status=-1;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {

   EventSetMillisecondTimer(20);

   SetIndexBuffer(0,y,INDICATOR_DATA);

   long account=AccountInfoInteger(ACCOUNT_LOGIN);

   for(int i=0; i<ArraySize(allowed_accounts); i++)
      if(account==allowed_accounts[i])
        {
         password_status=1;
         break;
        }

   tine=TimeCurrent()+5;
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTimer()
  {
   if(Tim>TimeCurrent())
     {

      double agr=(SymbolInfoDouble(Symbol(),SYMBOL_BID)+SymbolInfoDouble(Symbol(),SYMBOL_ASK))/2;
      y[0]=agr;

      for(int i=ArraySize(y)-1;i>=1;i--){y[i]=y[i-1];}

      if(y[1]+delta*Point()<y[0] || y[2]+delta*Point()<y[0] || 
         y[3]+delta*Point()<y[0] || y[4]+delta*Point()<y[0] || 
         y[5]+delta*Point()<y[0] || y[6]+delta*Point()<y[0] || 
         y[7]+delta*Point()<y[0] || y[8]+delta*Point()<y[0] || 
         y[9]+delta*Point()<y[0] || y[10]+delta*Point()<y[0] || 
         y[11]+delta*Point()<y[0] || y[12]+delta*Point()<y[0] || 
         y[13]+delta*Point()<y[0] || y[14]+delta*Point()<y[0] || 
         y[15]+delta*Point()<y[0] || y[16]+delta*Point()<y[0] || 
         y[17]+delta*Point()<y[0] || y[18]+delta*Point()<y[0] || 
         y[19]+delta*Point()<y[0] || y[20]+delta*Point()<y[0])

         if(password_status==1)
            Up_sig("Call_sig");

      if(y[1]-delta*Point()>y[0] || y[2]-delta*Point()>y[0] || 
         y[3]-delta*Point()>y[0] || y[4]-delta*Point()>y[0] || 
         y[5]-delta*Point()>y[0] || y[6]-delta*Point()>y[0] || 
         y[7]-delta*Point()>y[0] || y[8]-delta*Point()>y[0] || 
         y[9]-delta*Point()>y[0] || y[10]-delta*Point()>y[0] || 
         y[11]-delta*Point()>y[0] || y[12]-delta*Point()>y[0] || 
         y[13]-delta*Point()>y[0] || y[14]-delta*Point()>y[0] || 
         y[15]-delta*Point()>y[0] || y[16]-delta*Point()>y[0] || 
         y[17]-delta*Point()>y[0] || y[18]-delta*Point()>y[0] || 
         y[19]-delta*Point()>y[0] || y[20]-delta*Point()>y[0])

         if(password_status==1)
            Dn_sig("Sell_sig");

        }else {Alert("Демо-период завершён ",TimeToString(Tim));
     }

  }
//+------------------------------------------------------------------+

void Up_sig(string txt)
  {
   if(TimeCurrent()>(tine+Stop_Limit))
     {
      tine=TimeCurrent();

      if(Allert) Alert(txt);

      SetCursorPos(bye_x,bye_y);
      mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
      mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Dn_sig(string txt)
  {
   if(TimeCurrent()>(tine+Stop_Limit))
     {
      tine=TimeCurrent();

      if(Allert) Alert(txt);

      SetCursorPos(sell_x,sell_y);
      mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
      mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

     }
  }
//+------------------------------------------------------------------+
 
Impreza:
#property indicator_chart_window

input int  bye_x = 1525;   // Bye - x
input int  bye_y = 432;    // Bye - y
input int  sell_x = 1525;  // Sell - х
input int  sell_y = 468;   // Sell - у
input int  Stop_Limit = 5; // Stop_Limit
input int  delta = 2;      // Spike
input bool Allert = true;  // Allert

#define  MOUSEEVENTF_LEFTDOWN    0x0002 // left button down
#define  MOUSEEVENTF_LEFTUP      0x0004 // left button up

#define _WIN64  // Только для 64-разрядного терминала!

#include <WinDef.mqh>

#import "user32.dll" 
   BOOL SetCursorPos( int PosX, int PosY );
   void mouse_event( DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData, ULONG_PTR dwExtraInfo );
#import 

const long allowed_accounts[] = {8432237, 240712, 50188344, 50186534, 50187101, 9675587, 50224049, 5000007084, 50211205}; // 465438
datetime Tim = D'2018.10.10 23:00:00';
double y[];
int password_status = -1;
datetime tine = 0;
string typ = "";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
   EventSetMillisecondTimer( 20 );
   
   SetIndexBuffer( 0, y, INDICATOR_DATA );
   
   long account = AccountInfoInteger( ACCOUNT_LOGIN );
   
   for( int i = 0; i < ArraySize( allowed_accounts ); i++ ){
      if( account == allowed_accounts[i] )
      {
         password_status = 1;
         break;
      }
   }
   
   tine = TimeCurrent() + 5;
//---
   return INIT_SUCCEEDED;
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   return rates_total;
}
//+------------------------------------------------------------------+
void OnTimer()
{
   if( Tim > TimeCurrent() )
   {
      double agr = (SymbolInfoDouble( Symbol(), SYMBOL_BID ) + SymbolInfoDouble( Symbol(), SYMBOL_ASK )) / 2.0;
      y[0] = agr;

      for( int i = ArraySize(y)-1; i >= 1; i--)
      {
         y[i] = y[i-1];
      }
      
      double dp = delta * Point();

      if( y[1] + dp < y[0] || y[2] + dp < y[0] || 
         y[3] + dp < y[0] || y[4] + dp < y[0] || 
         y[5] + dp < y[0] || y[6] + dp < y[0] || 
         y[7] + dp < y[0] || y[8] + dp < y[0] || 
         y[9] + dp < y[0] || y[10] + dp < y[0] || 
         y[11] + dp < y[0] || y[12] + dp < y[0] || 
         y[13] + dp < y[0] || y[14] + dp < y[0] || 
         y[15] + dp < y[0] || y[16] + dp < y[0] || 
         y[17] + dp < y[0] || y[18] + dp < y[0] || 
         y[19] + dp < y[0] || y[20] + dp < y[0])
      {
         if( password_status == 1 ){
            Up_sig( "Call_sig" );
         }
      }

      if(y[1] - dp > y[0] || y[2] - dp > y[0] || 
         y[3] - dp > y[0] || y[4] - dp > y[0] || 
         y[5] - dp > y[0] || y[6] - dp > y[0] || 
         y[7] - dp > y[0] || y[8] - dp > y[0] || 
         y[9] - dp > y[0] || y[10] - dp > y[0] || 
         y[11] - dp > y[0] || y[12] - dp > y[0] || 
         y[13] - dp > y[0] || y[14] - dp > y[0] || 
         y[15] - dp > y[0] || y[16] - dp > y[0] || 
         y[17] - dp > y[0] || y[18] - dp > y[0] || 
         y[19] - dp > y[0] || y[20] - dp > y[0])
      {
         if( password_status == 1 ){
            Dn_sig( "Sell_sig" );
         }
      }
   }
   else {
      Alert( "Демо-период завершён ", TimeToString( Tim ) );
   }
}
//+------------------------------------------------------------------+
void Up_sig( string txt )
{
   if( TimeCurrent() > (tine + Stop_Limit) )
   {
      tine = TimeCurrent();
      
      if( Allert ) Alert( txt );
      
      SetCursorPos( bye_x, bye_y );
      mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
      mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
   }
}
//+------------------------------------------------------------------+
void Dn_sig( string txt )
{
   if( TimeCurrent() > (tine + Stop_Limit) )
   {
      tine=TimeCurrent();
      
      if( Allert ) Alert( txt );
      
      SetCursorPos( sell_x, sell_y );
      mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 );
      mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
   }
}
//+------------------------------------------------------------------+
Reason: