//+------------------------------------------------------------------+//| MACD Sample.mq4 |//| Copyright 2005-2014, MetaQuotes Software Corp. |//| http://www.mql4.com |//+------------------------------------------------------------------+#property copyright"2005-2014, MetaQuotes Software Corp."#property link"http://www.mql4.com"inputdouble TakeProfit =3160;
inputdouble Lots =0.5;
inputdouble TrailingStop =1040;
inputint OpenLevel =22;
inputint CloseLevel=77;
inputintPeriod =85;
inputint Period1 =57;
int LastBars=0;
externint Magic = 110725;
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnTick(void)
{
int cnt,ticket,total;
//---// initial data checks// it is important to make sure that the expert works with a normal// chart and the user did not make any mistakes setting external // variables (Lots, StopLoss, TakeProfit, // TrailingStop) in our case, we check TakeProfit// on a chart of less than 100 bars//---//--- Trade only if new bar has arrivedif(LastBars!=Bars) LastBars=Bars;
elsereturn(0);
if(Bars<100)
{
Print("bars less than 100");
return;
}
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return;
}
//--- to simplify the coding and speed up access data are put into internal variables
total=OrdersTotal();
if(total<1)
{
//--- no opened orders identifiedif(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ",AccountFreeMargin());
return;
}
//--- check for long position (BUY) possibilityif(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period)>iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period1))
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-TakeProfit*Point,Bid+TakeProfit*Point,"USDCADH4",Magic,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("BUY order opened : ",OrderOpenPrice());
}
elsePrint("Error opening BUY order : ",GetLastError());
return;
}
//--- check for short position (SELL) possibilityif(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period1)<iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period))
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+TakeProfit*Point,Ask-TakeProfit*Point,"USDCADH4",Magic,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
Print("SELL order opened : ",OrderOpenPrice());
}
elsePrint("Error opening SELL order : ",GetLastError());
}
//--- exit from the "no opened orders" blockreturn;
}
//--- it is important to enter the market correctly, but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++)
{
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
//--- long position is openedif(OrderType()==OP_BUY)
{
//--- should it be closed?if(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period1)<iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period))
{
//--- close order and exitif(!OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet))
Print("OrderClose error ",GetLastError());
return;
}
//--- check for trailing stopif(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
//--- modify order and exitif(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green))
Print("OrderModify error ",GetLastError());
return;
}
}
}
}
else// go to short position
{
//--- should it be closed?if(iRSI(NULL,0,OpenLevel,PRICE_LOW,Period)>iRSI(NULL,0,CloseLevel,PRICE_HIGH,Period1))
{
//--- close order and exitif(!OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet))
Print("OrderClose error ",GetLastError());
return;
}
//--- check for trailing stopif(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
//--- modify order and exitif(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red))
Print("OrderModify error ",GetLastError());
return;
}
}
}
}
}
}
//---
}
//+------------------------------------------------------------------+
Hola. Por favor, ayúdenme a entender... El Asesor Experto está cerrando las operaciones de otras personas o no abriendo las suyas si hay operaciones de otras personas.
Hola. Por favor, ayúdenme a entender... El Asesor Experto está cerrando las operaciones de otras personas o no abriendo las suyas si hay operaciones de otras personas.
Si se escribe arriba, el Asesor Experto cierra las operaciones abiertas manualmente,
Si lo pongo de esta manera
if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()&& OrderMagicNumber()==Magic) // check for symbol
Si hay operaciones abiertas manualmente, el Asesor Experto no cerrará otras operaciones, pero no abrirá las suyas si hay operaciones abiertas manualmente.
Si se escribe arriba, el Asesor Experto cierra las operaciones abiertas manualmente,
Si lo pongo de esta manera
Si hay operaciones abiertas manualmente, el Asesor Experto no cerrará otras operaciones, pero no abrirá las suyas si hay operaciones abiertas manualmente.
También es necesario seleccionar por medio de la magia al abrir
¿Qué es esto? La apertura está indicada. La cuestión es que cuando se utilizan varios Asesores Expertos, no hay ningún problema. El problema ocurre sólo cuando hay una apertura manual de una posición en la cuenta.
En cuanto se abren operaciones en la cuenta manualmente, el Asesor Experto deja de funcionar.
En cuanto elimine esto en el código, total=OrdersTotal();
if(total<1)
Los EAs van directos, pero abren muchas operaciones
¿Qué es esto? La apertura está indicada. El caso es que cuando se utilizan varios EAs no hay ningún problema, el problema se da sólo cuando hay una apertura manual de una posición en la cuenta.
En cuanto se abren operaciones en la cuenta manualmente, el Asesor Experto deja de funcionar.
En cuanto elimine esto en el código, total=OrdersTotal();
if(total<1)
Los EAs van directos, pero abren muchas operaciones.
Esto es lo que estoy hablando - OrdersTotal() es para todas las órdenes y necesita una orden EA
if(CountOrders("", -1, Magic)<1)
{
открытие ордеров
}
//+----------------------------------------------------------------------------+//| Подсчет ордеров |//+----------------------------------------------------------------------------+//| -1 - Все типы ордеров |//| 0 - ордера типа BUY |//| 1 - ордера типа SELL |//| 2 - ордера типа BUYLIMIT |//| 3 - ордера типа SELLLIMIT |//| 4 - ордера типа BUYSTOP |//| 5 - ордера типа SELLSTOP |//+----------------------------------------------------------------------------+int CountOrders(string symb="", int or_ty=-1, int magiс=-1)
{
int cnt=0;
if(symb=="0") symb=_Symbol;
for(int pos=OrdersTotal()-1;pos>=0;pos--)
{
if(OrderSelect(pos,SELECT_BY_POS)==true)
{
if((OrderSymbol()==symb || symb=="")&&(or_ty<0 || or_ty==OrderType()))
{
if(magiс<0 || OrderMagicNumber()==magiс) cnt++;
}
}
}
return(cnt);
}
Envié una solicitud ayer, ha pasado más de un día y silencio.
1. Ir al cajero automático más cercano, insertar la tarjeta, introducir el código pin...
2. Ve al banco más cercano, haz contacto visual, luego sigue la situación...
3. Ve al mercado. 3) Ir al mercado. Ve al banco. Retirar fondos (puedes retirarlos todos, no sólo los tuyos...) ...
4. ¡Si tienes que retirar dinero de MMM, entonces ni siquiera el tanque te ayudará!
Y en serio, ¡no puedes!
Hola. Por favor, ayúdenme a entender... El Asesor Experto está cerrando las operaciones de otras personas o no abriendo las suyas si hay operaciones de otras personas.
Hola. Por favor, ayúdenme a entender... El Asesor Experto está cerrando las operaciones de otras personas o no abriendo las suyas si hay operaciones de otras personas.
Si se escribe arriba, el Asesor Experto cierra las operaciones abiertas manualmente,
Si lo pongo de esta manera
Si hay operaciones abiertas manualmente, el Asesor Experto no cerrará otras operaciones, pero no abrirá las suyas si hay operaciones abiertas manualmente.
Si se escribe arriba, el Asesor Experto cierra las operaciones abiertas manualmente,
Si lo pongo de esta manera
Si hay operaciones abiertas manualmente, el Asesor Experto no cerrará otras operaciones, pero no abrirá las suyas si hay operaciones abiertas manualmente.
También necesito la selección del número mágico en la apertura
¿Qué es esto? La apertura está indicada. La cuestión es que cuando se utilizan varios Asesores Expertos, no hay ningún problema. El problema ocurre sólo cuando hay una apertura manual de una posición en la cuenta.
En cuanto se abren operaciones en la cuenta manualmente, el Asesor Experto deja de funcionar.
En cuanto elimine esto en el código, total=OrdersTotal();
if(total<1)
Los EAs van directos, pero abren muchas operaciones
¿Qué es esto? La apertura está indicada. El caso es que cuando se utilizan varios EAs no hay ningún problema, el problema se da sólo cuando hay una apertura manual de una posición en la cuenta.
En cuanto se abren operaciones en la cuenta manualmente, el Asesor Experto deja de funcionar.
En cuanto elimine esto en el código, total=OrdersTotal();
if(total<1)
Los EAs van directos, pero abren muchas operaciones.
Esto es lo que estoy hablando - OrdersTotal() es para todas las órdenes y necesita una orden EA
A eso me refiero, OrdersTotal() son todos los pedidos y tú quieres los de EA
Esto es en lugar de
total=Total de pedidos();
if(total<1) o dejamos este también?