Herramientas MT4 Expert Advisor que abra 1 sola operación por vela

 

Publi

Expert Advisor que abra 1 sola operación por vela

 

Publi

Página 1 de 3 123 ÚltimoÚltimo
Resultados 1 al 10 de 27


  1. #1




    Reputación:
    Poder de reputación: 8

    Espana
    Mensajes: 5
    Créditos: 286

    Re: Expert Advisor que abra 1 sola operación por vela


    Publi
    Expert Advisor que abra 1 sola operación por vela-20180726_222317_2_resized.jpg
    Adjunto la imagen de lo que me ocurre muchas veces...
    Foro de Forex Trading United

  2. Publi
    Publi


  3. #2




    Reputación:
    Poder de reputación: 7

    Espana
    Mensajes: 16
    Créditos: 388

    Re: Expert Advisor que abra 1 sola operación por vela

    Cita Iniciado por tivag Ver mensaje
    hola compi , en la primera parte no lo entendi bien , en cuanto al tema del trailing en donde tengas puesto el OrderOpenPrice() sumale o restale (segun sea buy o sell) la distancia que quieras y deberia irte si es que te entendido bien.

    saludos
    He probado a modificar el OrderOpenPrice() en las 4 posiciones que me vienen y no he obtenido resultado. te dejo el script por si vieses algún fallo.

    La idea, como indiqué es que el trailing stop, comience a 5 pips pero cuando el precio diste 10 pips o más del precio inicial, no cuando esté directamente a 5 pips.
    Y lo otro que busco es que debo añadir para que solo me haga una operación por vela.

    extern int MagicNumber=10001;
    extern double Lots =0.1;
    extern double StopLoss=10;
    extern double TakeProfit=10;
    extern int TrailingStop=5;
    extern int Slippage=3;
    //+------------------------------------------------------------------+
    // expert start function
    //+------------------------------------------------------------------+
    int start()
    {
    double MyPoint=Point;
    if(Digits==3 || Digits==5) MyPoint=Point*10;

    double TheStopLoss=0;
    double TheTakeProfit=0;
    if( TotalOrdersCount()==0 )
    {
    int result=0;
    if((iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,1)<iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,1))&&(iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,0)>iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,0))) // Here is your open buy rule { result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
    if(result>0)
    {
    TheStopLoss=0;
    TheTakeProfit=0;
    if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
    if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
    OrderSelect(result,SELECT_BY_TICKET);
    OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
    }
    return(0);
    }
    if((iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,1)>iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,1))&&(iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,0)<iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,0))) // Here is your open Sell rule
    {
    result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippag e,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
    if(result>0)
    {
    TheStopLoss=0;
    TheTakeProfit=0;
    if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
    if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
    OrderSelect(result,SELECT_BY_TICKET);
    OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
    }
    return(0);
    }
    }

    for(int cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()<=OP_SELL &&
    OrderSymbol()==Symbol() &&
    OrderMagicNumber()==MagicNumber
    )
    {
    if(OrderType()==OP_BUY)
    {
    if((iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,0)<iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,0))) //here is your close buy rule
    {
    OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),Slippage,Red);
    }
    if(TrailingStop>0)
    {
    if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
    {
    if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
    return(0);
    }
    }
    }
    }
    else
    {
    if((iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,0)>iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,0))) // here is your close sell rule
    {
    OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),Slippage,Red);
    }
    if(TrailingStop>0)
    {
    if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
    {
    if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyP oint*TrailingStop,OrderTakeProfit(),0,Red);
    return(0);
    }
    }
    }
    }
    }
    }
    return(0);
    }

    int TotalOrdersCount()
    {
    int result=0;
    for(int i=0;i<OrdersTotal();i++)
    {
    OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
    if (OrderMagicNumber()==MagicNumber) result++;

    }
    return (result);
    }
    Foro de Forex Trading United

  4. #3
    Avatar de tivag
    antecessor


    Reputación:
    Poder de reputación: 17

    Espana
    Mensajes: 659
    Créditos: 5.114

    Re: Expert Advisor que abra 1 sola operación por vela

    Cita Iniciado por naccant Ver mensaje
    Buenas, de nuevo.

    Gracias por lo comentado; con el trailingstop no he encontrado la forma, ya que lo he modificado en los 4 puntos donde me aparece y no realiza lo deseado. te dejo el script completo y me dices si hay un error.
    extern int MagicNumber=10001;
    extern double Lots =0.1;
    extern double StopLoss=10;
    extern double TakeProfit=10;
    extern int TrailingStop=5;
    extern int Slippage=3;
    //+------------------------------------------------------------------+
    // expert start function
    //+------------------------------------------------------------------+
    int start()
    {
    double MyPoint=Point;
    if(Digits==3 || Digits==5) MyPoint=Point*10;

    double TheStopLoss=0;
    double TheTakeProfit=0;
    if( TotalOrdersCount()==0 )
    {
    int result=0;
    if((iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,1)<iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,1))&&(iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,0)>iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,0))) // Here is your open buy rule { result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
    if(result>0)
    {
    TheStopLoss=0;
    TheTakeProfit=0;
    if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
    if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
    OrderSelect(result,SELECT_BY_TICKET);
    OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
    }
    return(0);
    }
    if((iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,1)>iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,1))&&(iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,0)<iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,0))) // Here is your open Sell rule
    {
    result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippag e,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
    if(result>0)
    {
    TheStopLoss=0;
    TheTakeProfit=0;
    if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
    if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
    OrderSelect(result,SELECT_BY_TICKET);
    OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
    }
    return(0);
    }
    }

    for(int cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()<=OP_SELL &&
    OrderSymbol()==Symbol() &&
    OrderMagicNumber()==MagicNumber
    )
    {
    if(OrderType()==OP_BUY)
    {
    if((iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,0)<iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,0))) //here is your close buy rule
    {
    OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),Slippage,Red);
    }
    if(TrailingStop>0)
    {
    if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
    {
    if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
    return(0);
    }
    }
    }
    }
    else
    {
    if((iMA(NULL,0,3,0,MODE_EMA,PRICE_OPEN,0)>iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,0))) // here is your close sell rule
    {
    OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),Slippage,Red);
    }
    if(TrailingStop>0)
    {
    if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
    {
    if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyP oint*TrailingStop,OrderTakeProfit(),0,Red);
    return(0);
    }
    }
    }
    }
    }
    }
    return(0);
    }

    int TotalOrdersCount()
    {
    int result=0;
    for(int i=0;i<OrdersTotal();i++)
    {
    OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
    if (OrderMagicNumber()==MagicNumber) result++;

    }
    return (result);
    hola compi creo que ahora te entendi lo que kerias , tu quieres que cuando el precio llegue a mas de 10 pip se inicie pero con un trailing de 5 para ello entonces creamos una variable nueva por ejemplo iniciotrailing=10 y luego nos vamos a las lineas donde se inicia el trailing y las modificas


    if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) por
    if(Bid-OrderOpenPrice()>MyPoint*iniciotrailing)

    if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) por
    if((OrderOpenPrice()-Ask)>(MyPoint*iniciotrailing))

    saludos
    Foro de Forex Trading United

  5. #4




    Reputación:
    Poder de reputación: 8

    Espana
    Mensajes: 5
    Créditos: 286

    Re: Expert Advisor que abra 1 sola operación por vela

    Muchísimas gracias Tivag, voy a probarlos.
    Foro de Forex Trading United

  6. #5




    Reputación:
    Poder de reputación: 7

    Espana
    Mensajes: 16
    Créditos: 388

    Re: Expert Advisor que abra 1 sola operación por vela

    Entiendo que:

    en la definición de variables esto
    double profit=0;
    int historico= OrdersHistoryTotal();
    for (int i=0;i<historico;i++)


    y luego seguido del expert start function

    {
    if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
    profit += OrderProfit();
    }

    if (profit>ganancia)
    {
    stop=true;
    }
    else
    stop=false;




    Cita Iniciado por naccant Ver mensaje
    Aquí dejo el scrip de lo que estoy trabajando, no va mal pero necesita depuraciones; a ver donde debo meter los comandos indicados.

    extern int MagicNumber=10033;
    extern double Lots =0.2;
    extern double StopLoss=25;
    extern double TakeProfit=50;
    extern int TrailingStop=1;
    extern int InicioTrailing=5;
    extern int Slippage=3;
    //+------------------------------------------------------------------+
    // expert start function
    //+------------------------------------------------------------------+
    int start()
    {
    double MyPoint=Point;
    if(Digits==3 || Digits==5) MyPoint=Point*10;

    double TheStopLoss=0;
    double TheTakeProfit=0;
    if( TotalOrdersCount()==0 )
    {
    int result=0;
    if((Ask>iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0))&&
    (Bid<iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0))&&
    (iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1)>iMA(NULL, 0,120,0,MODE_SMA,PRICE_CLOSE,1))&&
    (Close[1]<iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1))||
    (iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1)<iMA(NULL, 0,120,0,MODE_SMA,PRICE_CLOSE,1))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0)>iMA(NULL,0, 120,0,MODE_SMA,PRICE_CLOSE,0))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,1)<iMA(NULL,0, 120,0,MODE_SMA,PRICE_CLOSE,1))&&
    (iMACD(NULL,0,3,5,2,PRICE_CLOSE,MODE_MAIN,1)>0)&&
    (Ask>iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0))&&
    (Bid<iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0))||
    (iRSI(NULL,0,11,PRICE_OPEN,1)<40)&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)>40)&&
    (iRSI(NULL,0,11,PRICE_OPEN,1)>(iRSI(NULL,0,11,PRIC E_OPEN,2)))&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)>(iRSI(NULL,0,11,PRIC E_OPEN,1)))&&
    (Ask>iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,0))&&
    (Bid<iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,0))||
    (iRSI(NULL,0,11,PRICE_OPEN,1)<30)&&
    (iRSI(NULL,0,11,PRICE_OPEN,1)>(iRSI(NULL,0,11,PRIC E_OPEN,2)))&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)>(iRSI(NULL,0,11,PRIC E_OPEN,1)))||
    (iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,0)>iMA(NULL,0, 50,0,MODE_EMA,PRICE_CLOSE,0))&&
    (Ask>iMA(NULL,0,20,0,MODE_SMA,PRICE_HIGH,0))&&
    (Bid<iMA(NULL,0,20,0,MODE_SMA,PRICE_HIGH,0))||
    (iRSI(NULL,0,11,PRICE_OPEN,0)<50)&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)>(iRSI(NULL,0,11,PRIC E_OPEN,1)))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0)>iMA(NULL,0, 20,0,MODE_EMA,PRICE_HIGH,0))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0)>iMA(NULL,0, 5,0,MODE_EMA,PRICE_HIGH,1))||
    (Close[3]<iMA(NULL,0,20,0,MODE_SMA,PRICE_HIGH,3))&&
    (Close[2]<iMA(NULL,0,20,0,MODE_SMA,PRICE_HIGH,2))&&
    (Close[1]>iMA(NULL,0,20,0,MODE_SMA,PRICE_HIGH,1))&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)>(iRSI(NULL,0,11,PRIC E_OPEN,1))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0)>iMA(NULL,0, 5,0,MODE_SMA,PRICE_HIGH,1))))

    // Here is your open buy rule
    {
    result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Blue);
    if(result>0)
    {
    TheStopLoss=0;
    TheTakeProfit=0;
    if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
    if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
    OrderSelect(result,SELECT_BY_TICKET);
    OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
    }
    return(0);
    }
    if((Ask>iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0))&&
    (Bid<iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0))&&
    (iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1)<iMA(NULL, 0,120,0,MODE_SMA,PRICE_CLOSE,1))&&
    (Close[1]>iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1))||
    (iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1)>iMA(NULL, 0,120,0,MODE_SMA,PRICE_CLOSE,1))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_LOW,0)<iMA(NULL,0,1 20,0,MODE_SMA,PRICE_CLOSE,0))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_LOW,1)>iMA(NULL,0,1 20,0,MODE_SMA,PRICE_CLOSE,1))&&
    (iMACD(NULL,0,3,5,2,PRICE_CLOSE,MODE_MAIN,1)<0)&&
    (Ask>iMA(NULL,0,5,0,MODE_SMA,PRICE_LOW,0))&&
    (Bid<iMA(NULL,0,5,0,MODE_SMA,PRICE_LOW,0))||
    (iRSI(NULL,0,11,PRICE_OPEN,1)>60)&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)<60)&&
    (iRSI(NULL,0,11,PRICE_OPEN,1)<(iRSI(NULL,0,11,PRIC E_OPEN,2)))&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)<(iRSI(NULL,0,11,PRIC E_OPEN,1)))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_LOW,0)<iMA(NULL,0,2 0,0,MODE_SMA,PRICE_HIGH,0))&&
    (Ask>iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,0))&&
    (Bid<iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,0))||
    (iRSI(NULL,0,11,PRICE_OPEN,1)>70)&&
    (iRSI(NULL,0,11,PRICE_OPEN,1)<(iRSI(NULL,0,11,PRIC E_OPEN,2)))&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)<(iRSI(NULL,0,11,PRIC E_OPEN,1)))||
    (iMA(NULL,0,20,0,MODE_SMA,PRICE_HIGH,0)<iMA(NULL,0 ,50,0,MODE_EMA,PRICE_CLOSE,0))&&
    (Ask>iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,0))&&
    (Bid<iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,0))||
    (iRSI(NULL,0,11,PRICE_OPEN,0)>50)&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)<(iRSI(NULL,0,11,PRIC E_OPEN,1)))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0)<iMA(NULL,0, 20,0,MODE_EMA,PRICE_LOW,0))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0)<iMA(NULL,0, 5,0,MODE_EMA,PRICE_HIGH,1))||
    (Close[3]>iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,3))&&
    (Close[2]>iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,2))&&
    (Close[1]<iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,1))&&
    (iRSI(NULL,0,11,PRICE_OPEN,0)<(iRSI(NULL,0,11,PRIC E_OPEN,1)))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,0)<iMA(NULL,0, 5,0,MODE_SMA,PRICE_HIGH,1)))

    // Here is your open Sell rule
    {
    result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippag e,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
    if(result>0)
    {
    TheStopLoss=0;
    TheTakeProfit=0;
    if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
    if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
    OrderSelect(result,SELECT_BY_TICKET);
    OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
    }
    return(0);
    }
    }

    for(int cnt=0;cnt<OrdersTotal();cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()<=OP_SELL &&
    OrderSymbol()==Symbol() &&
    OrderMagicNumber()==MagicNumber
    )
    {
    if(OrderType()==OP_BUY)
    {
    if((iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1)<iMA(NU LL,0,50,0,MODE_SMA,PRICE_CLOSE,1))&&
    (iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,2)>iMA(NULL, 0,50,0,MODE_SMA,PRICE_CLOSE,2))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_HIGH,1)<iMA(NULL,0, 120,0,MODE_SMA,PRICE_CLOSE,1)))
    //here is your close buy rule
    {
    OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),Slippage,Red);
    }
    if(TrailingStop>0)
    {
    if(Bid-OrderOpenPrice()>MyPoint*InicioTrailing)
    {
    if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
    return(0);
    }
    }
    }
    }
    else
    {
    if((iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,1)>iMA(NU LL,0,50,0,MODE_SMA,PRICE_CLOSE,1))&&
    (iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,2)<iMA(NULL, 0,50,0,MODE_SMA,PRICE_CLOSE,2))&&
    (iMA(NULL,0,5,0,MODE_SMA,PRICE_LOW,1)>iMA(NULL,0,1 20,0,MODE_SMA,PRICE_CLOSE,1)))// here is your close sell rule
    {
    OrderClose(OrderTicket(),OrderLots(),OrderClosePri ce(),Slippage,Red);
    }
    if(TrailingStop>0)
    {
    if((OrderOpenPrice()-Ask)>(MyPoint*InicioTrailing))
    {
    if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyP oint*TrailingStop,OrderTakeProfit(),0,Red);
    return(0);
    }
    }
    }
    }
    }
    }
    return(0);
    }


    int TotalOrdersCount()
    {
    int result=0;
    for(int i=0;i<OrdersTotal();i++)
    {
    OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
    if (OrderMagicNumber()==MagicNumber) result++;


    }
    return (result);
    }
    Foro de Forex Trading United

  7. #6




    Reputación:
    Poder de reputación: 7

    Espana
    Mensajes: 16
    Créditos: 388

    Re: Expert Advisor que abra 1 sola operación por vela

    Buenas, es lo que yo indicaba en la duda, me pasa igual puede ser que se me cierre la orden y dentro de la misma vela se vuela a abrir otra. Mi intención era que hiciese una sola operación y no abrir ninguna más independietemente de que se cerrase la primera dentro de la primera vela.

    Por ahora estoy utiliando el cruce del ask y el bid (que se dá en un momento concreto) en ve de el cruce de medias (que se da durante toda la vela).







    Cita Iniciado por CICLIC_VA Ver mensaje
    Expert Advisor que abra 1 sola operación por vela-20180726_222317_2_resized.jpg
    Adjunto la imagen de lo que me ocurre muchas veces...
    Foro de Forex Trading United

  8. #7
    Avatar de tivag
    antecessor


    Reputación:
    Poder de reputación: 17

    Espana
    Mensajes: 659
    Créditos: 5.114

    Re: Expert Advisor que abra 1 sola operación por vela

    Cita Iniciado por naccant Ver mensaje
    Buenas, disculpa mi poco conocimiento en programación, voy aprendiendo por pasos. Me indica estos fallos, adjunto imagen.
    Archivo adjunto 59533
    hola tranquilo , es normal si estas empezando , cuando puse orden buy o sell (); hacia referencia a tu parte de codigo para que supieras que podria ir hay, esa linea quitala, tal y como se ve en la imagen parece que esta al principio del todo luego todo el ea te ira vela a vela , lo puedes hacer asi o bien poner eso antes de donde se lanza la orden de compra o venta y asi solo se hara cada vela solo la orden , cuestion de como lo quieras.

    saludos
    Foro de Forex Trading United

  9. #8




    Reputación:
    Poder de reputación: 7

    Espana
    Mensajes: 16
    Créditos: 388

    Re: Expert Advisor que abra 1 sola operación por vela

    Cita Iniciado por tivag Ver mensaje
    hola compi creo que ahora te entendi lo que kerias , tu quieres que cuando el precio llegue a mas de 10 pip se inicie pero con un trailing de 5 para ello entonces creamos una variable nueva por ejemplo iniciotrailing=10 y luego nos vamos a las lineas donde se inicia el trailing y las modificas


    if(Bid-OrderOpenPrice()>MyPoint*TrailingStop) por
    if(Bid-OrderOpenPrice()>MyPoint*iniciotrailing)

    if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop)) por
    if((OrderOpenPrice()-Ask)>(MyPoint*iniciotrailing))

    saludos
    Muchísimas gracias, me pongo a ello a ver si me funciona.

    Un saludo
    Foro de Forex Trading United

  10. #9




    Reputación:
    Poder de reputación: 7

    Espana
    Mensajes: 16
    Créditos: 388

    Expert Advisor que abra 1 sola operación por vela

    Buenas,

    Soy nuevo en este foro y en este mundillo, ando creando EA´s y aprendiendo cosas nuevas, pero lo que no consigo controlar es como hacer que solo haga 1 operación por vela, ya que las condiciones que pongo dan lugar a que se abran nuevas una vez cerradas las anteriores operaciones.

    y por otra parte si es posible que el Trailing Stop, no empiece en 0, sino en un pip definido. Me explico indico que el trailing stop se active a 5 pips, pero desde el momento en que el precio esté a 10 pisp de la apertura.

    Un saludo
    Foro de Forex Trading United

  11. #10
    Avatar de tivag
    antecessor


    Reputación:
    Poder de reputación: 17

    Espana
    Mensajes: 659
    Créditos: 5.114

    Re: Expert Advisor que abra 1 sola operación por vela


    Publi
    Cita Iniciado por naccant Ver mensaje
    Buenas de nuevo.

    Con las ayudas que me has proporcionado he ido testando la EA durante varias semanas y a su vez depurando cosillas para que no me pierda más que gane.

    Ahora he visto que necesitaría poner la condición de que la EA no trabaje más si alcanza una valor determinado de ganancia. Como puedo proceder?

    Muchas gracias por todo
    Para ello se debe contabilizar el beneficio obtenido , se guarda en una variable y cuando esa variable sea mayor que tu objetivo ponemos una variable de tipo bool a true , esa variable la introduces en donde se manda las ordenes cuando sea false y asi solo se ejecutara cuando el beneficio sea inferior a lo esperado.



    double profit=0;
    int historico= OrdersHistoryTotal();
    for (int i=0;i<historico;i++)

    {
    if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
    profit += OrderProfit();
    }

    if (profit>ganancia)
    {
    stop=true;
    }
    else
    stop=false;
    Foro de Forex Trading United

Página 1 de 3 123 ÚltimoÚltimo
This website uses cookies
Utilizamos cookies propias y de terceros para elaborar información estadística y mostrarle publicidad personalizada a través del análisis de su navegación. Si continúa navegando acepta su uso. Más información y política de cookies.
     

 

Publi


Aviso Legal
Ley Orgánica 15/1999, de 13 de diciembre, de Protección de Datos de Carácter Personal