Ayuda a la codificación - página 104

 

Muchas gracias Mladen .... Eres genial ...

 

Hola chicos,

¿alguna ayuda con mi solicitud en la página 103, por favor? He buscado información en internet pero no he conseguido que salte la alerta de cada 5 bares (a partir de la hora)

Gracias de antemano

 

Estimado Mladen / Sr. Herramientas ¿Puede u por favor arreglar este ea para que no reabrir el comercio una vez que la parada o tp es golpeado..

Archivos adjuntos:
 

Ayuda para codificar el stop loss

Hola chicos,

Tengo este EA que parece que no puedo cambiar el Stop Loss en él.

No importa lo que cambie, no cambiará. Me gustaría cambiar el stop loss a por lo menos 300. ¿Alguna idea?

Gracias de antemano

este es el código para ello:

// entrada genérica del usuario

extern double Lotes=1.0;

extern int TakeProfit=44;

extern int StopLoss=90;

extern bool RSIMethodA=false;

extern bool RSIMethodB=true;

extern int RSIValue=50;

extern bool AbandonMethodA=true;

extern bool AbandonMethodB=false;

extern int Abandon=101;

extern bool MoneyManagement=true;

extern int Risk=2;

extern int Slippage=3;

extern bool UseProfitLock=true;

extern int BreakEvenTrigger=25;

extern int BreakEven=3;

extern bool LiveTrading=false;

extern bool AccountIsMini=false;

extern int maxTradesPerPair=1;

extern int MagicNumber=5432;

double lotMM;

bool BuySignal=false;

bool SetBuy=false;

bool SellSignal=false;

bool SetSell=false;

// Manejo de la barra

datetime bartime=0;

int bartick=0;

int TradeBars=0;

//+------------------------------------------------------------------+

//| función de inicialización del experto ||

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| función de desinicialización experta ||

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| función de inicio experto ||

//+------------------------------------------------------------------+

int inicio()

{

//----

si (UseProfitLock) ProfitLockStop();

si (AbandonarMétodoA | AbandonarMétodoB)

{

RunAbandonCheck();

RunAbandonMethods();

}

if (!SetLotsMM()) return(0);

RunOrderTriggerCalculations();

RunPairSpesificSettings();

RunNewOrderManagement();

//----

return(0);

}

/////////////////////////////////////////////////

// SetLotsMM - Por Robert Cochran http://autoforex.biz

/////////////////////////////////////////////////

bool SetLotsMM()

{

double MarginCutoff;

if(!AccountIsMini) MarginCutoff = 1000;

if( AccountIsMini) MarginCutoff = 100;

if(AccountFreeMargin() < MarginCutoff) return(false);

if(MoneyManagement)

{

lotMM = MathCeil(AccountBalance() * Risk / 10000) / 10;

if(lotMM < 0.1) lotMM = Lots;

if(lotMM > 1.0) lotMM = MathCeil(lotMM);

// Aplicar los límites del tamaño del lote

if(LiveTrading)

{

if( AccountIsMini) lotMM = lotMM * 10;

if(!AccountIsMini && lotMM < 1.0) lotMM = 1.0;

}

if(lotMM > 100) lotMM = 100;

}

si no

{

lotMM = Lots; // Cambie MoneyManagement a 0 si quiere que el parámetro Lots tenga efecto

}

return(true);

}

//+------------------------------------------------------------------+

/////////////////////////////////////////////////

// RunOrderTriggerCalculations

/////////////////////////////////////////////////

bool RunOrderTriggerCalculations()

{

bool RSIPOS=false

bool RSINEG=false;

// Media móvil de 3 periodos en la Barra[1]

double bullMA3=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,1);

// Media móvil de 7 periodos en la Barra[1]

double bearMA7=iMA(Symbol(),0,7,0,MODE_EMA,PRICE_CLOSE,1);

// Media móvil de 2 periodos en la barra[2]

double RSI=iRSI(Symbol(),0,2,PRICE_CLOSE,2);

double RSI2=iRSI(Symbol(),0,2,PRICE_CLOSE,1);

// Determina en qué polaridad está el RSI

si (RSIMethodA)

{

if(RSI>RSIValue && RSI2<RSIValue)

{

RSIPOS=true;

RSINEG=false;

}

Si no, RSIPOS=false;

if(RSIRSIValue)

{

RSIPOS=false;

RSINEG=true;

}

Si no, RSINEG=false;

}

if (RSIMethodB)

{

if(RSI>RSIValue)

{

RSIPOS=true;

RSINEG=falso;

}

if(RSI<RSIValue)

{

RSIPOS=falso;

RSINEG=true;

}

}

if ((bullMA3 > (bearMA7+Point)) && RSINEG)

{

BuySignal=true;

}

Si no, BuySignal=false;

if ((bullMA3 < (bearMA7-Point)) && RSIPOS)

{

SellSignal=true;

}

de lo contrario SellSignal=false;

return(true);

}

/////////////////////////////////////////////////

// OpenOrdersBySymbolAndComment

/////////////////////////////////////////////////

int AbrirPedidosParaEstaEA()

{

int ofts=0;

for(int x=0;x<TotalPedidos();x++)

{

OrderSelect(x, SELECT_BY_POS, MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)

{

ofts++;

}

}

return(ofts);

}

/////////////////////////////////////////////////

// PROFIT LOCK - Por Robert Cochran - http://autoforex.biz

/////////////////////////////////////////////////

bool ProfitLockStop()

{

if( OpenOrdersForThisEA() > 0 )

{

for ( int i = 0; i < OrdersTotal(); i++){

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

//--- OPERACIONES LARGAS

if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber()== MagicNumber)

{

if (Bid >= OrderOpenPrice() + BreakEvenTrigger*Point &&

OrderOpenPrice() > OrderStopLoss())

{

OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + BreakEven * Point, OrderTakeProfit(), Green);

}

}

//--- OPERACIONES CORTAS

if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==MagicNumber)

{

if (Ask <= OrderOpenPrice() - BreakEvenTrigger*Point &&

OrderOpenPrice() < OrderStopLoss())

{

OrderModify(OrderTicket(), OrderOpenPrice(),OrderOpenPrice() - BreakEven * Point, OrderTakeProfit(), Blue);

}

}

}

}

}

/////////////////////////////////////////////////

// ABANDONAR EL CONTROL

/////////////////////////////////////////////////

bool EjecutarComprobaciónDeAbandono()

{

if( OpenOrdersForThisEA() > 0 )

{

if (TradeBars == 0 && bartick == 0)

{

for (int i = 0; i < OrdersTotal(); i++)

{

if (OrderSymbol() == Symbol())

{

TradeBars = MathFloor(CurTime() - OrderOpenTime())/60/Period();

bartime = Time[0];

bartick = TradeBars;

}

}

}

if(bartime!=Time[0])

{

bartime=Tiempo[0];

bartick++;

}

}

return(true);

}

/////////////////////////////////////////////////

// RunAbandonMethods

/////////////////////////////////////////////////

bool RunAbandonMethods()

{

if( OpenOrdersForThisEA() > 0 )

{

for (int i = 0; i < OrdersTotal(); i++)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (AbandonMethodA && bartick==Abandon)//Forzar "HEDGE" después de abandonar

{

// LONG TRADES

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue);

SetSell=true;

continuar;

}

// OPERACIONES CORTAS

if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue);

SetBuy=true;

continuar;

}

}

if (AbandonMethodB && bartick==Abandon)//Los indicadores deciden la dirección después del abandono

{

// OPERACIONES LARGAS

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);

continuar;

}

// OPERACIONES CORTAS

if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);

continuar;

}

}

}

}

return(true);

}

/////////////////////////////////////////////////

// RunPairSpesificSettings

/////////////////////////////////////////////////

bool RunPairSpesificSettings()

{

// configurar las optimizaciones de los símbolos

if (Symbol()=="GBPUSD")

{

TakeProfit=55; StopLoss=100; Abandono=69;

}

return(true);

}

/////////////////////////////////////////////////

// RunNewOrderManagement

/////////////////////////////////////////////////

bool EjecutarNuevaGestiónDePedidos()

{

double TP,SL;

if( OpenOrdersForThisEA() < maxTradesPerPair )

{

//ENTRY Ask(buy, long)

if (BuySignal || SetBuy)

{

SL = Ask - StopLoss*Punto;

TP = Ask + TakeProfit*Punto;

OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP, "TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);

bartick=0;

if (SetBuy) SetBuy=false;

return(true);

}

//ENTRY Oferta (vender, corto)

if (SellSignal || SetSell)

{

SL = Oferta + StopLoss*Punto;

TP = Oferta - TakeProfit*Punto;

OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,TP, "TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);

bartick=0;

if (SetSell) SetSell=false;

return(true);

}

}

return(true);

}

 
graphics:
Hola chicos,

Tengo este EA que parece que no puedo cambiar el Stop Loss en él.

No importa lo que cambie, no cambiará. Me gustaría cambiar el stop loss a por lo menos 300. ¿Alguna idea?

Gracias de antemano

este es el código para ello:

// entrada genérica del usuario

extern double Lotes=1.0;

extern int TakeProfit=44;

extern int StopLoss=90;

extern bool RSIMethodA=false;

extern bool RSIMethodB=true;

extern int RSIValue=50;

extern bool AbandonMethodA=true;

extern bool AbandonMethodB=false;

extern int Abandon=101;

extern bool MoneyManagement=true;

extern int Risk=2;

extern int Slippage=3;

extern bool UseProfitLock=true;

extern int BreakEvenTrigger=25;

extern int BreakEven=3;

extern bool LiveTrading=false;

extern bool AccountIsMini=false;

extern int maxTradesPerPair=1;

extern int MagicNumber=5432;

double lotMM;

bool BuySignal=false;

bool SetBuy=false;

bool SellSignal=false;

bool SetSell=false;

// Manejo de la barra

datetime bartime=0;

int bartick=0;

int TradeBars=0;

//+------------------------------------------------------------------+

//| función de inicialización del experto ||

//+------------------------------------------------------------------+

int init()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| función de desinicialización experta ||

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| función de inicio experto ||

//+------------------------------------------------------------------+

int inicio()

{

//----

si (UseProfitLock) ProfitLockStop();

si (AbandonarMétodoA | AbandonarMétodoB)

{

RunAbandonCheck();

RunAbandonMethods();

}

if (!SetLotsMM()) return(0);

RunOrderTriggerCalculations();

RunPairSpesificSettings();

RunNewOrderManagement();

//----

return(0);

}

/////////////////////////////////////////////////

// SetLotsMM - Por Robert Cochran Bienvenido autoforex.biz - BlueHost.com

/////////////////////////////////////////////////

bool SetLotsMM()

{

doble MarginCutoff;

if(!AccountIsMini) MarginCutoff = 1000;

if( AccountIsMini) MarginCutoff = 100;

if(AccountFreeMargin() < MarginCutoff) return(false);

if(MoneyManagement)

{

lotMM = MathCeil(AccountBalance() * Risk / 10000) / 10;

if(lotMM < 0.1) lotMM = Lots;

if(lotMM > 1.0) lotMM = MathCeil(lotMM);

// Aplicar los límites del tamaño del lote

if(LiveTrading)

{

if( AccountIsMini) lotMM = lotMM * 10;

if(!AccountIsMini && lotMM < 1.0) lotMM = 1.0;

}

if(lotMM > 100) lotMM = 100;

}

si no

{

lotMM = Lots; // Cambie MoneyManagement a 0 si quiere que el parámetro Lots tenga efecto

}

return(true);

}

//+------------------------------------------------------------------+

/////////////////////////////////////////////////

// RunOrderTriggerCalculations

/////////////////////////////////////////////////

bool RunOrderTriggerCalculations()

{

bool RSIPOS=false

bool RSINEG=false;

// Media móvil de 3 periodos en la Barra[1]

double bullMA3=iMA(Symbol(),0,3,0,MODE_EMA,PRICE_CLOSE,1);

// Media móvil de 7 periodos en la Barra[1]

double bearMA7=iMA(Symbol(),0,7,0,MODE_EMA,PRICE_CLOSE,1);

// Media móvil de 2 periodos en la barra[2]

double RSI=iRSI(Symbol(),0,2,PRICE_CLOSE,2);

double RSI2=iRSI(Symbol(),0,2,PRICE_CLOSE,1);

// Determina en qué polaridad está el RSI

si (RSIMethodA)

{

if(RSI>RSIValue && RSI2<RSIValue)

{

RSIPOS=true;

RSINEG=false;

}

Si no, RSIPOS=false;

if(RSIRSIValue)

{

RSIPOS=false;

RSINEG=true;

}

Si no, RSINEG=false;

}

if (RSIMethodB)

{

if(RSI>RSIValue)

{

RSIPOS=true;

RSINEG=falso;

}

if(RSI<RSIValue)

{

RSIPOS=falso;

RSINEG=true;

}

}

if ((bullMA3 > (bearMA7+Point)) && RSINEG)

{

BuySignal=true;

}

Si no, BuySignal=false;

if ((bullMA3 < (bearMA7-Point)) && RSIPOS)

{

SellSignal=true;

}

de lo contrario SellSignal=false;

return(true);

}

/////////////////////////////////////////////////

// OpenOrdersBySymbolAndComment

/////////////////////////////////////////////////

int AbrirPedidosParaEstaEA()

{

int ofts=0;

for(int x=0;x<TotalPedidos();x++)

{

OrderSelect(x, SELECT_BY_POS, MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)

{

ofts++;

}

}

return(ofts);

}

/////////////////////////////////////////////////

// PROFIT LOCK - Por Robert Cochran - Bienvenido autoforex.biz - BlueHost.com

/////////////////////////////////////////////////

bool ProfitLockStop()

{

if( OpenOrdersForThisEA() > 0 )

{

for ( int i = 0; i < OrdersTotal(); i++){

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

//--- OPERACIONES LARGAS

if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber()== MagicNumber)

{

if (Bid >= OrderOpenPrice() + BreakEvenTrigger*Point &&

OrderOpenPrice() > OrderStopLoss())

{

OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + BreakEven * Point, OrderTakeProfit(), Green);

}

}

//--- OPERACIONES CORTAS

if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==MagicNumber)

{

if (Ask <= OrderOpenPrice() - BreakEvenTrigger*Point &&

OrderOpenPrice() < OrderStopLoss())

{

OrderModify(OrderTicket(), OrderOpenPrice(),OrderOpenPrice() - BreakEven * Point, OrderTakeProfit(), Blue);

}

}

}

}

}

/////////////////////////////////////////////////

// ABANDONAR EL CONTROL

/////////////////////////////////////////////////

bool EjecutarComprobaciónDeAbandono()

{

if( OpenOrdersForThisEA() > 0 )

{

if (TradeBars == 0 && bartick == 0)

{

for (int i = 0; i < OrdersTotal(); i++)

{

if (OrderSymbol() == Symbol())

{

TradeBars = MathFloor(CurTime() - OrderOpenTime())/60/Period();

bartime = Time[0];

bartick = TradeBars;

}

}

}

if(bartime!=Time[0])

{

bartime=Tiempo[0];

bartick++;

}

}

return(true);

}

/////////////////////////////////////////////////

// RunAbandonMethods

/////////////////////////////////////////////////

bool RunAbandonMethods()

{

if( OpenOrdersForThisEA() > 0 )

{

for (int i = 0; i < OrdersTotal(); i++)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (AbandonMethodA && bartick==Abandon)//Forzar "HEDGE" después de abandonar

{

// LONG TRADES

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue);

SetSell=true;

continuar;

}

// OPERACIONES CORTAS

if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue);

SetBuy=true;

continuar;

}

}

if (AbandonMethodB && bartick==Abandon)//Los indicadores deciden la dirección después del abandono

{

// OPERACIONES LARGAS

if (OrderType() == OP_BUY && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,White);

continuar;

}

// OPERACIONES CORTAS

if (OrderType() == OP_SELL && OrderSymbol() == Symbol() &&

OrderMagicNumber()==MagicNumber)

{

OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);

continuar;

}

}

}

}

return(true);

}

/////////////////////////////////////////////////

// RunPairSpesificSettings

/////////////////////////////////////////////////

bool RunPairSpesificSettings()

{

// configurar las optimizaciones de los símbolos

if (Symbol()=="GBPUSD")

{

TakeProfit=55; StopLoss=100; Abandono=69;

}

return(true);

}

/////////////////////////////////////////////////

// RunNewOrderManagement

/////////////////////////////////////////////////

bool EjecutarNuevaGestiónDePedidos()

{

double TP,SL;

if( OpenOrdersForThisEA() < maxTradesPerPair )

{

//ENTRY Ask(buy, long)

if (BuySignal || SetBuy)

{

SL = Ask - StopLoss*Punto;

TP = Ask + TakeProfit*Punto;

OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP, "TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);

bartick=0;

if (SetBuy) SetBuy=false;

return(true);

}

//ENTRY Oferta (vender, corto)

if (SellSignal || SetSell)

{

SL = Oferta + StopLoss*Punto;

TP = Oferta - TakeProfit*Punto;

OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,TP, "TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);

bartick=0;

if (SetSell) SetSell=false;

return(true);

}

}

return(true);

}

Siempre establecerá StopLoss a 100 si el símbolo es GBPUSD

Para otros debería funcionar bien (excepto que deberías multiplicar el stop loss por 10 para brokers de 5 dígitos ya que el EA trabaja con puntos y no con pips)

 

Lo estoy usando en el USD/JPY en este momento y el stop loss se mantiene en 100.

Dónde puedo encontrar el multiplicador de pérdida de la parada?

 
graphics:
Lo estoy usando en el USD/JPY en este momento y el stop loss se mantiene en 100. ¿Dónde puedo encontrar el multiplicador del stop loss?

El stop loss y el take profit se establecen en esta parte :

bool RunNewOrderManagement()

{

double TP,SL;

if( OpenOrdersForThisEA() < maxTradesPerPair )

{

//ENTRY Ask(buy, long)

if (BuySignal || SetBuy)

{

SL = Ask - StopLoss*Point;

TP = Ask + TakeProfit*Point;

OrderSend(Symbol(),OP_BUY,lotMM,Ask,Slippage,SL,TP ,"TS-ProfitLock - "+Symbol()+" - Long",MagicNumber,0,White);

bartick=0;

if (SetBuy) SetBuy=false;

return(true);

}

//ENTRY Bid (sell, short)

if (SellSignal || SetSell)

{

SL = Bid + StopLoss*Point;

TP = Bid - TakeProfit*Point;

OrderSend(Symbol(),OP_SELL,lotMM,Bid,Slippage,SL,T P,"TS-ProfitLock - "+Symbol()+" - Short",MagicNumber,0,Red);

bartick=0;

if (SetSell) SetSell=false;

return(true);

}

}

return(true);

}[/PHP]

As of stop loss that stays 100 : this part of code

[PHP]bool RunPairSpesificSettings()

{

// set up the symbol optimizations

if (Symbol()=="GBPUSD")

{

TakeProfit=55; StopLoss=100; Abandon=69;

}

return(true);

}

se activa sólo si el símbolo es "GBPUSD" (como se ve en el código) por lo que sólo en ese caso se revierte. Revisa tu código de nuevo y busca el 100 y encontrarás lo que pasa con tus stop loss ya que en el código que adjuntas el stop loss se revierte sólo en el caso de GBPUSD

 

Sigue sin cambiar el stop loss, incluso si cambio los pares de divisas a los que estoy operando. Este EA hubiera sido perfecto si el stop loss se pudiera cambiar

Gracias por tratar de ayudar de todos modos.

 

Hola coders,

¿Podría alguien ayudar a modificar este indicador de squeeze break para tener una opción de banda de EMA bollinger así como una opción de canal de EMA keltner?

Gracias :)

Archivos adjuntos:
 
iwillsurvive:
Hola coders,

¿Podría alguien ayudar a modificar este indicador de squeeze break para que tenga una opción de banda de bollinger EMA así como una opción de canal de keltner EMA?

Gracias :)

Hola Iwillsurvive, he modificado el indicador para que tenga la opción de ma tanto en las bandas de keltner como en las de bollinger, por defecto está configurado en EMA.

Archivos adjuntos:
Razón de la queja: