Você está perdendo oportunidades de negociação:
- Aplicativos de negociação gratuitos
- 8 000+ sinais para cópia
- Notícias econômicas para análise dos mercados financeiros
Registro
Login
Você concorda com a política do site e com os termos de uso
Se você não tem uma conta, por favor registre-se
Olá Pro-Coders,
Será que alguém poderia ajudar?
Eu gostaria que minha EA abrisse uma Buy Trade e fechasse uma Sell Trade existente sobre a mudança de tendência.
Ele o faz, mas somente quando teve lucro. Quando a tendência muda enquanto a posição ainda está
aberto, ele funciona em StopLoss. (Veja foto). Às vezes está funcionando e às vezes não.
O que eu poderia melhorar?
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>55)
{
OpenBuy_ =true;
CloseSell_=true;
}
else
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<45)
{
OpenSell_=true;
CloseBuy_=true;
}
Essa parte do código não é suficiente para concluir nada
Olá, Mladen,
Muito obrigado por ter analisado meu problema.
Por favor, encontre o código abaixo que encerrará os pedidos de Venda e Compra existentes.
Também deve abrir uma nova ordem de Compra ou Venda se a tendência apontar na direção certa...
//+------------------------------------------------------------------+
//| Signal Exit Buy / Exit Sell)
//| Iterate through open tickets
//+------------------------------------------------------------------+
for(int i=0; i<Total; i++)
{
dummyResult=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber)
{
for(int z=OrdersTotal()-1; z>=0; z--)
{
if(OrderSelect(z,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
buy_ticket=OrderTicket();
else
if(OrderType()== OP_SELL)
sell_ticket=OrderTicket();
}
// Close BUY
if(CloseBuy_==true && buy_ticket!=0)
{
dummyResult=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage*PipMultiplier,MediumSeaGreen);
if(EachTickMode) TickCheck = True;
if(!EachTickMode) BarCount = Bars;
Print("Error closing Buy #",(string)OrderTicket()," Error code ",(string)GetLastError());
// Open new Sell Order
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<45) OpenSell_=true;
}
// Close SELL
if(CloseSell_==true && sell_ticket!=0)
{
dummyResult=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage*PipMultiplier,DarkOrange);
if(EachTickMode) TickCheck = True;
if(!EachTickMode) BarCount = Bars;
Print("Error closing Sell #",(string)OrderTicket()," Error code ",(string)GetLastError());
// Open new Buy Order
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>55) OpenBuy_ =true;
}
Olá, Mladen,
Muito obrigado por ter analisado meu problema.
Por favor, encontre o código abaixo que encerrará os pedidos de Venda e Compra existentes.
Também deve abrir uma nova ordem de Compra ou Venda se a tendência apontar na direção certa...
//+------------------------------------------------------------------+
//| Signal Exit Buy / Exit Sell)
//| Iterate through open tickets
//+------------------------------------------------------------------+
for(int i=0; i<Total; i++)
{
dummyResult=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber)
{
for(int z=OrdersTotal()-1; z>=0; z--)
{
if(OrderSelect(z,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
buy_ticket=OrderTicket();
else
if(OrderType()== OP_SELL)
sell_ticket=OrderTicket();
}
// Close BUY
if(CloseBuy_==true && buy_ticket!=0)
{
dummyResult=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage*PipMultiplier,MediumSeaGreen);
if(EachTickMode) TickCheck = True;
if(!EachTickMode) BarCount = Bars;
Print("Error closing Buy #",(string)OrderTicket()," Error code ",(string)GetLastError());
// Open new Sell Order
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<45) OpenSell_=true;
}
// Close SELL
if(CloseSell_==true && sell_ticket!=0)
{
dummyResult=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage*PipMultiplier,DarkOrange);
if(EachTickMode) TickCheck = True;
if(!EachTickMode) BarCount = Bars;
Print("Error closing Sell #",(string)OrderTicket()," Error code ",(string)GetLastError());
// Open new Buy Order
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>55) OpenBuy_ =true;
}
Por que você está usando um loop dentro do loop? Não há nenhuma necessidade disso. Livre-se dele, e quando o código for simplificado, tudo será mais fácil de limpar também.
Olá, Mladen,
Eu modifiquei o código de acordo, você acha que agora está melhor?
Você poderia, por favor, dar uma olhada? Este código ainda está em um pseudo estado, ainda não testado.
Obrigado de antemão!
//+-------------------------------------------------------------------------+
int PositionIndex;//| Signal close Buy / close Sell / Open new BUY or SELL order when possible
int TotalNumberOfOrders;
TotalNumberOfOrders = OrdersTotal();// store number of Orders in the variable
for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)// for loop to loop through all Orders . . COUNT DOWN TO ZERO !
{
if(!OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES)) continue;// if the OrderSelect fails advance the loop to the next PositionIndex
if(OrderMagicNumber() == MagicNumber // does the Order's Magic Number match our EA's magic number ?
&& OrderSymbol() == Symbol() // does the Order's Symbol match the Symbol our EA is working on ?
&& (OrderType() == OP_BUY // is the Order a Buy Order ?
|| OrderType() == OP_SELL )) // or is it a Sell Order ?
if (! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage*PipMultiplier,DarkOrange )) //try to close the order
Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError()); //if the Order Close failed print some helpful information
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>52) // Check if new entry condition is given
{
OpenBuy_=true;
}
else
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<42)
{
OpenSell_=true;
}
} // end of For loop
Olá, Mladen,
Eu modifiquei o código de acordo, você acha que agora está melhor?
Você poderia, por favor, dar uma olhada? Este código ainda está em um pseudo estado, ainda não testado.
Obrigado de antemão!
//+-------------------------------------------------------------------------+
int PositionIndex;//| Signal close Buy / close Sell / Open new BUY or SELL order when possible
int TotalNumberOfOrders;
TotalNumberOfOrders = OrdersTotal();// store number of Orders in the variable
for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)// for loop to loop through all Orders . . COUNT DOWN TO ZERO !
{
if(!OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES)) continue;// if the OrderSelect fails advance the loop to the next PositionIndex
if(OrderMagicNumber() == MagicNumber // does the Order's Magic Number match our EA's magic number ?
&& OrderSymbol() == Symbol() // does the Order's Symbol match the Symbol our EA is working on ?
&& (OrderType() == OP_BUY // is the Order a Buy Order ?
|| OrderType() == OP_SELL )) // or is it a Sell Order ?
if (! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage*PipMultiplier,DarkOrange )) //try to close the order
Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError()); //if the Order Close failed print some helpful information
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>52) // Check if new entry condition is given
{
OpenBuy_=true;
}
else
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<42)
{
OpenSell_=true;
}
} // end of For loop
Mntiwana
Here is the EA for B& S with 15 warnings left. If some one could tell me how to clear Declaration of global such as “declaration of 'trailingprofit' hides global declaration at line 62 mnt-BuyersSellers EA v1.00.mq4 915 53” I will clear it up.
I also need a few files to run it.
2016.12.17 16:01:35.347 2016.11.01 00:47 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\4BARS-MTF-BBH 1.06.ex4' [2]
2016.12.17 16:01:29.815 2016.11.01 00:17 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\BullBearHelper 1.00.ex4' [2]
2016.12.17 16:01:29.815 2016.11.01 00:17 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\AdaptiveLaguerreFilter.ex4' [2]
And ,"Slope Direction Line"
Let me Know
Ray
traderduke
Obrigado por seu interesse,o pacote indi está anexado,na verdade todo o sistema é da FF (http://www.tradingsystemforex.com/ideas-for-expert-advisors/4662-buyers-sellers-ea.html)
A gspe estava trabalhando nisso, mas acho que toda a estrutura da EA é de "funyoo" e só estou interessado no código EA como amostra/modelo de estrutura para criar uma nova EA com, o resto de sua estratégia não é fruto pleno como eu acho, podemos formar melhor do que isso, temos indicadores 100 vezes melhores por enquanto :)
cumprimentos
"crsnapebtinternetcom" e MLADEN ..... então eu testei e funcionou, mas precisa de alguma certificação :)
cumprimentos
traderduke
Obrigado por seu interesse,o pacote indi está anexado,na verdade todo o sistema é da FF (http://www.tradingsystemforex.com/ideas-for-expert-advisors/4662-buyers-sellers-ea.html)
A gspe estava trabalhando nisso, mas acho que toda a estrutura da EA é de "funyoo" e só estou interessado no código EA como amostra/modelo de estrutura para criar uma nova EA com, o resto de sua estratégia não é fruto pleno como eu acho, podemos formar melhor do que isso, temos indicadores 100 vezes melhores por enquanto :)
cumprimentos
Gente
Os Funyoos EAs geralmente mostraram bons resultados ao usar o martingale no teste de costas. Eu seria muito cuidadoso ao usá-los