Yikes... Eu sou tão estúpido)))) Não entenda, não toque nas funções init(), deinit() e deinit() e start() em vão. Somente da maneira que as grandes metaquotas dizem a você))))
Olá a todos!!! Tenho uma ordem de abertura da EA contra o movimento, como mudar ou aconselhar onde mudar????
fio GLOB_START;
int init() { GLOB_START = "@" + DoubleToStr(ID,0) + "@" + "_start"; if !GlobalVariableCheck( GLOB_START )GlobalVariableSet(GLOB_START,TimeCurrent()); retorno(0); }
int deinit() { switch( UninitializeReason() ) { caso REASON_REMOVE: delete_glob ("@" + DoubleToStr(ID,0) + "@" ); } se ( IsTesting() )delete_glob ("@" + DoubleToStr(ID,0) + "@" ); retorno(0); }
void delete_glob ( string c ) { int i; para ( i = GlobalVariablesTotal()-1; i>= 0 ; i-- )if ( StringFind(GlobalVariableName(i),c) >= 0 )GlobalVariableDel(GlobalVariableName(i)) }
int start() { Comentário(Info()); int KOL_BUY = order_total(0); int KOL_SELL = order_total(1); duplo l;
se ( order_total() == 0 ) { aberto(0,Lote,0,TP); aberto(1,Lote,0,TP); }
se ( KOL_BUY == 0 && KOL_SELL != 0 ) { aberto(0,Lote,0,TP); l = último_comércio(1); aberto(1,1,0,0,0); modificar_ordens(1); }
se ( KOL_BUY != 0 && KOL_SELL == 0 ) { aberto(1,Lote,0,TP); l = last_trade(0); aberto(0,l,0,0,0); modificar_ordens(0); }
retorno(0); }
Informações de cordas() { int i; duplo buff_1 = 0, buff_2 = 0, buff_3 = 0; res de fio = "\n";
for( i = OrderHistoryTotal() - 1; i >= 0; i-- ) { OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); if( OrderMagicNumber() == ID ) { if ( OrderOpenTime() >= iTime(NULL,PERIOD_D1,0) )buff_1 += OrderProfit(); if ( OrderOpenTime() >= iTime(NULL,PERIOD_D1,1) && OrderOpenTime() < iTime(NULL,PERIOD_D1,0) )buff_2 += OrderProfit(); if ( OrderOpenTime() >= GlobalVariableGet(GLOB_START) )buff_3 += OrderProfit(); } }
res = res + "Lucro na moeda de depósito para " + TimeToStr(iTime(NULL,PERIOD_D1,0)) + ": " + DoubleToStr(buff_1,0) + "\n" + "\n"; res = res + "Lucro em moeda de depósito para " + TimeToStr(iTime(NULL,PERIOD_D1,1)) + ": " + DoubleToStr(buff_2,0) + "\n" + "\n"; res = res + "Lucro no total da moeda de depósito:" + DoubleToStr(buff_3,0) + "\n"; retorno(res); }
void modify_orders( tipo int ) { int i; datatimetime_last = 0, time_first = TimeCurrent(); duplo SPREAD = MarketInfo(Symbol(),MODE_SPREAD)*MarketInfo(Symbol(),MODE_POINT), op_pr_last, op_pr_first, level;
for( i = OrderTotal() - 1; i >= 0; i-- ) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if( OrderMagicNumber() == ID && OrderType() == tipo ) { se ( OrderOpenTime() > time_last ) { op_pr_last = OrderOpenPrice(); time_last = OrderOpenTime(); } se ( OrderOpenTime() < time_first ) { op_pr_first = OrderOpenPrice(); time_first = OrderOpenTime(); } } }
se ( tipo == 0 )nível = op_pr_last + MathAbs(op_pr_last-op_pr_first) * (SL/100); se ( tipo == 1 )nível = op_pr_last - MathAbs(op_pr_last-op_pr_first) * (SL/100);
for( i = OrderTotal() - 1; i >= 0; i -- ) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if( OrderMagicNumber() == ID && OrderType() == type && NormalizeDouble(OrderTakeProfit(),Digits) != NormalizeDouble(level,Digits) )OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),level,0) } }
duplo último_comércio( int t ) { int i; duplo res = -1; data/hora=0;
for(i=OrdensTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderOpenTime()>time && OrderMagicNumber()==ID && OrderType() == t) { res = OrderLots(); tempo = OrderOpenTime(); } } se ( multiplicador ) retornar(res * Lot_koeff); se ( !multiplicador ) retornar(res + Lot_koeff); } int open(int tipo, double l, double sl=0, double tp=0, string comm = "") { int isOpened = 0, tente = 0; duplo s,t; enquanto ( IsTradeContextBusy() ){Sleep(500);} RefreshRates(); if ( sl != 0 && sl < MarketInfo(Symbol(),MODE_STOPLEVEL) )sl = MarketInfo(Symbol(),MODE_STOPLEVEL); if ( tp != 0 && tp < MarketInfo(Symbol(),MODE_STOPLEVEL) )tp = MarketInfo(Symbol(),MODE_STOPLEVEL); se ( tipo == 0 ) { se ( tp == 0 )t = 0; se ( tp != 0 )t = Perguntar + tp * Ponto; se ( sl == 0 )s = 0; se ( sl != 0 )s = Bid - sl * Ponto; } se ( tipo == 1 ) { se ( tp == 0 )t = 0; se ( tp != 0 )t = Proposta - tp * Ponto; se ( sl == 0 )s = 0; se ( sl != 0 )s = Pergunta + sl * Ponto; } s = NormalizarDuplo(s,Dígitos); t = NormalizeDuplo(t,Dígitos); if(type==0)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Ask,Digits),10,s,t,comm,ID); if(type==1)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Bid,Digits),10,s,t,comm,ID); Sleep(500); enquanto(isOpened<0) { enquanto ( IsTradeContextBusy() ){Sleep(500);} RefreshRates(); se ( tipo == 0 ) { se ( tp == 0 )t = 0; se ( tp != 0 )t = Proposta + tp * Ponto; se ( sl == 0 )s = 0; se ( sl != 0 )s = Bid - sl * Ponto; } se ( tipo == 1 ) { se ( tp == 0 )t = 0; se ( tp != 0 )t = Perguntar - tp * Ponto; se ( sl == 0 )s = 0; se ( sl != 0 )s = Pergunta + sl * Ponto; } s = NormalizarDuplo(s,Dígitos); t = NormalizeDuplo(t,Dígitos); try++; if(type==0)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Ask,Digits),10,s,t,comm,ID); if(type==1)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Bid,Digits),10,s,t,comm,ID); if(try > 5) break; if(isOpened>=0)break; Sleep(500); } if(isOpened<0) Alert("Ordem não aberta, erro :", GetLastError())); retorno(isOpened); }
int order_total( int type_1 = -1, int type_2 = -1 ) { int i; int kol=0; for(i=OrdensTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderMagicNumber()==ID && (OrderType() == type_1 || OrderType() == type_2) )kol+++; if(OrderMagicNumber()==ID && type_1 == -1 && type_2 == -1 )kol++; } retorno(kol); }
check_lot duplo(duplo &lo) { double l = MarketInfo(Symbol(),MODE_LOTSTEP); int ok = 0; enquanto ( l < 1 ){l*=10;ok++;} if( lo < MarketInfo(Symbol(),MODE_MINLOT) )lo = MarketInfo(Symbol(),MODE_MINLOT); if( lo > MarketInfo(Symbol(),MODE_MAXLOT) )lo = MarketInfo(Symbol(),MODE_MAXLOT); return(NormalizeDouble(lo,ok));
Bom dia para todos. Cavalheiros, tenho uma pergunta, por favor me esclareçam, se eu trabalhar com Alpari e Master_Forex eu testei um Expert Advisor nas histórias que eu descarrego do meu terminal de trabalho, nada de fora, nenhuma história esquerda, como do Dukas, nenhum programa auxiliar como o Tick Data Suite, apenas 90% modelagem do terminal do meu DS especificamente Alpari ou Master_Forex, método ........ Eu testei meio ano em diferentes condições e parâmetros, escolhi o melhor, depois teste de volta e no semestre seguinte, então 2-5 anos, então tudo na pilha e a coruja está pronto. Pode ser um pré-campeão confiável ou ainda precisa de 99% e tudo a ele ligado.
Descobri no fórum que isso é possível: https://www.mql5.com/ru/forum/141467
E onde posso encontrar um emulador de carrapatos?
Então não é possível implementar a emulação de carrapatos nos fins de semana com MQL4???
Apenas nessa página, o link para o qual você postou em seu post. Leia-o com mais atenção.
Sim, eu fui estúpido. Só preciso começar(); começar adicionalmente via init(){}...
int init(){start();}
...
início nulo(){...}
Obrigado, eu descobri.
Como posso resgatar meus bônus por dinheiro?
Bônus de quem?
Eu tenho o seguinte código:
data de início externa = D'2013.10.17 23:59';
int start()
{
int b1=iBarShift(Símbolo(),0,start,0);
duplo hb=iHigh(Símbolo(),0,b1); //bar
duplo hb2=iHigh(Símbolo(),0,b1-1); //bar de amanhã a partir da data especificada
Você poderia me dizer como colocar o dia de ontem a partir da data especificada, porque duplo hb3=iHigh(Symbol(),0,b1+1); não funciona...
Olá a todos!!! Tenho uma ordem de abertura da EA contra o movimento, como mudar ou aconselhar onde mudar????
fio GLOB_START;
int init()
{
GLOB_START = "@" + DoubleToStr(ID,0) + "@" + "_start";
if !GlobalVariableCheck( GLOB_START )GlobalVariableSet(GLOB_START,TimeCurrent());
retorno(0);
}
int deinit()
{
switch( UninitializeReason() )
{
caso REASON_REMOVE: delete_glob ("@" + DoubleToStr(ID,0) + "@" );
}
se ( IsTesting() )delete_glob ("@" + DoubleToStr(ID,0) + "@" );
retorno(0);
}
void delete_glob ( string c )
{
int i;
para ( i = GlobalVariablesTotal()-1; i>= 0 ; i-- )if ( StringFind(GlobalVariableName(i),c) >= 0 )GlobalVariableDel(GlobalVariableName(i))
}
int start()
{
Comentário(Info());
int KOL_BUY = order_total(0);
int KOL_SELL = order_total(1);
duplo l;
se ( order_total() == 0 )
{
aberto(0,Lote,0,TP);
aberto(1,Lote,0,TP);
}
se ( KOL_BUY == 0 && KOL_SELL != 0 )
{
aberto(0,Lote,0,TP);
l = último_comércio(1);
aberto(1,1,0,0,0);
modificar_ordens(1);
}
se ( KOL_BUY != 0 && KOL_SELL == 0 )
{
aberto(1,Lote,0,TP);
l = last_trade(0);
aberto(0,l,0,0,0);
modificar_ordens(0);
}
retorno(0);
}
Informações de cordas()
{
int i;
duplo buff_1 = 0, buff_2 = 0, buff_3 = 0;
res de fio = "\n";
for( i = OrderHistoryTotal() - 1; i >= 0; i-- )
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if( OrderMagicNumber() == ID )
{
if ( OrderOpenTime() >= iTime(NULL,PERIOD_D1,0) )buff_1 += OrderProfit();
if ( OrderOpenTime() >= iTime(NULL,PERIOD_D1,1) && OrderOpenTime() < iTime(NULL,PERIOD_D1,0) )buff_2 += OrderProfit();
if ( OrderOpenTime() >= GlobalVariableGet(GLOB_START) )buff_3 += OrderProfit();
}
}
res = res + "Lucro na moeda de depósito para " + TimeToStr(iTime(NULL,PERIOD_D1,0)) + ": " + DoubleToStr(buff_1,0) + "\n" + "\n";
res = res + "Lucro em moeda de depósito para " + TimeToStr(iTime(NULL,PERIOD_D1,1)) + ": " + DoubleToStr(buff_2,0) + "\n" + "\n";
res = res + "Lucro no total da moeda de depósito:" + DoubleToStr(buff_3,0) + "\n";
retorno(res);
}
void modify_orders( tipo int )
{
int i;
datatimetime_last = 0, time_first = TimeCurrent();
duplo SPREAD = MarketInfo(Symbol(),MODE_SPREAD)*MarketInfo(Symbol(),MODE_POINT), op_pr_last, op_pr_first, level;
for( i = OrderTotal() - 1; i >= 0; i-- )
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if( OrderMagicNumber() == ID && OrderType() == tipo )
{
se ( OrderOpenTime() > time_last )
{
op_pr_last = OrderOpenPrice();
time_last = OrderOpenTime();
}
se ( OrderOpenTime() < time_first )
{
op_pr_first = OrderOpenPrice();
time_first = OrderOpenTime();
}
}
}
se ( tipo == 0 )nível = op_pr_last + MathAbs(op_pr_last-op_pr_first) * (SL/100);
se ( tipo == 1 )nível = op_pr_last - MathAbs(op_pr_last-op_pr_first) * (SL/100);
for( i = OrderTotal() - 1; i >= 0; i -- )
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if( OrderMagicNumber() == ID && OrderType() == type && NormalizeDouble(OrderTakeProfit(),Digits) != NormalizeDouble(level,Digits) )OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),level,0)
}
}
duplo último_comércio( int t )
{
int i;
duplo res = -1;
data/hora=0;
for(i=OrdensTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderOpenTime()>time && OrderMagicNumber()==ID && OrderType() == t)
{
res = OrderLots();
tempo = OrderOpenTime();
}
}
se ( multiplicador ) retornar(res * Lot_koeff);
se ( !multiplicador ) retornar(res + Lot_koeff);
}
int open(int tipo, double l, double sl=0, double tp=0, string comm = "")
{
int isOpened = 0, tente = 0;
duplo s,t;
enquanto ( IsTradeContextBusy() ){Sleep(500);}
RefreshRates();
if ( sl != 0 && sl < MarketInfo(Symbol(),MODE_STOPLEVEL) )sl = MarketInfo(Symbol(),MODE_STOPLEVEL);
if ( tp != 0 && tp < MarketInfo(Symbol(),MODE_STOPLEVEL) )tp = MarketInfo(Symbol(),MODE_STOPLEVEL);
se ( tipo == 0 )
{
se ( tp == 0 )t = 0;
se ( tp != 0 )t = Perguntar + tp * Ponto;
se ( sl == 0 )s = 0;
se ( sl != 0 )s = Bid - sl * Ponto;
}
se ( tipo == 1 )
{
se ( tp == 0 )t = 0;
se ( tp != 0 )t = Proposta - tp * Ponto;
se ( sl == 0 )s = 0;
se ( sl != 0 )s = Pergunta + sl * Ponto;
}
s = NormalizarDuplo(s,Dígitos);
t = NormalizeDuplo(t,Dígitos);
if(type==0)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Ask,Digits),10,s,t,comm,ID);
if(type==1)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Bid,Digits),10,s,t,comm,ID);
Sleep(500);
enquanto(isOpened<0)
{
enquanto ( IsTradeContextBusy() ){Sleep(500);}
RefreshRates();
se ( tipo == 0 )
{
se ( tp == 0 )t = 0;
se ( tp != 0 )t = Proposta + tp * Ponto;
se ( sl == 0 )s = 0;
se ( sl != 0 )s = Bid - sl * Ponto;
}
se ( tipo == 1 )
{
se ( tp == 0 )t = 0;
se ( tp != 0 )t = Perguntar - tp * Ponto;
se ( sl == 0 )s = 0;
se ( sl != 0 )s = Pergunta + sl * Ponto;
}
s = NormalizarDuplo(s,Dígitos);
t = NormalizeDuplo(t,Dígitos);
try++;
if(type==0)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Ask,Digits),10,s,t,comm,ID);
if(type==1)isOpened = OrderSend(Symbol(),type,check_lot(l),NormalizeDouble(Bid,Digits),10,s,t,comm,ID);
if(try > 5) break;
if(isOpened>=0)break;
Sleep(500);
}
if(isOpened<0) Alert("Ordem não aberta, erro :", GetLastError()));
retorno(isOpened);
}
int order_total( int type_1 = -1, int type_2 = -1 )
{
int i;
int kol=0;
for(i=OrdensTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==ID && (OrderType() == type_1 || OrderType() == type_2) )kol+++;
if(OrderMagicNumber()==ID && type_1 == -1 && type_2 == -1 )kol++;
}
retorno(kol);
}
check_lot duplo(duplo &lo)
{
double l = MarketInfo(Symbol(),MODE_LOTSTEP);
int ok = 0;
enquanto ( l < 1 ){l*=10;ok++;}
if( lo < MarketInfo(Symbol(),MODE_MINLOT) )lo = MarketInfo(Symbol(),MODE_MINLOT);
if( lo > MarketInfo(Symbol(),MODE_MAXLOT) )lo = MarketInfo(Symbol(),MODE_MAXLOT);
return(NormalizeDouble(lo,ok));
Como faço um arrasto para "Fundos:" (AccountEquity())?
Parâmetros
duplo TrailingStart externo = 10000; // Nível de TrailingStart
TrailingStop duplo externo = 100; // Tamanho do TrailingStop
duplo TrailingStep externo = 10; // TrailingStep externo
Como encontrar dois fractais superiores/inferiores em uma fila? A figura abaixo.
Tentei escrever um indicador, mas não consegui pensar bem.
Talvez alguém tenha visto um indicador assim pronto?