Las condiciones deberían ser más refinadas. Por ejemplo : cuando ambos están señalando el mismo es muy a menudo. Entonces, ¿cuándo exactamente deben hacer eso. ¿A la primera vez que ocurre? ¿En cada ocurrencia de eso? Además, si están saliendo en cada cambio de uno de los dos, las salidas van a ser muy frecuentes
Gracias por la respuesta. Sí, esto podría no ser una buena estrategia. Es que si consigo esto como plantilla probablemente pueda hacer algunos cambios por mí mismo después. Lo que quiero es la posibilidad de combinar dos indicadores (y el uso de sus topes).
Digamos que la estrategia en lugar debe ser: comprar cuando ambos indicadores indican. Y vender cuando ambos indicadores lo indiquen. Debería ocurrir después del cambio de indicador y de la barra cerrada. Debería ocurrir en cada ocurrencia de eso.
cuando se aplica el indicador durante la ejecución del EA ( la media móvil estándar en MT4 ) los valores son muy diferentes a los que se muestran aplicando el mismo indicador al final de la ejecución del EA.
¿Podría explicar por qué y si es posible corregir el indicador?
Mladen acaba de terminar mi personalización en el indicador anterior que modificó. ¿Qué hay de malo en este código? No muestra nada... No hay errores cuando se compila.
#property version"1.00"#property strict#property indicator_chart_window#property indicator_buffers4#property indicator_color1 Gold
#property indicator_color2 DodgerBlue
#property indicator_color3 LimeGreen
#property indicator_color4 Crimson
#property indicator_width1 2#property indicator_width2 2#property indicator_width3 2#property indicator_width4 2externstring NOTE1 = "SELECT PARAMETERS OF THE INDICATOR"; //SPAN MA CROSS PARAMSexternint SpanPeriod = 1; // Period of Spanexternint SpanShift = -26; // Shift of SpanexternENUM_MA_METHOD SpanMode = 1; // Mode of SpanexternENUM_APPLIED_PRICE SpanPrice = 0; // Applied price of Spanexternint MaPeriod = 55; // Period of Moving averageexternint MaShift = 0; // Shift of Moving averageexternENUM_MA_METHOD MaMode = 1; // Mode of Moving averageexternENUM_APPLIED_PRICE MaPrice = 0; // Applied price of Moving averageexternstring NOTE2 = "SELECT COLORS/STYLES OF THE INDICATOR"; //SPAN MA CROSS COLORS/STYLESexterncolor SpanClr = Gold; // Span colorexternint SpanWdt = 2; // Span widthexternENUM_LINE_STYLE SpanStl = 0; // Span line styleexterncolor MaClr = DodgerBlue; // Moving average colorexternint MaWdt = 2; // Moving average widthexternENUM_LINE_STYLE MaStl = 0; // Moving average line styleexternstring NOTE3 = "SELECT PARAMETERS OF THE SIGNAL ARROWS"; //SPAN MA CROSS PARAMETERS OF THE SIGNAL ARROWSexternbool DrawArrows = true; // Draw signal arrows?externbool DrawMaLines = true; // Draw lines?externcolor UpArrowClr = LimeGreen; // Up arrow colorexternint UpArrowWdt = 2; // Up arrow widthexterncolor DnArrowClr = Crimson; // Down arrow colorexternint DnArrowWdt = 2; // Down arrow widthexternint ArrowsDistance = 10; // Arrows distance from candleexternstring NOTE4 = "SELECT PARAMETERS OF THE ALERT"; //SPAN MA CROSS PARAMETERS OF THE ALERTexternbool AlertsOn = true; // Active alert?externbool AlertsOnCurrent = true; // Alert on current unclosed barexternbool AlertsMessage = true; // Alert messageexternbool AlertsSound = true; // Alert soundexternbool AlertsEmail = false; // Alert e-mailexternstring SoundFile = "alert2.wav"; // Filename of sound alertstring IndicatorFileName;
int WhichBar;
double Gap;
double SpanBuffer[]; // Buffer of the Spandouble MaBuffer[]; // Buffer of the Moving averagedouble CrossUpBuffer[]; // Up arrow bufferdouble CrossDnBuffer[]; // Down arrow bufferdouble TrendBuffer[]; // Span/Ma cross bufferint init()
{
IndicatorFileName = WindowExpertName();
IndicatorBuffers(5);
SetIndexBuffer(0, SpanBuffer);
SetIndexBuffer(1, MaBuffer);
SetIndexBuffer(2, CrossUpBuffer);
SetIndexBuffer(3, CrossDnBuffer);
SetIndexBuffer(4, TrendBuffer);
if (DrawMaLines) {
SetIndexStyle (0, DRAW_LINE, SpanStl, SpanWdt, SpanClr);
SetIndexStyle (1, DRAW_LINE, MaStl, MaWdt, MaClr);}
else {
SetIndexStyle(0, DRAW_NONE);
SetIndexStyle(1, DRAW_NONE);}
if (DrawArrows) {
SetIndexStyle (2, DRAW_ARROW, 0, UpArrowWdt, UpArrowClr); SetIndexArrow(0, 233);
SetIndexStyle (3, DRAW_ARROW, 0, DnArrowWdt, DnArrowClr); SetIndexArrow(0, 234);}
else {
SetIndexStyle(2, DRAW_NONE);
SetIndexStyle(3, DRAW_NONE);}
return(0);}
int deinit() { return(0); }
int start() {
int counted_bars = IndicatorCounted();
int i, limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = MathMin(Bars-counted_bars, Bars-1);
for(i=limit; i>=0; i--){
SpanBuffer[i] = iMA(NULL, 0, SpanPeriod, SpanShift, SpanMode, SpanPrice, i);
MaBuffer[i] = iMA(NULL, 0, MaPeriod, MaShift, MaMode, MaPrice, i);
Gap = iATR(NULL,0,20,i);
TrendBuffer[i] = TrendBuffer[i+1];
if (SpanBuffer[i] > MaBuffer[i]) TrendBuffer[i] = 1;
if (SpanBuffer[i] < MaBuffer[i]) TrendBuffer[i] =-1;
CrossUpBuffer[i] = EMPTY_VALUE;
CrossDnBuffer[i] = EMPTY_VALUE;
if (TrendBuffer[i]!= TrendBuffer[i+1])
if (TrendBuffer[i] == 1)
CrossUpBuffer[i] = Low[i] - ArrowsDistance * Gap;
else CrossDnBuffer[i] = High[i] + ArrowsDistance * Gap;
}
if (AlertsOn)
{
if (AlertsOnCurrent)
WhichBar = 0;
else WhichBar = 1;
if (TrendBuffer[WhichBar] != TrendBuffer[WhichBar+1])
if (TrendBuffer[WhichBar] == 1)
doAlert("uptrend");
else doAlert("downtrend");
}
return(0);
}
// CUSTOM FUNCTIONS -------------------------void doAlert(string doWhat)
{
staticstring previousAlert="nothing";
staticdatetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];
message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Span ma cross ", doWhat);
if (AlertsMessage) Alert(message);
if (AlertsEmail) SendMail(StringConcatenate(Symbol()," Span ma cross "), message);
if (AlertsSound) PlaySound(SoundFile);
}
}
Mladen acaba de terminar mi personalización en el indicador anterior que modificó. ¿Qué hay de malo en este código? No muestra nada... No hay errores cuando se compila.
thefxpros
Pruébalo así
#property version"1.00"#property strict#property indicator_chart_window#property indicator_buffers4#property indicator_color1 Gold
#property indicator_color2 DodgerBlue
#property indicator_color3 LimeGreen
#property indicator_color4 Crimson
#property indicator_width1 2#property indicator_width2 2#property indicator_width3 2#property indicator_width4 2externstring NOTE1 = "SELECT PARAMETERS OF THE INDICATOR"; //SPAN MA CROSS PARAMSexternint SpanPeriod = 1; // Period of Spanexternint SpanShift = -26; // Shift of SpanexternENUM_MA_METHOD SpanMode = 1; // Mode of SpanexternENUM_APPLIED_PRICE SpanPrice = 0; // Applied price of Spanexternint MaPeriod = 55; // Period of Moving averageexternint MaShift = 0; // Shift of Moving averageexternENUM_MA_METHOD MaMode = 1; // Mode of Moving averageexternENUM_APPLIED_PRICE MaPrice = 0; // Applied price of Moving averageexternstring NOTE2 = "SELECT COLORS/STYLES OF THE INDICATOR"; //SPAN MA CROSS COLORS/STYLESexterncolor SpanClr = Gold; // Span colorexternint SpanWdt = 2; // Span widthexternENUM_LINE_STYLE SpanStl = 0; // Span line styleexterncolor MaClr = DodgerBlue; // Moving average colorexternint MaWdt = 2; // Moving average widthexternENUM_LINE_STYLE MaStl = 0; // Moving average line styleexternstring NOTE3 = "SELECT PARAMETERS OF THE SIGNAL ARROWS"; //SPAN MA CROSS PARAMETERS OF THE SIGNAL ARROWSexternbool DrawArrows = true; // Draw signal arrows?externbool DrawMaLines = true; // Draw lines?externcolor UpArrowClr = LimeGreen; // Up arrow colorexternint UpArrowWdt = 2; // Up arrow widthexterncolor DnArrowClr = Crimson; // Down arrow colorexternint DnArrowWdt = 2; // Down arrow widthexternint ArrowsDistance = 10; // Arrows distance from candleexternstring NOTE4 = "SELECT PARAMETERS OF THE ALERT"; //SPAN MA CROSS PARAMETERS OF THE ALERTexternbool AlertsOn = true; // Active alert?externbool AlertsOnCurrent = true; // Alert on current unclosed barexternbool AlertsMessage = true; // Alert messageexternbool AlertsSound = true; // Alert soundexternbool AlertsEmail = false; // Alert e-mailexternstring SoundFile = "alert2.wav"; // Filename of sound alertstring IndicatorFileName;
int WhichBar;
double Gap;
double SpanBuffer[]; // Buffer of the Spandouble MaBuffer[]; // Buffer of the Moving averagedouble CrossUpBuffer[]; // Up arrow bufferdouble CrossDnBuffer[]; // Down arrow bufferdouble TrendBuffer[]; // Span/Ma cross bufferint init()
{
IndicatorFileName = WindowExpertName();
IndicatorBuffers(5);
SetIndexBuffer(0, SpanBuffer);
SetIndexBuffer(1, MaBuffer);
SetIndexBuffer(2, CrossUpBuffer);
SetIndexBuffer(3, CrossDnBuffer);
SetIndexBuffer(4, TrendBuffer);
if (DrawMaLines) {
SetIndexStyle (0, DRAW_LINE, SpanStl, SpanWdt, SpanClr);
SetIndexStyle (1, DRAW_LINE, MaStl, MaWdt, MaClr);}
else {
SetIndexStyle(0, DRAW_NONE);
SetIndexStyle(1, DRAW_NONE);}
if (DrawArrows) {
SetIndexStyle (2, DRAW_ARROW, 0, UpArrowWdt, UpArrowClr); SetIndexArrow(0, 233);
SetIndexStyle (3, DRAW_ARROW, 0, DnArrowWdt, DnArrowClr); SetIndexArrow(0, 234);}
else {
SetIndexStyle(2, DRAW_NONE);
SetIndexStyle(3, DRAW_NONE);}
return(0);}
int deinit() { return(0); }
int start() {
int counted_bars = IndicatorCounted();
int i, limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit = MathMin(Bars-counted_bars, Bars-1);
for(i=limit; i>=0; i--){
SpanBuffer[i] = iMA(NULL, 0, SpanPeriod, SpanShift, SpanMode, SpanPrice, i);
MaBuffer[i] = iMA(NULL, 0, MaPeriod, MaShift, MaMode, MaPrice, i);
Gap = iATR(NULL,0,20,i);
if (i<Bars-1) TrendBuffer[i] = TrendBuffer[i+1];
if (SpanBuffer[i] > MaBuffer[i]) TrendBuffer[i] = 1;
if (SpanBuffer[i] < MaBuffer[i]) TrendBuffer[i] =-1;
CrossUpBuffer[i] = EMPTY_VALUE;
CrossDnBuffer[i] = EMPTY_VALUE;
if (i<Bars-1 && TrendBuffer[i]!= TrendBuffer[i+1])
if (TrendBuffer[i] == 1)
CrossUpBuffer[i] = Low[i] - ArrowsDistance * Gap;
else CrossDnBuffer[i] = High[i] + ArrowsDistance * Gap;
}
if (AlertsOn)
{
if (AlertsOnCurrent)
WhichBar = 0;
else WhichBar = 1;
if (TrendBuffer[WhichBar] != TrendBuffer[WhichBar+1])
if (TrendBuffer[WhichBar] == 1)
doAlert("uptrend");
else doAlert("downtrend");
}
return(0);
}
// CUSTOM FUNCTIONS -------------------------void doAlert(string doWhat)
{
staticstring previousAlert="nothing";
staticdatetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];
message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Span ma cross ", doWhat);
if (AlertsMessage) Alert(message);
if (AlertsEmail) SendMail(StringConcatenate(Symbol()," Span ma cross "), message);
if (AlertsSound) PlaySound(SoundFile);
}
}
He probado con Mladen y parece que funciona pero en el probador de estrategias no se refresca y no sale la alerta, cuando se abra el mercado lo probaré en el mercado real.
Simon
Las condiciones deberían ser más refinadas. Por ejemplo : cuando ambos están señalando el mismo es muy a menudo. Entonces, ¿cuándo exactamente deben hacer eso. ¿A la primera vez que ocurre? ¿En cada ocurrencia de eso? Además, si están saliendo en cada cambio de uno de los dos, las salidas van a ser muy frecuentes
Gracias por la respuesta. Sí, esto podría no ser una buena estrategia. Es que si consigo esto como plantilla probablemente pueda hacer algunos cambios por mí mismo después. Lo que quiero es la posibilidad de combinar dos indicadores (y el uso de sus topes).
Digamos que la estrategia en lugar debe ser: comprar cuando ambos indicadores indican. Y vender cuando ambos indicadores lo indiquen. Debería ocurrir después del cambio de indicador y de la barra cerrada. Debería ocurrir en cada ocurrencia de eso.
¡Todo lo mejor!
Estimado mladen,
Tengo un problema con el indicador adjunto:
cuando se aplica el indicador durante la ejecución del EA ( la media móvil estándar en MT4 ) los valores son muy diferentes a los que se muestran aplicando el mismo indicador al final de la ejecución del EA.
¿Podría explicar por qué y si es posible corregir el indicador?
Señor mladen ,
Estoy haciendo algunos cambios para el canal ma ribbon filled to ma pero tengo problemas con el buffer .
¿Es posible ocultar el canal detrás del histograma o hacer un espacio en blanco entre los canales?
Intenté ocultar el canal pero sólo pude hacerlo en un lado, ¿es necesario añadir un buffer más?
Y un problema mas es en la linea 44, no puedo externarla o borrarla.
Siempre sale un error.
Por favor, dame algún consejo, gracias.
Steven .
Señor mladen ,
Estoy haciendo algunos cambios para el canal ma ribbon filled to ma pero tengo problemas con el buffer .
¿Es posible ocultar el canal detrás del histograma o hacer un espacio en blanco entre los canales?
Intenté ocultar el canal pero sólo pude hacerlo en un lado, ¿es necesario añadir un buffer más?
Y un problema mas es en la linea 44, no puedo externarla o borrarla.
Siempre sale un error.
Por favor, dame algún consejo, gracias.
Steven .
No estoy seguro de si esto es lo que estás tratando de hacer, pero inténtalo.
No estoy seguro de si esto es lo que estás tratando de hacer, pero pruébalo
SI , exactamente lo que quiero :D
Pero, ¿puede ayudarme a comprobar el código en la línea 44 'AlertOnClosedCandle', por qué no puede eliminar o extern bool?
Es la primera vez que tengo este tipo de problema.
De cualquier manera he aprendido algunas cosas en el buffer.
Gracias.
Mladen acaba de terminar mi personalización en el indicador anterior que modificó. ¿Qué hay de malo en este código? No muestra nada... No hay errores cuando se compila.
Mladen acaba de terminar mi personalización en el indicador anterior que modificó. ¿Qué hay de malo en este código? No muestra nada... No hay errores cuando se compila.
thefxpros
Pruébalo así
Corrección :
Cambia las líneas 74 y 75 de sigma de esta :
a esto :
Y debería funcionar
O eliminar la declaración estricta por completo (ya que ese indicador necesita una reescritura completa si se va a utilizar con el "estricto")
Estimado mladen,
He probado ambas sugerencias sin éxito pero me he dado cuenta de que el indi no se actualiza cuando se ejecuta en un EA como en la siguiente imagen.
¿Debería ser posible arreglarlo?
:
losfxpros
Pruébalo así
Hola Sr. Mladen,
Estaba pensando en añadir un comentario cuando el precio ha invertido de la tendencia y tienen "esperar para comprar" y "esperar para vender".
Añadiendo la nueva línea a la compra no hay problema, pero cuando se añade a la venta no puede hacer que funcione.
¿Qué debo cambiar?