Si vous n'avez pas de compte, veuillez vous inscrire
Autorisez l'utilisation de cookies pour vous connecter au site Web MQL5.com.
Veuillez activer les paramètres nécessaires dans votre navigateur, sinon vous ne pourrez pas vous connecter.
Vous êtes connecté. L'authentification à deux facteurs a été désactivée. Configurez-la à nouveau et scannez un nouveau code QR, ou continuez avec l'authentification à deux facteurs désactivée.
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);
}
mais il faut
if(OrderBuy<1&& rsi>Urov_70 && rsi1<Urov_70)
{
tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,slBuy,tpBuy,NULL,MagicNumber,0,clrBlue);
}
if(OrderSell<1&& rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,slSell,tpSell,NULL,MagicNumber,0,clrRed);
}
Cela n'a pas aidé (
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);
}
}
//+------------------------------------------------------------------+
Qu'est-ce que tu veux avec un code comme ça ?
Quoi, et qu'est-ce qui n'a pas marché ?
if(OrderBuy<1&& rsi>Urov_70 && rsi1<Urov_70)
{
tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,sl,sl,tp,NULL,MagicNumber,0,clrBlue)
}
si(OrderSell<1&& rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,sl,sl,tp,NULL,MagicNumber,0,clrRed) ;
}
mais il faut
if(OrderBuy<1&& rsi>Urov_70 && rsi1<Urov_70)
{
tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,slBuy,tpBuy,NULL,MagicNumber,0,clrBlue);
}
si(OrderSell<1&& rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,slSell,tpSell,NULL,MagicNumber,0,clrRed) ;
}
A chaque tic s'ouvre (
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,slBuy,tpBuy,NULL,MagicNumber,0,clrBlue);
}
if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,slSell,tpSell,NULL,MagicNumber,0,clrRed);
}
}
//+------------------------------------------------------------------+
Que voulez-vous avec ce code de toute façon ?
Quoi, et qu'est-ce qui n'a pas fonctionné là-bas ?
Quel est le problème avec le code ?
Il ne faut pas qu'il s'ouvre à chaque tic.
Quel est le problème avec le code ?
Ce n'est pas comme ça que ça marche.
Pourquoi rechercher la boucle de position si elle ne fait rien et ne renvoie rien comme résultat ?
Pourquoi vérifier les variables avec des valeurs nulles pour moins de un et s'attendre à ce qu'il ne s'ouvre pas à chaque tick?
Il y a beaucoup d'absurdités pour être honnête...
J'ai le même problème, dans le testeur il s'ouvre à chaque tic alors qu'il ne devrait pas le faire.
J'ai mis une béquille pour que le nombre minimum de commandes fonctionne mais c'est un patch, rien de plus
J'ai le même problème, dans le testeur il s'ouvre à chaque tic alors qu'il ne devrait pas le faire.
J'ai mis une béquille pour que le nombre minimum de commandes fonctionne mais c'est un patch, rien de plus
C'est tout faux.
Pourquoi rechercher la boucle de position si elle ne fait rien et ne renvoie rien comme résultat ?
Pourquoi vérifier les variables avec des valeurs nulles pour moins de un et s'attendre à ce qu'il ne s'ouvre pas à chaque tick?
Et il y a beaucoup d'absurdités pour être honnête...
Réparez-la de la bonne façon.
Si je l'avais fait, je l'aurais fait.
Si vous comptez correctement le nombre de positions ouvertes, vous n'avez pas besoin de béquilles.
Ils ne devraient pas être limités de quelque manière que ce soit.
En résumé, la condition est la suivante
void OnTick()
{
if(OrdersTotal()==0) //+-------------если количество ордеров равно 0{
if((MathAbs(ma2-ma4)>100*_Point)
&& (MathAbs(Bid-ma3)>100*Point())
&& (ma31>ma32>ma33)) //+-----покупка по 6+50
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,50,0,0,"",Magic,0,clrAzure);//+------отправка 1 ордера
}
if((Bid+1000*Point)>ma3 && (Bid>ma1) && (Bid>ma2))//+-------------условие продажи
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,50,0,0,"",Magic,0,clrAzure);//+-----отправка 1 ордера
}
if(ticket==0)
{
return;
}
}
//+---------------------------------------------------------если уже есть
if(FindLastOType()==OP_BUY)
{
if(Ask<=FindLastOrderOpenPrice()-Step*Point())//+------------если ордер в минус
{
ticket=OrderSend(Symbol(),OP_BUY,(FindLastLot()*Martin),Ask,50,0,0,"",Magic,0,clrAzure);
}
else
if(Ask>=FindLastOrderOpenPrice()+Step*Point())//+------------если ордер в плюс
{
ticket=OrderSend(Symbol(),OP_BUY,(FindLastLot()*Martin),Ask,50,0,0,"",Magic,0,clrAzure);
}
}
if(FindLastOType()==OP_SELL)
{
if(Bid>=FindLastOrderOpenPrice()+Step*Point())//+------------если ордер в минус
{
ticket=OrderSend(Symbol(),OP_SELL,(FindLastLot()*Martin),Bid,50,0,0,"",Magic,0,clrLightGray);
}
else
if(Bid<=FindLastOrderOpenPrice()-Step*Point()) //+------------если ордер в плюс
{
ticket=OrderSend(Symbol(),OP_SELL,(FindLastLot()*Martin),Bid,50,0,0,"",Magic,0,clrLightGray);
}
}
Trailingall();
}
J'ai fait ça, maintenant il ne s'ouvre pas à chaque tick, mais laisse les signaux entrer...
double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell;
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=OrdersTotal()-1; i>=0; i--) //Цикл по всем ордерам
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) //Выбрали ордер
{
if(OrderType()==OP_BUY)
{
TotalBiu++; //Кол. покупок
}
if(OrderType()==OP_SELL)
{
TotalSell++; //Кол. продаж
}
}
}
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(TotalBiu==0)
if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
{
tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,slBuy,tpBuy,NULL,MagicNumber,0,clrBlue);
}
if(TotalSell==0)
if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
{
tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,slSell,tpSell,NULL,MagicNumber,0,clrRed);
}
}
//+------------------------------------------------------------------+