Como codificar? - página 93

 

mas você pode me explicar por que

BuyCondition = BuyValueCurrent1 != EMPTY_VALUE

por que valor_vazio?

 

de qualquer forma, não funciona e não entendo e descubro por quê.

aqui estão minhas variáveis

BuyValueCurrent = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,1); // braintrend1 [/PHP]
BuyValueCurrent2 = iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,1); // braintrend2

and here is the statement

[PHP] BuyCondition = (BuyValueCurrent != EMPTY_VALUE && BuyValueCurrent2 != EMPTY_VALUE);

dá resultados totalmente difusos mesmo quando o indicador (Braintrend2stop e BrainTrend1Stop) são vendidos

 
clarc:
tenho uma EA que abre e maneja a posição, mas às vezes dá ao indicador o mesmo sinal múltiplo e a EA abre toda vez que este sinal sai uma nova posição - mas eu não quero uma segunda ou terceira e assim por diante e na posição, eu vou apenas a primeira - é possível que a EA verifique a posição aberta com base no número mágico e no par para evitar tais entradas múltiplas ?

Aqui está a idéia:

int CountLongs()

{

int contagem=0;

int trade;

int trades=OrdensTotal();

for(trade=0;trade<trades;trade++) {

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()!=Symbol() || OrderMagicNumber() != MagicNumber) continua;

if(OrderType()==OP_BUY) count++;

} //---- para

devolução(contagem);

}

em CountShorts()

{

int contagem=0;

int trade;

int trades=OrdensTotal();

for(trade=0;trade<trades;trade++) {

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()!=Symbol() || OrderMagicNumber() != MagicNumber) continua;

if(OrderType()==OP_SELL) count++;

} //---- para

devolução(contagem);

}

E na função start():

if(CountLongs() == 0 && CountShorts() == 0) {

Sua condição de entrada aqui

}

Esperança que ajuda.

FerruFx

 
payback:
de qualquer forma não funciona e eu não entendo e descubro por quê...

aqui estão minhas variáveis

BuyValueCurrent = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,1); // braintrend1 [/PHP]
BuyValueCurrent2 = iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,1); // braintrend2

and here is the statement

[PHP] BuyCondition = (BuyValueCurrent != EMPTY_VALUE && BuyValueCurrent2 != EMPTY_VALUE);
dá resultados totalmente difusos mesmo quando o indicador (Braintrend2stop e BrainTrend1Stop) são vendidos

Não conheço seu indiciador Braintrend1 e 2, apenas assumi que quando uma condição de compra é cumprida, eles desenham uma seta na tabela. Em MT4, o valor padrão do buffer é uma constante chamada "VAZIO-VALOR", portanto, se não houver seta o valor retornado por iCustom() é esta constante, e se houver seta o valor retornado é o preço onde a seta é colocada.

Como eu entendi, você quer comprar quando ambos os indiciados estão mostrando uma flecha, não é isso?

 

sim é exatamente o que eu quero fazer

 
payback:
sim, é exatamente o que eu quero fazer

Portanto, por favor, verifique sua sintaxe iCustom().

 

o que tenho que verificar? talvez eu perca alguma coisa

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

bem para o que eu suponho que se houver um sinal de compra ele é armazenado no buffer 0 ou está vazio e o buffer 1 tem o sinal de venda

 
payback:
o que tenho que verificar? talvez eu perca algo
double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)
bem para o que eu suponho que se houver um sinal de compra ele é armazenado no buffer 0 ou está vazio e o buffer 1 tem o sinal de venda

Afixe seu indiciamento aqui, eu vou procurar.

 

ok thx!

e, por favor, explique

Arquivos anexados:
 
payback:
ok thx!e, por favor, explique

Open BrainTrend1Stop.mq4.

No início do arquivo, você pode encontrar :

extern int NumBars=500;

extern int EnableAlerts=0;

extern int SignalID=0;[/PHP]This means that you have to fill those three parameters as arguments in the iCustom() call, like this:

BuyValueCurrent = iCustom(NULL,0,"BrainTrend1Stop",NumBars,EnableAlerts,SignalID,0,1); // braintrend1

[/PHP]About the buffer's number, you can see this:

#property indicator_color1 Magenta

#property indicator_color2 Aqua[/PHP]So the buffer 0 is Magenta and the buffer 1 is Aqua.

Thus if the Buy arrow's color is Aqua, the buffer's number is 1 and the iCustom call is:[PHP]BuyValueCurrent = iCustom(NULL,0,"BrainTrend1Stop",NumBars,EnableAlerts,SignalID,1,1); // braintrend1
A little lower you have:[PHP] SetIndexEmptyValue(1,0.0);

This means that the default empty value for the buffer 1 is set to 0.0; so when there is no arrow, the value returned by the iCustom() call will be 0.0.

So you should know the presence of the arrow checking its value against 0, like this (if the second indic follows the same behavior):[PHP]BuyCondition = (BuyValueCurrent > 0 && BuyValueCurrent2 > 0);

Sobre o segundo indiciamento, acho que você deve ser capaz de fazer a mesma análise por si mesmo.

Razão: