Bonjour,
J'essaie de créer des EA via des constructeurs gratuits qui sont sur le Web.
J'ai un problème, parfois sur la seule bougie il y a plus d'entrées. J'ai cherché le code, j'ai trouvé du matériel différent, mais je n'arrive pas à le faire fonctionner. Voici le code d'un simple EA sur la croix de deux moyennes mobiles, vous pouvez indiquer les fonctions appropriées et où les placer, de sorte qu'il n'y ait qu'une seule entrée sur une bougie.
Merci d'avance
extern entier MagicNumber=10001 ;
Lots doubles externes =0,1 ;
externe double StopLoss=5 ;
double externe TakeProfit=10 ;
extern int TrailingStop=0 ;
extern int Glissement=3 ;
extern int ma_fast_period=13 ;
extern int ma_slow_period=89;
décalage entier externe=0 ;
// ------------------------------------------------------------ -------------------
//fonction de démarrage expert
// ------------------------------------------------------------ -------------------
int start()
{
double MonPoint=Point ;
if(Chiffres==3 || Chiffres==5) MonPoint=Point*10 ;
double TheStopLoss=0 ;
double TheTakeProfit=0 ;
if( TotalOrdersCount()==0 )
{
entier résultat=0 ;
if((iMA(NULL,0,ma_fast_period,shift,MODE_SMA,PRICE _CLOSE,1)lt;iMA(NULL,0,ma_slow_period,shift,MODE_S MA,PRICE_CLOSE,1))(iMA(NULL,0,ma_fast_period,shift ,MODE_SMA ,PRICE_CLOSE,0)gt;iMA(NULL,0,ma_slow_period,shift, MODE_SMA,PRICE_CLOSE,0)))/Voici votre règle d'achat ouvert
{
result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage ,0,0,comment
http://www.ForexEAdvisor.comquot;,MagicNumber,0,Blue);
si(résultatgt;0)
{
TheStopLoss=0 ;
TheTakeProfit=0 ;
if(TakeProfitgt;0) TheTakeProfit=Ask TakeProfit*MyPoint ;
if(StopLossgt;0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(résultat,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
}
retour(0);
}
if((iMA(NULL,0,ma_fast_period,shift,MODE_SMA,PRICE _CLOSE,1)gt;iMA(NULL,0,ma_slow_period,shift,MODE_S MA,PRICE_CLOSE,1))(iMA(NULL,0,ma_fast_period,shift ,MODE_SMA ,PRICE_CLOSE,0)lt;iMA(NULL,0,ma_slow_period,shift, MODE_SMA,PRICE_CLOSE,0)))/Voici votre règle de vente ouverte
{
result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippag e,0,0,comment,MagicNumber,0,Red);
si(résultatgt;0)
{
TheStopLoss=0 ;
TheTakeProfit=0 ;
if(TakeProfitgt;0) TheTakeProfit=Bid-TakeProfit*MyPoint ;
if(StopLossgt;0) TheStopLoss=Bid StopLoss*MyPoint ;
OrderSelect(résultat,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(TheStopLoss,Digits),NormalizeDouble(TheTa keProfit,Digits),0,Green);
}
retour(0);
}
}
for(int cnt=0;cntlt;TotalCommandes();cnt )
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()lt;=OP_SELL
OrderSymbol()==Symbole()
OrderMagicNumber()==MagicNumber
)
{
si(TypeCommande()==OP_BUY)
{
if(TrailingStopgt;0)
{
if(Bid-OrderOpenPrice()gt;MyPoint*TrailingStop)
{
if(OrderStopLoss()lt;Bid-MyPoint*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
retour(0);
}
}
}
}
autre
{
if(TrailingStopgt;0)
{
if((OrderOpenPrice()-Ask)gt;(MyPoint*TrailingStop))
{
if((OrderStopLoss()gt;(Ask MyPoint*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
retour(0);
}
}
}
}
}
}
retour(0);
}
int TotalOrdersCount()
{
entier résultat=0 ;
for(int i=0;ilt;TotalCommandes();i )
{
OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
if (OrderMagicNumber()==MagicNumber) résultat ;
}
retour (résultat);
}