Errores, fallos, preguntas - página 1793
Está perdiendo oportunidades comerciales:
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Registro
Entrada
Usted acepta la política del sitio web y las condiciones de uso
Si no tiene cuenta de usuario, regístrese
¿Y es posible escribir una función así?
Hay un error en el tipo de dibujo DRAW_CANDLES después de actualizarlo: hago todo como se describe aquí: https://www.mql5.com/ru/forum/23/page19#comment_2891050
No se puede cambiar el tipo de construcción (1-2-3) seleccionando a través de los parámetros de entrada. Código:
#property indicator_plots 1
#property indicator_buffers 4
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//--- Перечисление - новые типы отрисовки DRAW_CANDLE
enum ENUM_DRAW_CANDLE_TYPE
{
DRAW_CANDLE_TYPE_1, // Один цвет: #1 - контуры и тела
DRAW_CANDLE_TYPE_2, // Два цвета: #1 - контуры, #2 - тела
DRAW_CANDLE_TYPE_3 // Три цвета: #1 - контуры, #2 - восход., #3 - нисход.
};
//---
double bufopen[];
double bufhigh[];
double buflow[];
double bufclose[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
input ENUM_DRAW_CANDLE_TYPE inpDrawCandleStyle=DRAW_CANDLE_TYPE_1;
input color inpClr1 = clrWhite;
input color inpClr2 = clrLime;
input color inpClr3 = clrRed;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- Привязываем буферы
SetIndexBuffer(0,bufopen,INDICATOR_DATA);
SetIndexBuffer(1,bufhigh,INDICATOR_DATA);
SetIndexBuffer(2,buflow,INDICATOR_DATA);
SetIndexBuffer(3,bufclose,INDICATOR_DATA);
//--- Устанавливаем тип графического построения
PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_CANDLES);
//--- Устанавливаем пустые значения в буферах
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//--- Устанавливаем цвета индикатора
switch(inpDrawCandleStyle) // В зависимости от типа построения свечей
{
case DRAW_CANDLE_TYPE_1: // Если все свечи одним цветом
////--- Устанавливаем количество цветов стиля (не помогает)
//PlotIndexGetInteger( 0, PLOT_COLOR_INDEXES, 1 );
//---
PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,inpClr1);
break;
case DRAW_CANDLE_TYPE_2: // Если контуры цветом #1, а тела - цветом #2
////--- Устанавливаем количество цветов стиля (не помогает)
//PlotIndexGetInteger( 0, PLOT_COLOR_INDEXES, 2 );
//--- Устанавливаем цвет индикатора
PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,inpClr1);
PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,inpClr2);
break;
case DRAW_CANDLE_TYPE_3: // Если контуры цветом #1, восх - #2, нисх - #3
////--- Устанавливаем количество цветов стиля (не помогает)
//PlotIndexGetInteger( 0, PLOT_COLOR_INDEXES, 3 );
//--- Устанавливаем цвет индикатора
PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,inpClr1);
PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,inpClr2);
PlotIndexSetInteger(0,PLOT_LINE_COLOR,2,inpClr3);
break;
default: // Если тип построения не определен
Print(__FUNCTION__,": ОШИБКА! Неизвестный тип построения свечей '"+EnumToString(inpDrawCandleStyle)+"'");
return(INIT_FAILED); // Выходим с ошибкой
}
//---
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[])
{
//---
if(prev_calculated<=0)
for(int i=0; i<rates_total; i++)
{
bufopen[ i ] = open[ i ];
bufhigh[ i ] = high[ i ];
buflow[i]=low[i];
bufclose[i]=close[i];
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Específicamente - el primer tipo (velas + contornos primer color) funciona bien, no cambia a los otros.
Añadido:
Si establece los colores a través de la directiva del preprocesador - todo bien, pero entonces también es imposible cambiar el tipo de dibujo DRAW_CANDLES.
Sí, necesitamos implementar un constructor y un operador de copia
Hay un error en el tipo de dibujo DRAW_CANDLES después de actualizarlo: hago todo como se describe aquí: https://www.mql5.com/ru/forum/23/page19#comment_2891050
No se puede cambiar el tipo de construcción (1-2-3) seleccionando a través de los parámetros de entrada. Código:
PlotIndexSet Integer( 0, PLOT_COLOR_INDEXES, 3 );
Lamentablemente, esta solución sólo funciona para la estructura personalizada. En el ejemplo MqlTradeRequest.
Tienes un error en tu código, deberías usar PlotIndexSetInteger:
PlotIndexSet Integer( 0, PLOT_COLOR_INDEXES, 3 );
A continuación, pasar la estructura por referencia en los parámetros. Otra opción es hacer tu propia copia de la estructura y el reparto, pero tienes que pensar cómo hacerlo bien.
No lo entiendo.
{
// копия MqlTradeRequest
// + нужные операторы
};
// ...
MyTradeRequest request = Function();
MqlTradeResult = {0};
OrderSend((MqlTradeRequest)request, result);
// ...
{
// копия MqlTradeRequest
// + нужные операторы
};
// ...
MyTradeRequest request = Function();
MqlTradeResult = {0};
OrderSend((MqlTradeRequest)request, result);
// ...
Entiendo la idea. Pero ese tipo de reparto no funcionará.