code de vente pour EA
Publié : 30 juin 2012, 15:20
Bonjour à tous,
Je m'initie depuis peut à la programmation sur mt4 et je rencontre un probléme pour placer une vente quand 2 moyennes mobiles se croisent, ça marche à l'achat mais pas à la vente, voici le code que j'ai fait :
if (sell) {
// code de vente ici
sl=Bid + (stopLoss * factor);
sl2=Bid+(takeProfit * factor);
if(GlobalVariableGet("ticket")>0)
{
OrderClose(ticket,1,Ask,1,Red);
ticket = OrderSend(Symbol(),OP_SELL,1,Bid,1,NormalizeDouble(sl, Digits),NormalizeDouble(sl2, Digits),NULL,1234,Blue);
GlobalVariableSet("ticket", ticket);
}
else
{
ticket = OrderSend(Symbol(),OP_SELL,1,Bid,1,NormalizeDouble(sl, Digits),NormalizeDouble(sl2, Digits),NULL,1234,Blue);
GlobalVariableSet("ticket", ticket);
}
Print(GetLastError());
}
Pouvez vous me corriger svp.
Cordialement.
Je m'initie depuis peut à la programmation sur mt4 et je rencontre un probléme pour placer une vente quand 2 moyennes mobiles se croisent, ça marche à l'achat mais pas à la vente, voici le code que j'ai fait :
if (sell) {
// code de vente ici
sl=Bid + (stopLoss * factor);
sl2=Bid+(takeProfit * factor);
if(GlobalVariableGet("ticket")>0)
{
OrderClose(ticket,1,Ask,1,Red);
ticket = OrderSend(Symbol(),OP_SELL,1,Bid,1,NormalizeDouble(sl, Digits),NormalizeDouble(sl2, Digits),NULL,1234,Blue);
GlobalVariableSet("ticket", ticket);
}
else
{
ticket = OrderSend(Symbol(),OP_SELL,1,Bid,1,NormalizeDouble(sl, Digits),NormalizeDouble(sl2, Digits),NULL,1234,Blue);
GlobalVariableSet("ticket", ticket);
}
Print(GetLastError());
}
Pouvez vous me corriger svp.
Cordialement.