Para iniciar sesión y usar el sitio web MQL5.com es necesario permitir el uso de Сookies.
Por favor, active este ajuste en su navegador, de lo contrario, no podrá iniciar sesión.
Ha iniciado sesión. La autenticación de dos factores se ha desactivado. Vuelva a configurarla y escanee un nuevo código QR, o continúe con la autenticación de dos factores desactivada.
Había un fallo en el bloque de cierre de pedidos, lo he arreglado.
¿Pueden decirme por qué no se abren los pedidos? Da un error 130
input double Urov_70=70;
input double Urov_30=30;
input double Lot=0.01;
input int TakeProfit=100;
input int StopLoss=100;
input int MagicNumber=523;
input int slippage=30;
double tp=0,sl=0,OrderBuy=0,OrderSell=0;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
tp=NormalizeDouble(TakeProfit*_Point,_Digits);
sl=NormalizeDouble(StopLoss*_Point,_Digits);
return(INIT_SUCCEEDED);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY){}
if(OrderType()==OP_SELL){}
}
}
double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+
if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
{
tiket= OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
}
if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
}
}
//+------------------------------------------------------------------+
No soy un profesional, ¡podría estar equivocado!
estas líneas
tp=NormalizeDouble(TakeProfit*_Point,_Digits);sl=NormalizarDoble(PérdidaDetención*Punto,_Dígitos);
Lo entenderás mejor si lo pones así
tp=NormalizeDouble(Ask+ TakeProfit*_Point,_Digits);sl=NormalizarDoble(Oferta- StopLoss*_Punto,_Dígitos);
Además, no es necesario poner a cero las variables globales tp y sl.
¿Pueden decirme por qué no se abren los pedidos? Error 130.
...
El error 130 es una parada cercana. Compruebe la distancia mínima de ajuste de la parada - StopLevel
Y, sí, ya se ha señalado más arriba: los está calculando incorrectamente.
Lo hice - nada ha cambiado (
Sí, acaba de anunciarlo.
input double Urov_70=70;
input double Urov_30=30;
input double Lot=0.01;
input int TakeProfit=100;
input int StopLoss=100;
input int MagicNumber=523;
input int slippage=30;
double tp=0,sl=0,OrderBuy=0,OrderSell=0;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY){}
if(OrderType()==OP_SELL){}
}
}
double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+
double StopLossLevel;
double TakeProfitLevel;
if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;
///---
if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
{
tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
}
if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
}
}
//+------------------------------------------------------------------+
Lo hice - nada ha cambiado (
input double Urov_70=70;
input double Urov_30=30;
input double Lot=0.01;
input int TakeProfit=100;
input int StopLoss=100;
input int MagicNumber=523;
input int slippage=30;
double tp=0,sl=0,OrderBuy=0,OrderSell=0;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY){}
if(OrderType()==OP_SELL){}
}
}
double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+
double StopLossLevel;
double TakeProfitLevel;
if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;
///---
if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
{
tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
}
if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
}
}
//+------------------------------------------------------------------+
Trasladar el cálculo de los topes al ontic
sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);
..
tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);
Esta es la variante de OP_BUY
para OP_SELL
tp=NormalizarDoble(Oferta-TomaBeneficio*_Punto,_Dígitos);
sl=NormalizarDoble(Ask+StopLoss*_Point,_Digits);Error 148. En cada tic se abre.
input double Urov_70=70;
input double Urov_30=30;
input double Lot=0.01;
input int TakeProfit=100;
input int StopLoss=100;
input int MagicNumber=523;
input int slippage=30;
double tp,sl,OrderBuy=0,OrderSell=0;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY){}
if(OrderType()==OP_SELL){}
}
}
double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+
double StopLossLevel;
double TakeProfitLevel;
if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;
tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);
tp=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);
sl=NormalizeDouble(Ask+StopLoss*_Point,_Digits);
///---
if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
{
tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
}
if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
}
}
//+------------------------------------------------------------------+
dos valores diferentes de sl tp
Llámalos de forma diferente: slSell , slBuy, tpSell, tpBuy
dos valores diferentes de sl tp
Llámalos de forma diferente: slSell , slBuy, tpSell, tpBuy
No ayudó (
double slSell,slBuy,tpSell,tpBuy;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY){}
if(OrderType()==OP_SELL){}
}
}
double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+
double StopLossLevel;
double TakeProfitLevel;
if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;
tpBuy=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
slBuy=NormalizeDouble(Bid-StopLoss*_Point,_Digits);
tpSell=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);
slSell=NormalizeDouble(Ask+StopLoss*_Point,_Digits);
///---
if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
{
tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
}
if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
}
}
//+------------------------------------------------------------------+