[¡AVISO CERRADO!] Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen. No puedo ir a ningún sitio sin ti. - página 174

 
Por favor, avisa. Tengo un Asesor Experto en una ventana (por ejemplo, USDJPY), pero necesito que ponga flechas(ObjectCreate) en otras ventanas abiertas, por ejemplo, AUDUSD, EURUSD, etc.
 
nicdevis >> :
>> Por favor, avisa. Tengo un Asesor Experto en una ventana (por ejemplo, USDJPY) y necesito que ponga flechas(ObjectCreate) en un momento determinado en otras ventanas abiertas, por ejemplo, AUDUSD, EURUSD, etc.

Si miras en el ayudante ObjectCreate, puedes ver claramente que sólo funciona dentro de un único gráfico abierto, en el que se encuentra el indicador o Asesor Experto. La salida puede ser la transferencia de datos al Asesor Experto en la ventana deseada a través de las variables globales o del archivo.

 
granit77 >> :

Si miras en el ayudante ObjectCreate, puedes ver claramente que sólo funciona dentro de un único gráfico abierto, en el que se encuentra el indicador o Asesor Experto. La salida puede ser la transferencia de datos al Asesor Experto en la ventana requerida a través de las variables globales o del archivo.

Es decir, ¿no hay forma de hacerlo desde otra ventana? >> Gracias.

 

¿Cómo se puede desactivar esta función de modificación de órdenes pendientes mediante variables externas?


//+------------------------------------------------------------------+
//| Модификация ордеров                                              |
//+------------------------------------------------------------------+
void ModifyOrders() {
  bool   fm;
  double ldStop=0, ldTake=0;
  int    spr=MarketInfo(Symbol(), MODE_SPREAD);
  double pAsk=Ask+( DistanceSet+ spr)*Point;
  double pBid=Bid- DistanceSet*Point;

  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()== MAGIC+1) {
        if ( StopLoss!=0) ldStop= pAsk- StopLoss*Point;
        if ( TakeProfit!=0) ldTake= pAsk+ TakeProfit*Point;
        OrderModify(OrderTicket(), pAsk, ldStop, ldTake, 0, clModifyBuy);
      }
      if (OrderSymbol()==Symbol() && OrderMagicNumber()== MAGIC+2) {
        if ( StopLoss!=0) ldStop= pBid+ StopLoss*Point;
        if ( TakeProfit!=0) ldTake= pBid- TakeProfit*Point;
        OrderModify(OrderTicket(), pBid, ldStop, ldTake, 0, clModifySell);
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Возвращает флаг существования ордера или позиции по номеру       |
//+------------------------------------------------------------------+
bool ExistOrder(int mn) {
  bool Exist= False;
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()== MAGIC+ mn) {
        Exist= True; break;
      }
    }
  }
  return( Exist);
}

//+------------------------------------------------------------------+
//| Возвращает флаг существования позиции по номеру                  |
//+------------------------------------------------------------------+
bool ExistPosition(int mn) {
  bool Exist= False;
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()== MAGIC+ mn) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          Exist= True; break;
        }
      }
    }
  }
  return( Exist);
}
 
1Rakso писал(а) >>

¿Cómo se puede desactivar esta función de modificación de órdenes pendientes mediante variables externas?

extern bool bModify=false;
int start()
  if ( bModify) ModifyOrders();
  return(0);
}
Algo así
 
Vinin >> :
>> Algo así.

Gracias. ¡Vininin!

>> Lo intentaré).

 
Canal EA

Programadores, por favor, ayuda, necesito un EA que abra órdenes, aunque ya estén abiertas. Este es un EA de canal. Cada vez que una línea toca una de las líneas, se debe abrir la orden correspondiente. Me gustaría darles las gracias por adelantado.



//+------------------------------------------------------------------+
//| TradeChannel.mq4 |
//| Copyright © 2005, Yuri Makarov |
//| http://mak.tradersmind.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Yuri Makarov"
#property link "http://mak.tradersmind.com"

extern double Lots = 1.0;
extern int Slippage = 5;
extern int TimeOut = 10000;

double SetLevel(double Level, double NewLevel, string ObjName, int Style)
{
switch (Style)
{
case 1: // Buy Order line
ObjectSet(ObjName,OBJPROP_COLOR,Blue);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet(ObjName,OBJPROP_WIDTH,2);
break;
case 2: // Sell Order line
ObjectSet(ObjName,OBJPROP_COLOR,Red);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_SOLID);
ObjectSet(ObjName,OBJPROP_WIDTH,2);
break;
case 3: // Buy Stop line
ObjectSet(ObjName,OBJPROP_COLOR,Blue);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_DASH);
ObjectSet(ObjName,OBJPROP_WIDTH,1);
break;
case 4: // Sell Stop line
ObjectSet(ObjName,OBJPROP_COLOR,Red);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_DASH);
ObjectSet(ObjName,OBJPROP_WIDTH,1);
break;
case 5: // Buy Take line
ObjectSet(ObjName,OBJPROP_COLOR,Blue);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_DOT);
ObjectSet(ObjName,OBJPROP_WIDTH,1);
break;
case 6: // Sell Take line
ObjectSet(ObjName,OBJPROP_COLOR,Red);
ObjectSet(ObjName,OBJPROP_STYLE,STYLE_DOT);
ObjectSet(ObjName,OBJPROP_WIDTH,1);
break;
}

if (MathAbs(NewLevel - Close[0]) < MathAbs(Level - Close[0])) return (NewLevel);
else return (Level);
}

int start()
{
int NumObj = ObjectsTotal();
double Spread = Ask - Bid;

double pBuy = 0;
double pSell = 0;
double pBuyStop = 0;
double pBuyTake = 0;
double pSellStop = 0;
double pSellTake = 0;

for (int i = 0; i < NumObj; i++)
{
string ObjName = ObjectName(i);
string ObjDesc = ObjectDescription(ObjName);
double Price = 0;

switch (ObjectType(ObjName))
{
case OBJ_HLINE:
Price = ObjectGet(ObjName,OBJPROP_PRICE1);
break;
case OBJ_TREND:
Price = ObjectGetValueByShift(ObjName,0);
break;
}

if (Price > 0)
{
if (ObjDesc == "Buy") pBuy = SetLevel(pBuy, Price, ObjName, 1); else
if (ObjDesc == "Sell") pSell = SetLevel(pSell, Price, ObjName, 2); else
if (ObjDesc == "Stop")
{
if (Price < Close[0]) pBuyStop = SetLevel(pBuyStop, Price, ObjName, 3);
else pSellStop = SetLevel(pSellStop, Price, ObjName, 4);
} else
if (ObjDesc == "Take")
{
if (Price > Close[0]) pBuyTake = SetLevel(pBuyTake, Price, ObjName, 5);
else pSellTake = SetLevel(pSellTake, Price, ObjName, 6);
}
}
}

int NumOrders = OrdersTotal();
int NumPos = 0;

for (i = 0; i < NumOrders; i++)
{
OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() != Symbol()) continue;

NumPos++;

double tp = OrderTakeProfit();
double sl = OrderStopLoss();

if (OrderType() == OP_BUY)
{
if (Bid > pSell && pSell > 0)
{
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Red);
Sleep(TimeOut);
return(0);
}
if (MathAbs(tp - pBuyTake) > Spread || MathAbs(sl - pBuyStop) > Spread)
{
OrderModify(OrderTicket(), Ask, pBuyStop, pBuyTake, 0);
Sleep(TimeOut);
return(0);
}
}

if (OrderType() == OP_SELL)
{
if (Ask < pBuy)
{
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red);
Sleep(TimeOut);
return(0);
}
if (MathAbs(tp - pSellTake) > Spread || MathAbs(sl - pSellStop) > Spread)
{
OrderModify(OrderTicket(), Bid, pSellStop, pSellTake, 0);
Sleep(TimeOut);
return(0);
}
}
}

if (NumPos > 0) return(0);
if ((pSell - pBuy) < Spread*2) return(0);

if (Bid > pSell && pSell > pBuyStop)
{
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, pSellStop, pSellTake);
Sleep(TimeOut);
return(0);
}

if (Ask < pBuy && (pBuy < pSellStop || pSellStop == 0))
{
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, pBuyStop, pBuyTake);
Sleep(TimeOut);
return(0);
}
}

int init()
{
return(0);
}

int deinit()
{
return(0);
}

 

Lo más probable es que esta línea sea un obstáculo para usted:

if (NumPos > 0) return(0);

Podemos empezar con esto. Esto debería ser eliminado.

Y separar el mecanismo de entrada de compra y venta. Toma la función de I.Kim (insértala al final del código)





//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает количество позиций.                                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
int NumberOfPositions(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), kp=0;

  if ( sy=="0") sy=Symbol();
  for ( i=0; i< k; i++)                                    {
    if (OrderSelect( i, SELECT_BY_POS, MODE_TRADES))      {
      if (OrderSymbol()== sy || sy=="")                   {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if ( op<0 || OrderType()== op)                   {
            if ( mn<0 || OrderMagicNumber()== mn) kp++;
          }}}}}  return( kp);}

Entonces la condición de apertura de la transacción será comprar:



if ( NumberOfPositions(NULL,OP_BUY, -1)<1 ) {
//если нет бай-позиций 



Y la condición para abrir una operación de venta :



if ( NumberOfPositions(NULL,OP_SELL, -1)<1) {


 
RomanS писал(а) >>

Probablemente este problema se haya resuelto antes de 2003, pero como alguien no lo sabe, lo comparto)))

Haga clic con el botón derecho del ratón en el gráfico - seleccione las propiedades - pestaña general - marque la escala fija - OK

A continuación, pase el ratón por encima de la escala de precios, haga clic con el botón izquierdo y manténgalo pulsado, mueva el ratón hacia arriba/abajo para ajustar la escala.

Puede que lo tengas en la ventana principal, así que no tienes que buscar mucho.

 
Synax >> :
Canal EA

Quiero pedirle al EA que abra órdenes aunque ya estén abiertas. Este es un EA de canal, cada vez que se toca una u otra línea, se debe abrir la orden correspondiente. Creo que este EA abrirá una orden y no abrirá otra hasta que se cierre.



He hecho lo que he descrito en el post anterior. He insertado la función de número de posiciones y he sustituido el bloque de apertura de posiciones del final por éste:

//if (NumPos > 0) return(0);
if (( pSell - pBuy) < Spread*2) return(0);
//-------------------------------------------------
if ( NumberOfPositions(NULL,OP_SELL, -1)<1) {//если нет открытых селл-позиций
if (Bid > pSell && pSell > pBuyStop)//если условия соответствуют заданным
{//продаем
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, pSellStop, pSellTake);
Sleep( TimeOut);
return(0);
}}
//-----------------------------------------------------
if ( NumberOfPositions(NULL,OP_BUY, -1)<1 ) {//если нет открытых бай-позиций
if (Ask < pBuy && ( pBuy < pSellStop || pSellStop == 0))
{// покупаем
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, pBuyStop, pBuyTake);
Sleep( TimeOut);
return(0);
}}

Ahora EA puede mantener al menos 2 posiciones al mismo tiempo.

Lo siento, no puedo probarlo ya que has olvidado adjuntar el indicador que dibuja los canales.

Archivos adjuntos: