Ajuda na codificação - página 513

 
mladen:
Experimente (mostra agora quantas velas eu desejar em meu terminal) : quebra-velas_1.mq4

Agora está funcionando bem para mim.

Cumprimentos.

 

oi pessoal, tenho um problema que meu mt4 não pode mais mostrar na tabela ma, rsi, wpr velas que aconteceram depois que eu instalei novamente alguns dias atrás as plataformas do mt? qualquer um pode ajudar

 
tfi_markets:
Olá ProCoders,

Atualmente estou trabalhando com o indicador Autotrend Forecaster.

Eu escrevi o código abaixo, mas a EA não está abrindo negócios.

Alguém poderia ter a gentileza de dar uma olhada?

Agradecemos antecipadamente!

O MT4 mostra apenas alertas no diário:

Arquivos anexados:
journal.jpg  74 kb
 
tfi_markets:
O MT4 mostra apenas alertas na revista:

Então o problema está em suas condições que estão escritas no EA

Verifique se as condições já foram avaliadas

 

Olá codificadores,

Eu me sinto realmente envergonhado, porque esta é a terceira vez que pergunto sobre uma função de alerta.

Eu gostaria de receber um alerta quando a cor do histograma mudar de cor.

Como de costume, estou comparando os buffers indicadores uns com os outros. Mas desta vez não funciona.

Os amortecedores estão funcionando perfeitamente e minha função de comparação também está correta (aos meus olhos).

Então eu acho que tem que ser algo pequeno, espero que alguém possa me ajudar.

Obrigado de antemão,

#property indicator_separate_window#property indicator_buffers 5

#property indicator_color1 clrGreen

#property indicator_width1 4

#property indicator_color2 clrRed

#property indicator_width2 4

#property indicator_color3 Teal

#property indicator_color4 Teal

#property indicator_color5 Black

#property indicator_minimum 0

#property indicator_maximum 0.1

extern int Amplitude = 2;

extern bool alertsOn = true;

extern bool alertsMessage = true;

extern bool alertsSound = true;

extern bool alertsNotify = true;

extern bool alertsEmail = true;

extern string soundfile = "alert2.wav";

bool nexttrend;

double minh, maxl, up[], down[], trend[], atrlo[], atrhi[];

int init () {

SetIndexBuffer(0, up);

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexLabel(0, "up");

SetIndexBuffer(1, down);

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexLabel(1, "down");

SetIndexBuffer (2, atrlo);

SetIndexStyle (2, DRAW_NONE);

SetIndexBuffer (3, atrhi);

SetIndexStyle (3, DRAW_NONE);

SetIndexBuffer (4, trend);

//---

SetIndexEmptyValue (0, 0.0);

SetIndexEmptyValue (1, 0.0);

SetIndexEmptyValue (4, 0.0);

nexttrend = 0;

minh = High;

maxl = Low;

return (0);

}

int start () {

double atr, ll, hh, lma, hma;

int workbar = 1;

int c = IndicatorCounted ();

if (c < 0) {

return (- 1);

}

for (int i = Bars - 1 - c; i >= workbar; i --) {

ll = iLow (Symbol (), Period (),

iLowest (Symbol (), Period (), MODE_LOW, Amplitude, i));

hh = iHigh (Symbol (), Period (),

iHighest (Symbol (), Period (), MODE_HIGH, Amplitude, i));

lma = iMA (NULL, 0, Amplitude, 0, MODE_SMA, PRICE_LOW, i);

hma = iMA (NULL, 0, Amplitude, 0, MODE_SMA, PRICE_HIGH, i);

trend = trend;

atr = iATR (Symbol (), 0, 100, i) / 2;

if (nexttrend == 1) {

maxl = MathMax (ll, maxl);

if (hma < maxl && Close < Low) {

trend = 1;

nexttrend = 0;

minh = hh;

}

}

if (nexttrend == 0) {

minh = MathMin (hh, minh);

if (lma > minh && Close > High) {

trend = 0;

nexttrend = 1;

maxl = ll;

}

}

if (trend == 0.0) { //-------------------------------------------------------------------------------------------

if (trend != 0.0) {

up = down;

up = up;

} else {

up = MathMax (maxl, up);

}

atrhi = up + atr;

atrlo = up - atr;

down = 0.0;

} else {

if (trend != 1.0) {

down = up;//-------------------------------------------------------------------------------------------

down = down;

} else {

down = MathMin (minh, down);

}

atrhi = down + atr;

atrlo = down - atr;

up = 0.0; //-------------------------------------------------------------------------------------------

}

if(alertsOn){

if((up[2]!=EMPTY_VALUE) && (down[2]!=EMPTY_VALUE) &&(up[1]!=EMPTY_VALUE)&&(down[1]==EMPTY_VALUE))lcheckalert();

if((up[2]!=EMPTY_VALUE) && (down[2]==EMPTY_VALUE) &&(up[1]!=EMPTY_VALUE)&&(down[1]!=EMPTY_VALUE))scheckalert();

}

}

return (0);

}

void lcheckalert()

{

static datetime candletime=0;

if(candletime!=Time[0])

{

string lmessage = "ZOXY is green on, this means a buy signal! Pair:"+_Symbol +" Price: "+Ask;

if (alertsMessage) Alert(lmessage);

if (alertsNotify) SendNotification(lmessage);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Buy signal "),lmessage);

if (alertsSound) PlaySound("alert2.wav");

candletime=Time[0];

}

}

void scheckalert()

{

static datetime candletime=0;

if(candletime!=Time[0])

{

string smessage = "ZOXY is Red, this means a sell signal! Pair: "+_Symbol +" Price: "+Bid;

if (alertsMessage) Alert(smessage);

if (alertsNotify) SendNotification(smessage);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Sell signal "),smessage);

if (alertsSound) PlaySound("alert2.wav");

candletime=Time[0];

}

}

zoxy.mq4

Arquivos anexados:
zoxy.mq4  5 kb
 
mladen:
Então o problema está em suas condições que estão escritas no EACheck, se as condições alguma vez se avaliarem

Olá, Mladen,

obrigado por sua sugestão. Eu reescrevi o código um pouco para "forçar" as condições a verdadeiro / falso. Agora está vendendo, mas não comprando. Por favor, veja o código abaixo:

if(openOrders<=0)

{

// AutoTrendForecaster

double AutoTrendup=iCustom(Symbol(),0, "AutoTrendForecaster",TMperiod,Intensity,SL_distance_pips,0,bar);

duplo AutoTrendup_prev=iCustom(Symbol(),0, "AutoTrendForecaster",TMperiod,Intensity,SL_distance_pips,0,bar+1);

duplo AutoTrenddown=iCustom(Symbol(),0, "AutoTrendForecaster",TMperiod,Intensity,SL_distance_pips,1,bar);

duplo AutoTrenddown_prev=iCustom(Symbol(),0, "AutoTrendForecaster",TMperiod,Intensity,SL_distance_pips,1,bar+1);

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

//| COMPRAR

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

bool buyCondition = falso;

if(AutoTrendup>0 && AutoTrendup!=EMPTY_VALUE)

{

buyCondition = true;

}

se (buyCondition)

{

OpenBuy();

return(0);

}

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

//| SELL

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

bool sellCondition = false;

se (AutoTrenddown>0 && AutoTrenddown!=EMPTY_VALUE)

{

sellCondition = true;

}

se (sellCondition)

{

OpenSell();

return(0);

}

}

Agradecemos antecipadamente!

Arquivos anexados:
buysell.jpg  65 kb
 
xtractalpha:
Olá codificadores,

Eu me sinto realmente envergonhado, porque esta é a terceira vez que pergunto sobre uma função de alerta.

Eu gostaria de receber um alerta quando a cor do histograma mudar de cor.

Como de costume, estou comparando os buffers indicadores uns com os outros. Mas desta vez não funciona.

Os amortecedores estão funcionando perfeitamente e minha função de comparação também está correta (aos meus olhos).

Então eu acho que tem que ser algo pequeno, espero que alguém possa me ajudar.

Obrigado de antemão,

#property indicator_separate_window#property indicator_buffers 5

#property indicator_color1 clrGreen

#property indicator_width1 4

#property indicator_color2 clrRed

#property indicator_width2 4

#property indicator_color3 Teal

#property indicator_color4 Teal

#property indicator_color5 Black

#property indicator_minimum 0

#property indicator_maximum 0.1

extern int Amplitude = 2;

extern bool alertsOn = true;

extern bool alertsMessage = true;

extern bool alertsSound = true;

extern bool alertsNotify = true;

extern bool alertsEmail = true;

extern string soundfile = "alert2.wav";

bool nexttrend;

double minh, maxl, up[], down[], trend[], atrlo[], atrhi[];

int init () {

SetIndexBuffer(0, up);

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexLabel(0, "up");

SetIndexBuffer(1, down);

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexLabel(1, "down");

SetIndexBuffer (2, atrlo);

SetIndexStyle (2, DRAW_NONE);

SetIndexBuffer (3, atrhi);

SetIndexStyle (3, DRAW_NONE);

SetIndexBuffer (4, trend);

//---

SetIndexEmptyValue (0, 0.0);

SetIndexEmptyValue (1, 0.0);

SetIndexEmptyValue (4, 0.0);

nexttrend = 0;

minh = High;

maxl = Low;

return (0);

}

int start () {

double atr, ll, hh, lma, hma;

int workbar = 1;

int c = IndicatorCounted ();

if (c < 0) {

return (- 1);

}

for (int i = Bars - 1 - c; i >= workbar; i --) {

ll = iLow (Symbol (), Period (),

iLowest (Symbol (), Period (), MODE_LOW, Amplitude, i));

hh = iHigh (Symbol (), Period (),

iHighest (Symbol (), Period (), MODE_HIGH, Amplitude, i));

lma = iMA (NULL, 0, Amplitude, 0, MODE_SMA, PRICE_LOW, i);

hma = iMA (NULL, 0, Amplitude, 0, MODE_SMA, PRICE_HIGH, i);

trend = trend;

atr = iATR (Symbol (), 0, 100, i) / 2;

if (nexttrend == 1) {

maxl = MathMax (ll, maxl);

if (hma < maxl && Close < Low) {

trend = 1;

nexttrend = 0;

minh = hh;

}

}

if (nexttrend == 0) {

minh = MathMin (hh, minh);

if (lma > minh && Close > High) {

trend = 0;

nexttrend = 1;

maxl = ll;

}

}

if (trend == 0.0) { //-------------------------------------------------------------------------------------------

if (trend != 0.0) {

up = down;

up = up;

} else {

up = MathMax (maxl, up);

}

atrhi = up + atr;

atrlo = up - atr;

down = 0.0;

} else {

if (trend != 1.0) {

down = up;//-------------------------------------------------------------------------------------------

down = down;

} else {

down = MathMin (minh, down);

}

atrhi = down + atr;

atrlo = down - atr;

up = 0.0; //-------------------------------------------------------------------------------------------

}

if(alertsOn){

if((up[2]!=EMPTY_VALUE) && (down[2]!=EMPTY_VALUE) &&(up[1]!=EMPTY_VALUE)&&(down[1]==EMPTY_VALUE))lcheckalert();

if((up[2]!=EMPTY_VALUE) && (down[2]==EMPTY_VALUE) &&(up[1]!=EMPTY_VALUE)&&(down[1]!=EMPTY_VALUE))scheckalert();

}

}

return (0);

}

void lcheckalert()

{

static datetime candletime=0;

if(candletime!=Time[0])

{

string lmessage = "ZOXY is green on, this means a buy signal! Pair:"+_Symbol +" Price: "+Ask;

if (alertsMessage) Alert(lmessage);

if (alertsNotify) SendNotification(lmessage);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Buy signal "),lmessage);

if (alertsSound) PlaySound("alert2.wav");

candletime=Time[0];

}

}

void scheckalert()

{

static datetime candletime=0;

if(candletime!=Time[0])

{

string smessage = "ZOXY is Red, this means a sell signal! Pair: "+_Symbol +" Price: "+Bid;

if (alertsMessage) Alert(smessage);

if (alertsNotify) SendNotification(smessage);

if (alertsEmail) SendMail(StringConcatenate(Symbol()," Sell signal "),smessage);

if (alertsSound) PlaySound("alert2.wav");

candletime=Time[0];

}

}

zoxy.mq4

xtractalpha

Independentemente do SetIndexEmptyValue() EMPTY_VALUE não é == 0, mas 2147483647. Você também tem problemas de repintura nesse código que você tem que limpar primeiro

 

Por favor, alguém poderia corrigir este indicador para que ele mostre setas de alerta no gráfico e também deveria alertar apenas na primeira vela o que está se fechando acima/abaixo de um ema.

candle_close_cross_ma_alert1.mq4

Arquivos anexados:
 
triip:
Por favor, alguém poderia corrigir este indicador para que ele mostre setas de alerta(já está dentro) no gráfico e também deveria alertar apenas na primeira vela o que está fechando acima/abaixo umavela ema.candle_close_cross_ma_alert1.mq4

triip

Confira este aqui : https://www.mql5.com/en/forum/general

Ajuste o período ma rápido para 1 e então será o mesmo como se o preço cruzasse a média móvel (o slo ma)

 

Muito obrigado, sem sua ajuda eu não conseguiria consertá-lo.

(código ps. está funcionando).

Tenha um bom dia!

Razão: