As condições devem ser mais refinadas. Por exemplo: quando ambos estão sinalizando o mesmo é muito frequente. Portanto, quando exatamente devem fazer isso. Na primeira ocorrência disso? Em todas as ocorrências disso? Além disso, se você estiver saindo em alguma mudança de uma das duas, as saídas vão ser muito freqüentes.
Obrigado pela resposta! Sim, esta pode não ser uma boa estratégia. É que se eu receber isto como um modelo, provavelmente posso fazer algumas mudanças por mim mesmo mais tarde. O que eu quero é a possibilidade de combinar dois indicadores (e o uso de seus amortecedores).
Digamos que a estratégia deveria ser: comprar quando ambos os indicadores indicarem. E vender quando ambos os indicadores indicarem. Isso deve acontecer após a mudança do indicador e a barra fechada. Deve acontecer em cada ocorrência disso.
quando o indicador é aplicado durante a execução da EA ( a média móvel padrão em MT4 ) os valores são muito diferentes dos valores que são exibidos aplicando o mesmo indicador no final da execução da EA.
Você poderia explicar por que e se possível corrigir o indicador indi ?
Mladen acaba de terminar minha personalização no indicador anterior que você modificou. O que há de errado neste código? Ele não exibe nada...Nenhum erro quando compilado.
#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 minha personalização no indicador anterior que você modificou. O que há de errado neste código? Ele não exibe nada...Nenhum erro quando compilado.
thefxpros
Experimente assim
#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);
}
}
Tentei Mladen e parece funcionar, mas no testador de estratégia não se atualiza e não aparece o alerta, quando o mercado se abrirá eu tentarei no mercado real. obrigado
Eu estava pensando em acrescentar um comentário quando o preço se reverteu em relação à tendência e ter "esperar para comprar" & "esperar para vender" .
Adicionar a nova linha à compra não é problema, mas quando adicioná-la para vendê-la não pode fazê-la funcionar.
O que eu deveria mudar ?
string OPstr;
color OPclr;
if (buffer1[i+SignalCandle]>buffer5[i+SignalCandle]) {
OPstr = "BUY";
OPclr = Green;
}
if (buffer1[i+SignalCandle]>buffer5[i+SignalCandle] && Bid < buffer1[i+SignalCandle] ) {
OPstr = "WAIT FOR BUY";
OPclr = LimeGreen;
}
elseif (buffer1[i+SignalCandle]<buffer6[i+SignalCandle] ) {
OPstr = "SELL";
OPclr = Red;
}
if (buffer1[i+SignalCandle]<buffer6[i+SignalCandle] && Bid > buffer1[i+SignalCandle] ) {
OPstr = "WAIT FOR SELL";
OPclr = OrangeRed;
}
else
{
OPstr = "NO TRADE";
OPclr = Yellow;
}
Simon
As condições devem ser mais refinadas. Por exemplo: quando ambos estão sinalizando o mesmo é muito frequente. Portanto, quando exatamente devem fazer isso. Na primeira ocorrência disso? Em todas as ocorrências disso? Além disso, se você estiver saindo em alguma mudança de uma das duas, as saídas vão ser muito freqüentes.
Obrigado pela resposta! Sim, esta pode não ser uma boa estratégia. É que se eu receber isto como um modelo, provavelmente posso fazer algumas mudanças por mim mesmo mais tarde. O que eu quero é a possibilidade de combinar dois indicadores (e o uso de seus amortecedores).
Digamos que a estratégia deveria ser: comprar quando ambos os indicadores indicarem. E vender quando ambos os indicadores indicarem. Isso deve acontecer após a mudança do indicador e a barra fechada. Deve acontecer em cada ocorrência disso.
Tudo de bom!
Prezado mladen,
Tenho um problema com o indicador em anexo:
quando o indicador é aplicado durante a execução da EA ( a média móvel padrão em MT4 ) os valores são muito diferentes dos valores que são exibidos aplicando o mesmo indicador no final da execução da EA.
Você poderia explicar por que e se possível corrigir o indicador indi ?
Sr. mladen ,
Estou fazendo algumas mudanças para a fita cheia para o canal ma, mas tenho problemas com o buffer .
Isso pode esconder o canal atrás do histograma ou fazer com que fique em branco entre os canais?
Eu tento apagá-lo, mas só posso fazê-lo de um lado, é necessário adicionar mais um buffer?
E mais um problema está na linha 44 , eu não posso excluí-lo ou apagá-lo.
sempre tem um erro que sai.
Por favor, me dê alguns conselhos , obrigado .
Steven .
Sr. mladen ,
Estou fazendo algumas mudanças para a fita cheia para o canal ma, mas tenho um problema com o buffer .
Isso pode esconder o canal atrás do histograma ou fazer com que fique em branco entre os canais?
Eu tento apagá-lo, mas só posso fazê-lo de um lado, é necessário adicionar mais um buffer?
E mais um problema está na linha 44 , eu não posso excluí-lo ou apagá-lo.
sempre tem um erro que sai.
Por favor, me dê alguns conselhos , obrigado .
Steven .
Não tenho certeza se é isso que você está tentando fazer, mas experimente-o.
Não tenho certeza se é isso que você está tentando fazer, mas experimente
SIM , exatamente o que eu quero :D
Mas você pode me ajudar a verificar o código na linha 44 'AlertOnClosedCandle' , por que ele não pode apagar ou bool externo ?
Esta é minha primeira vez tendo este tipo de problema.
De qualquer forma, aprendi algumas coisas sobre o buffer .
Obrigado .
Mladen acaba de terminar minha personalização no indicador anterior que você modificou. O que há de errado neste código? Ele não exibe nada...Nenhum erro quando compilado.
Mladen acaba de terminar minha personalização no indicador anterior que você modificou. O que há de errado neste código? Ele não exibe nada...Nenhum erro quando compilado.
thefxpros
Experimente assim
Correção :
Mude as linhas 74 e 75 de sigma a partir desta :
a este :
E deve funcionar
Ou remover completamente a declaração estrita (já que esse indicador precisa de uma reescrita completa se for usado com o "estrito")
Prezado mladen,
Tentei ambas as sugestões sem sucesso, mas percebi que o índio não se atualiza ao correr em uma EA, como na figura a seguir.
Deve ser possível consertá-lo?
:
thefxpros
Tente assim
Olá, Sr. Mladen,
Eu estava pensando em acrescentar um comentário quando o preço se reverteu em relação à tendência e ter "esperar para comprar" & "esperar para vender" .
Adicionar a nova linha à compra não é problema, mas quando adicioná-la para vendê-la não pode fazê-la funcionar.
O que eu deveria mudar ?