Preguntas de los principiantes MQL4 MT4 MetaTrader 4 - página 173

 

Cada día encuentro mucha más expresión y negatividad en esta comunidad, y nadie reacciona.

De todos modos, ahí acaba la pregunta.

 
Nikolai Semko :

Si desea crear sus propios controles de teclado y de teclado (CHART_MOUSE_SCROLL, CHART_KEYBOARD_CONTROL ...), debe desactivarlo.
Pero no es posible.
La velocidad de Pero tal interfaz será del BE son significativamente más altos que los de la base, ya que no es posible utilizar funciones asíncronas El muy INHIBIDO ChartGetInteger

Muchas gracias de nuevo, Nikolai. Intenté convertir tu CanvasBar.mq5 a mt4, añadí algunas opciones de entrada en cuanto a anchos / colores / ... (por lo que se puede utilizar, por ejemplo, "para simular ninjatrader estilo de velas")

Archivos adjuntos:
CanvasBar.png  7 kb
CanvasBar.mq4  12 kb
 

¡Hola! ¡Tengo un indicador estándar de iEnvelopes!
No consigo que funcione como necesito.
¡Es decir, la necesidad de cuando la vela tocó o cruzó la línea en la vela actual hacia arriba, a continuación, abrió BUY, y la vela tocó o cruzó la línea en la vela actual hacia abajo, a continuación, abrió SELL..... y sucedió una vez (la señal de golpe y todo, otra señal de golpe y todo constantemente)!

Inv_0_1 = iEnvelopes(_Symbol, time2_method, envel, envel_method, envelshag, envel_Price, envelproc, MODE_UPPER, 0); 
    Inv_0_11 = iEnvelopes(_Symbol, time2_method, envel, envel_method, envelshag, envel_Price, envelproc, MODE_UPPER, 1); 
     
    Inv_0_2 = iEnvelopes(_Symbol, time2_method, envel, envel_method, envelshag, envel_Price, envelproc, MODE_LOWER, 0); 
    Inv_0_21 = iEnvelopes(_Symbol, time2_method, envel, envel_method, envelshag, envel_Price, envelproc, MODE_LOWER, 1); 

    if(High[0] > Inv_0_2 && High[0] < Inv_0_21) 
      { 
      TP = NormalizeDouble(Bid - tpt * _Point, _Digits); 
         ticketZK = OpenOrder(_Symbol, OP_SELL, lot, Bid, slippage, 0, TP, comment, Magic, 0, clrRed); 
         if(ticketZK > 0) 
         Print("Ордер на SELL успешно открыт! "); 
         return; 
      }  
     
       
    if(Low[0] < Inv_0_1 && Low[0] > Inv_0_11) 
      { 
      TP = NormalizeDouble(Ask + tpt * _Point, _Digits); 
         ticketZK = OpenOrder(_Symbol, OP_BUY, lot, Ask, slippage, 0, TP, comment, Magic, 0, clrBlue); 
         if(ticketZK > 0) 
         Print("Ордер на BUY успешно открыт! "); 
         return; 
      }

¡Por favor, ayuda!

 
ponochka:

Hola! Hay un indicador estándar iEnvelopes!
No puedo hacer que funcione como quiero.
¡Es decir, la necesidad de cuando la vela tocó o cruzó la línea en la vela actual hacia arriba, a continuación, abrió BUY, y la vela tocó o cruzó la línea en la vela actual hacia abajo, a continuación, abrió SELL..... y sucedió una vez (la señal de golpe y todo, otra señal de golpe y todo constantemente)!

¡Por favor, ayuda!

Tengo que añadir la comprensión del proceso al código :-)

Mientras la vela no se haya cerrado, el High[0] sólo puede subir, el Low[0] sólo puede bajar, mientras las envolventes descompiladas se comportan como quieren :-)

Si el sobre no se toma de los precios abiertos, no se puede mirar una barra no cerrada.

 
Maxim Kuznetsov:

necesitas añadir la comprensión del proceso al código :-)

Hasta que la vela se cierre, el High[0] sólo puede subir, el Low[0] sólo puede bajar, mientras que los sobres de la descompilación se comportan como quieren :-)

Si el sobre no se toma de los precios abiertos, no se puede mirar la barra no cerrada.

Es decir, ¿es mejor trabajar con Open y Close? ¿Qué es el cheque?
 

Ayúdame a entender cómo calcular la MA en un array.

Construyo MA por apertura-cierre, pero por el gráfico parece que se calcula de derecha a izquierda.

He utilizadoiMAOnArray ySimpleMAOnBuffer como herramientas, ¿hay alguna opción mejor?


//+------------------------------------------------------------------+
//|                                                        _null.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#include <MovingAverages.mqh>

#property indicator_buffers 4
#property indicator_plots   2
//--- plot OC
#property indicator_label1  "OC"
#property indicator_type1   DRAW_COLOR_HISTOGRAM
#property indicator_color1  clrSteelBlue, clrRed,clrGreen
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

#property indicator_label2  "MA1"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrBrown
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1


//--- indicator buffers
double   OC[], OC_color[], MA1_buf[];
input int MA1=2;

int OnInit()
  {
  
   IndicatorSetString(INDICATOR_SHORTNAME,"t1");
   
   SetIndexBuffer(0,OC,INDICATOR_DATA);
   SetIndexBuffer(1,OC_color,INDICATOR_COLOR_INDEX);
   
   SetIndexBuffer(2, MA1_buf,INDICATOR_DATA); 
   //PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,50);

     
//--- indicator buffers mapping

   
//---
   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[])
{

//--- Проверка количества доступных баров (1 - минимально, 4 - оптимально для большинства расчётов. Но всё "по месту"...)
   if(rates_total<4) return 0;
//--- Проверка и расчёт количества просчитываемых баров
   int limit=rates_total-prev_calculated; // 0 - пришел новый тик, новый бар формироваться не начал. 1 - пришел новый тик и начал формироваться новый бар.
   //if(limit>1) 
   
               // если вписать "limit>0", то на нулевом баре будет расчёт только нулевого бара, на каждом новом баре будет полный перерасчёт всей истории
               // если вписать "limit>1", то на нулевом баре будет расчёт только нулевого бара, на открытии нового бара - пересчёт первого и нулевого,
               // при подгрузке истории и на первом запуске - перерасчёт всей истории
     {
     limit=rates_total-1;
           // здесь должна быть инициализация всех используемых буферов индикатора необходимыми значениями (обычно EMPTY_VALUE и 0)
     }
   for(int i=limit; i>=0 && !IsStopped(); i--)
     {
      // необходимые действия по расчёту индикатора
     
     OC[i]=fmax(open[i],close[i])-fmin(open[i],close[i]);
     if(OC[i]>0.001)
      {   OC_color[i]=1;
      }
      }  
   
 /*  for(int k=limit; k>=0 && !IsStopped(); k--)
     {
   
     MA1_buf[k]=iMAOnArray(OC,0,MA1,k,MODE_SMA,0);
     }
*/
      SimpleMAOnBuffer(rates_total,prev_calculated,0,MA1,OC,MA1_buf);

//--- return value of prev_calculated for next call
   return(rates_total);
  }
 

¡¡¡Hola!!! Utilizo este código para traducir un enlace en un comentario, pero sistemáticamente una vez al día me da un error: web error 5203 (ERR_WEBREQUEST_REQUEST_FAILED. Error en el resultado de la petición HTTP)

¿Hay alguna forma de arreglarlo?

string Web(string url)
{
string headers, ret;
char post[], result[];
int res, timeout=5000;
res= WebRequest("GET",url,NULL,timeout,post,result,head ers);
if(d3 != 1 && res < 0)
{
MessageBox("4060 Добавите ссылку в доверенную зону (Сервис-Настройки-Советники-Разрешить URL)", "Внимание", MB_OK);
Print("Web-Error: ",GetLastError()," (4060 Добавите ссылку в доверенную зону (Сервис-Настройки-Советники-Разрешить URL");
ExpertRemove();
d3 = 1;
return("");
}
ret = CharArrayToString(result, 0, -1);
return(ret);
}
 

¿Puede decirme cómo hacer los coeficientes de ponderación de las señales?

Por ejemplo, tengo tres señales por escala: cruce, comparación1 (barra anterior vs. barra anterior) y comparación 2 (barra anterior vs. barra anterior en un TF superior).

Intento hacerlo con MAKD build en MT, pero no abre los tratos. No hay nada en el registro. Es decir, no se ha tocado la base estándar del EA, sólo se ha cambiado la lógica de la apertura de posiciones. Por lo tanto, el triplete es la base del asesor MT MAKD (normal)

No jures por el código nubio, no soy un programador


...
Вводимые параметры

input double TradeLevel_BUY = 1;

input double TradeLevel_SELL = -1;


input double w_S_MA_1 = 1;

input double w_S_MA_2 = 1;

input double w_S_MA_3 = 1;

input double w_S_MA_4 = 1;

input double w_S_MA_5 = 1;

input double w_S_MA_6 = 1;


...

----------------

...

void OnTick(void)

  {

   

   double MA_Fast_1,

          MA_Fast_2,

          MA_Slow_1,

          MA_Slow_2,

          MA_Fast_LargeTF_1,

          MA_Fast_LargeTF_2,

          MA_Slow_LargeTF_1,

          MA_Slow_LargeTF_2;

double S_MA_1,

       S_MA_2,

       S_MA_3,

...

   MA_Fast_1=iMA(NULL,0,MA_Fast_1_Period,MA_Fast_1_Shift,MODE_EMA,PRICE_CLOSE,1);
   MA_Fast_2=iMA(NULL,0,MA_Fast_2_Period,MA_Fast_2_Shift,MODE_EMA,PRICE_CLOSE,2);
   MA_Fast_LargeTF_1=iMA(NULL,MA_LargeTF,MA_Fast_LargeTF_1_Period,MA_Fast_LargeTF_1_Shift,MODE_EMA,PRICE_CLOSE,1);
   MA_Fast_LargeTF_2=iMA(NULL,MA_LargeTF,MA_Fast_LargeTF_2_Period,MA_Fast_LargeTF_2_Shift,MODE_EMA,PRICE_CLOSE,2);
   MA_Slow_1=iMA(NULL,0,MA_Slow_1_Period,MA_Slow_1_Shift,MODE_EMA,PRICE_CLOSE,1);
   MA_Slow_2=iMA(NULL,0,MA_Slow_2_Period,MA_Slow_2_Shift,MODE_EMA,PRICE_CLOSE,2);
   MA_Slow_LargeTF_1=iMA(NULL,0,MA_Slow_LargeTF_1_Period,MA_Slow_LargeTF_1_Shift,MODE_EMA,PRICE_CLOSE,1);

   MA_Slow_LargeTF_2=iMA(NULL,0,MA_Slow_LargeTF_2_Period,MA_Slow_LargeTF_2_Shift,MODE_EMA,PRICE_CLOSE,2);

...

 double Sum;

if (MA_Fast_1>MA_Slow_1)

      {

        S_MA_1=1*w_S_MA_1;

      }

   else

      {

        S_MA_1=0;

      }

   return;

   

   if (MA_Fast_1>MA_Fast_2)

      {

        S_MA_2=1*w_S_MA_2;

      }

   else

      {

        S_MA_2=0;

      }

   return;

   

   if (Open[1]<MA_Fast_LargeTF_1 && Close[1]>MA_Fast_LargeTF_1 || Open[1]>MA_Fast_LargeTF_1 && Close[1]>MA_Fast_LargeTF_1)

      {

        S_MA_3=1*w_S_MA_3;

      }

   else

      {

        S_MA_3=0;

      }

   return;

...

 if (MA_Fast_1<MA_Slow_1)

      {

        S_MA_4=-1*w_S_MA_4;

      }

   else

      {

        S_MA_4=0;

      }

   return;

   

   if (MA_Fast_1<MA_Fast_2)

      {

        S_MA_5=-1*w_S_MA_5;

      }

   else

      {

        S_MA_5=0;

      }

   return;

   

   if (Open[1]>MA_Fast_LargeTF_1 && Close[1]<MA_Fast_LargeTF_1 || Open[1]<MA_Fast_LargeTF_1 && Close[1]<MA_Fast_LargeTF_1)

      {

        S_MA_6=-1*w_S_MA_6;

      }

   else

      {

        S_MA_6=0;

      }

   return;


   Sum=S_MA_1+S_MA_2+S_MA_3+S_MA_4+S_MA_5+S_MA_6;

...

 if(Sum>TradeLevel_BUY)

        {

         ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Ask-SL*Point,Bid+TP*Point,"Optim",16384,0,Blue);

...


 if(Sum<=TradeLevel_SELL)

        {

         ticket=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Bid+SL*Point,Ask-TP*Point,"Optim",16384,0,Red);

         if(ticket>0)

 

Buenas tardes! ¿Cómo implemento esta función correctamente (creo que entenderán lo que quiero hacer)?

         if(IsTesting())
            for(int i2=0; i2<fixweekBars; i2++)
               else
            for(int i2=fixweekBars; i2>0; i2--)
 

Hola. Necesito ayuda con winApi user32.dll.

Hay un gráfico en el perfil. Necesito un script para abrir dos Chatr más. Los tres gráficos (era uno y abrió dos más) para hacer el tamaño especificado en el lugar establecido.

No importa cómo lo intente, no hay suerte.

Este script cambia el tamaño y la posición del gráfico sobre el que tiro.

//+------------------------------------------------------------------+
//|                                                      posicion.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property script_show_inputs

#import "user32.dll"

int  SetWindowPos(int hWnd,int hWndInsertAfter,int X,int Y,int cx,int cy,int uFlags);
int  GetParent(int hWnd);
int  GetTopWindow(int hWnd);
int  GetWindow(int hWnd,int wCmd);
int  GetWindowDC(int h);
int  ShowWindow(int hWnd,int nCmdShow);
#import 

#define GW_HWNDNEXT        0x0002
#define SWP_NOSIZE         0x0001
#define SWP_NOMOVE         0x0002
#define SWP_NOZORDER       0x0004
#define SW_RESTORE 9
#define SWP_FRAMECHANGED   0x0020

int     gr2x1_P1  []    = {PERIOD_H4,PERIOD_D1,PERIOD_W1};        // Period of grafic 1 of 2x1
int     CXShift2x1[]    = {0,0,1040};             // Horizontal shift of grafic 1 of 2x1
int     CYShift2x1[]    = {0,268,0};           // Vertical shift of grafic 1 of 2x1
int     CXSize2x1 []    = {1040,1040,880};           // Width of grafic 1 of 2x1
int     CYSize2x1 []    = {500,500,1000};           // Height of grafic 1 of 2x1

input int xy = 0;//xy 0-2
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
   void OnStart()
  {

   int i,handle;
   int parent;

   handle=(int)ChartGetInteger(0,CHART_WINDOW_HANDLE);Print("ChartGetInteger(0,CHART_WINDOW_HANDLE)   ",handle); //возвращает дескриптор 2688738                                                                                                                   
   parent=GetParent(handle);Print("parent_0   ",parent);                                         //возвращает дескриптор 197188
   ShowWindow(parent,SW_RESTORE);

  
      i=xy;
      SetWindowPos(parent,0,CXShift2x1[i],CYShift2x1[i],CXSize2x1[i],CYSize2x1[i],0);
      //Sleep(5000);
  }
//+------------------------------------------------------------------+
Открыть Новые дополнительные Chart-ы 
Но как дальше изменить размер дополнительных Chart-ов, ни как не получается. 

int i;
   for(i=0; i<3; i++)
     {
     long h=ChartOpen("EURUSD",gr2x1_P1[i]);
     }
Razón de la queja: