[¡Archivo!] Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen de largo. No puedo ir a ningún sitio sin ti - 4. - página 250

 
Gracias.
 
Arrastro el script al gráfico y no pasa nada, ni en el mismo gráfico con el EA ni en otro diferente. Es la primera vez que utilizo el script. Se ve así.
//+------------------------------------------------------------------+
//|                                                   таймфрейм .mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#include <ServicesMT4.mqh>
void start()
  {
   int hwndChart = WindowHandle("EURUSD", PERIOD_H1);
   while (!IsStopped())
    {
     for (int i = 0; i < 9 && !IsStopped(); i++)
      {
       ServiceSetTimeframeByNumber(hwndChart, i);
       Sleep(4000);
      }
    }
  }
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
El Asesor Experto tiene este aspecto.
//+------------------------------------------------------------------+
//|                                                  таймфрейммм.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#include <ServicesMT4.mqh>
void start()
  {
   int hwndChart = WindowHandle(Symbol(),Period());
   while (!IsStopped())
    {
     for (int i = 0; i < 9; i++)
      {
       ServiceSetTimeframeByNumber(hwndChart, i);
       Sleep(4000);
      }
    }
  }
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
Y como variante, respectivamente.
//+------------------------------------------------------------------+
//|                                                 таймфреймммм.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#include <ServicesMT4.mqh>
int hwndChart = NULL;
void init()
 {
  hwndChart = WindowHandle(Symbol(),Period()); // Получаем системный дескриптор графика.
  ServiceRefreshChart(hwndChart, 1000); // Запускаем обновление графика каждую 1 секунду.
 }

void start()
 {
  ServiceStopRefreshChart(hwndChart); // Останавливаем обновление. Больше не требуется.
  while (!IsStopped())
   {
    for (int i = 0; i < 9; i++)
     {
      ServiceSetTimeframeByNumber(hwndChart, i);
      Sleep(4000);
     }
   }
 }
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
 

Este script me funciona:

#include <ServicesMT4.mqh>
void start()
  {
   int hwndChart = WindowHandle("EURUSD", PERIOD_H1);
   while (!IsStopped())
    {
     for (int i = 0; i < 9 && !IsStopped(); i++)
      {
       ServiceSetTimeframeByNumber(hwndChart, i);
       Sleep(4000);
      }
    }
  }

Este experto trabaja de forma extraña. Se podría decir que no funciona. Por sí mismo, el TF sólo cambia hasta M5.

#include <ServicesMT4.mqh>
int hwndChart = NULL;

void init()
 {
  if (UninitializeReason() != REASON_CHARTCHANGE) hwndChart = WindowHandle(Symbol(),Period()); // Получаем системный дескриптор графика.
  ServiceRefreshChart(hwndChart, 1000); // Запускаем обновление графика каждую 1 секунду.
 }

void start()
 {
  ServiceStopRefreshChart(hwndChart); // Останавливаем обновление. Больше не требуется.
  while (!IsStopped())
   {
    for (int i = 0; i < 9; i++)
     {
      ServiceSetTimeframeByNumber(hwndChart, i);
      Sleep(4000);
     }
   }
 }
Esperando las garrapatas naturales. No está claro de dónde viene el problema. Algo ha cambiado en las nuevas versiones de MT4.
 
Zhunko:

Este script me funciona:

Este experto trabaja de forma extraña. Se podría decir que no funciona. Por sí mismo, el TF sólo conmuta hasta M5.

Esperaré a las garrapatas naturales. No entiendo cómo apareció el problema. Algo ha cambiado en las nuevas versiones de MT4.


Cierto, ¿por qué necesitamos un software que falla constantemente tanto que es imposible aplicarlo?

Utiliza las funciones estándar y todo irá bien.

El indicador se colocará en el gráfico y se actualizará manualmente en lugar de los ticks.

No olvide permitir el DLL en la configuración

//+------------------------------------------------------------------+
//|                                                    таймфрейм.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_chart_window
#import "user32.dll"
   int   PostMessageA(int  hWnd,int  Msg,int  wParam,string lParam);
#import
#define WM_COMMAND                     0x0111
int delimiter = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {//return;
   int    counted_bars=IndicatorCounted();
//----
   if(delimiter<3){delimiter++;Comment(delimiter);return(0);}
   delimiter=0;
   fChangePeriod();
//----
   return(0);
  }
//+------------------------------------------------------------------+
void fChangePeriod(){int ii,hwd = WindowHandle(Symbol(),Period());
   switch(Period()){
      case PERIOD_W1    : ii = 33134; break; //PERIOD_D1;
      case PERIOD_D1    : ii = 33136; break; //PERIOD_H4;
      case PERIOD_H4    : ii = 33135; break; //PERIOD_H1;
      case PERIOD_H1    : ii = 33140; break; //PERIOD_M30;
      case PERIOD_M30   : ii = 33139; break; //PERIOD_M15;
      case PERIOD_M15   : ii = 33138; break; //PERIOD_M5;
      case PERIOD_M5    : ii = 33137; break; //PERIOD_M1;
      case PERIOD_M1    : ii = 33141; break; //PERIOD_W1;
   }     
   PostMessageA(hwd, WM_COMMAND, ii, 0);
   return;
}
 
//+------------------------------------------------------------------+
// Скрипт для переключ таймфрейма.
// Для работы скрипта необходимо разрешить вызов функций из системных DLL:
// Сервис -> Настройки  -> Советники -> Разрешить импорт DLL.
#property show_inputs
#import "user32.dll"
        int PostMessageA(int hWnd,int Msg,int wParam,int lParam);
        void keybd_event(int bVk,int bScan,int dwFlags,int dwExtraInfo);
#import
#define WM_COMMAND 0x0111
extern int Per=5;
//+------------------------------------------------------------------+
int  start()
{int wParam,hWnd=WindowHandle(Symbol(),Period());
switch(Per)
        {case PERIOD_M1: wParam=33137;break;
         case PERIOD_M5: wParam=33138;break;
         case PERIOD_M15:wParam=33139;break;
         case PERIOD_M30:wParam=33140;break;
         case PERIOD_H1: wParam=33135;break;
         case PERIOD_H4: wParam=33136;break;
         case PERIOD_D1: wParam=33134;break;
         case PERIOD_W1: wParam=33141;break;
         case PERIOD_MN1:wParam=33334;break;}
PostMessageA(hWnd,WM_COMMAND,wParam,0);
keybd_event(0xD,0,0,0);keybd_event(0x23,0,0,0);return(0);}
//+------------------------------------------------------------------+ 
 
FAQ:


Cierto, ¿por qué necesitas un software que falla constantemente de forma tan grave que no se puede utilizar?

Utiliza las características estándar y estarás bien.

El indicador debe ser graficado y actualizado manualmente en lugar de ticks.

No olvide permitir la DLL en la configuración

¿Qué, tienes los hechos? ¿Y si estaba bromeando? Ni siquiera puedes comprobarlo. Se necesita una cierta habilidad.

PostMessage() también me funciona. Sólo que está mal. Intenta hacerlo con SendMessage(). Espero que sepas la diferencia.

Rustam, no todo el mundo puede manejar el software más sencillo. No tienes suerte. Algunos incluso tienen un sistema operativo con fallos.

 
¡¡¡¡¡¡¡Gracias!!!!!!!
 

¡¡¡¡¡El script funciona!!!!!

Pero sólo cambia al M5.

 
Dimka-novitsek:
¡¡¡¡¡El script funciona!!!!!
¿Cuál?
 

El último que dio Roll. En cualquier caso, al menos funciona en M5, por lo demás no he visto todavía ningún trabajo visual de guiones y asesores aquí. Nunca había visto tales guiones aquí.

Cómo arreglarlo, cómo hacerlo inteligente, no lo sé. Ah, entiendo.