sales code for EA

Présentation, Développement, Améliorations et Ressources pour les Stratégies de Trading Automatique.

Modérateur : Administrateurs

Message
Auteur
Jhonmicky
Nouveau
Messages : 1
Inscription : 03 août 2019, 08:49

sales code for EA

#1 Message par Jhonmicky »

Hello everyone,,
I can learn since the programming on mt4 and I encounter a problem to place a sale when 2 moving averages intersect, it works on the purchase but not on sale, here is the code that I have done:

if (sell) {
// sales code here
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 ());
}

Can you please correct me..

Répondre