Bonjour,
Voici notre question, nous cherchons un programme pour MT4 qui automatiquement règle le stop loss par tranche de 1 ou 2 pips de façon à limiter les pertes, pat contre il ne doit pas remonter dans le sens inverse
![]() |
|
![]() |
|
Dimanche 27 Mai 2012
Trader-Forex.fr en RSS
Bonjour,
Voici notre question, nous cherchons un programme pour MT4 qui automatiquement règle le stop loss par tranche de 1 ou 2 pips de façon à limiter les pertes, pat contre il ne doit pas remonter dans le sens inverse
Bonjour il y a un article sur le Guide metatrader de ce site qui explique comment réaliser un stop à la traine
Guide MetaTrader, leçon 16, Trailing stop en langage MQL4
voilà
je cherche a faire un EA qui descend en fonction de la position du pip's du marcher et que des que le stop loss a atteind ma position de rentre qui continue a descendre mais ne remonte pas
voici ce que j'ai
si quelqu'un peut m'ainder
int trailing_stop = 5;
double ts;
for (int i = OrdersTotal()-1; i >= 0; i --) // on parcourt tous les ordres
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol())
{
if (OrderType(5) == OP_BUY) // trailing stop pour un ordre d’achat
{
ts = Bid-(Point*trailing_stop); // calcul trailing stop
if (OrderStopLoss()< 0 ts) // test si nouveau plus haut
OrderModify(OrderTicket(5),OrderOpenPrice(), 50 ts,OrderTakeProfit(),5,White);
}
if (OrderType(5) == OP_SELL) // trailing stop pour un ordre de vente
{
ts = Ask+(Point*trailing_stop); // calcul trailing stop
if (OrderStopLoss()> 0ts)// test si nouveau plus bas
OrderModify(OrderTicket(),OrderOpenPrice(), 5 ts,OrderTakeProfit(),5,White);
}
}
}
Bonjour
je ne comprend pas bien votre code...
une fonction stop suiveur a chaque pip
et dans la fonction start(){suiveur(nbpip);}Code://++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+ stop suiveur + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void suiveur(int ts) { double stop; //++boucle sur tout les ordres for (int i=0; i<(OrdersTotal()); i++) { //rafraichissement RefreshRates(); //++seléction des ordres en mode trade OrderSelect(i, SELECT_BY_POS, MODE_TRADES); //++si la devise est identique au graph ou se trouve l'ea if (OrderSymbol() == Symbol())///if (OrderSymbol() == Symbol()&& OrderMagicNumber()==magic ) { //++les Buy if (OrderType() == OP_BUY) { //++calcul et normalisation valeur stop stop=NormalizeDouble(Bid-(Point*ts),Digits); //++si on peut se raprocher ou si il n'y a pas de stoploss if (OrderStopLoss()<stop || OrderStopLoss()==0) { bool retrn =OrderModify(OrderTicket(),OrderOpenPrice(),stop,OrderTakeProfit(),0,White); //++alerte de verif++ // // if (retrn == false) // { // Alert("OrderModify() error - ", GetLastError(),":b:",stop); // }else{ // Alert("OK modif a "+stop); // } } } if (OrderType() == OP_SELL) { stop=NormalizeDouble(Ask+(Point*ts),Digits); if (OrderStopLoss()>stop || OrderStopLoss()==0) { bool retr =OrderModify(OrderTicket(),OrderOpenPrice(),stop,OrderTakeProfit(),0,White); //++alerte de verif // // if (retr == false) // { // Alert("OrderModify() error - ", GetLastError(),":s:",stop); // }else{ // Alert("OK modif"+stop); // } } } } } }
Bien a vous
Dernière modification par Pacamo ; 05/05/2011 à 14h22.
et ou ce trouve le start?
bref...
Code:/+------------------------------------------------------------------+ //| test.mq4 | //| Copyright © 2011, Pacamo | //| http://www.pacamo.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, Pacamo" #property link "http://www.pacamo.net" extern int stops=25; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- suiveur(stops); //---- return(0); } //+------------------------------------------------------------------+ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+ stop suiveur + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void suiveur(int ts) { double stop; //++boucle sur tout les ordres for (int i=0; i<(OrdersTotal()); i++) { //++seléction des ordres en mode trade OrderSelect(i, SELECT_BY_POS, MODE_TRADES); //++si la devise est identique au graph ou se trouve l'ea if (OrderSymbol() == Symbol())///if (OrderSymbol() == Symbol()&& OrderMagicNumber()==magic ) { RefreshRates(); //++les Buy if (OrderType() == OP_BUY) { //++calcul et normalisation valeur stop stop=NormalizeDouble(Bid-(Point*ts),Digits); //++si on peut se raprocher ou si il n'y a pas de stoploss if (OrderStopLoss()<stop || OrderStopLoss()==0) { bool retrn =OrderModify(OrderTicket(),OrderOpenPrice(),stop,OrderTakeProfit(),0,White); //++alerte de verif++ // // if (retrn == false) // { // Alert("OrderModify() error - ", GetLastError(),":b:",stop); // }else{ // Alert("OK modif a "+stop); // } } } if (OrderType() == OP_SELL) { stop=NormalizeDouble(Ask+(Point*ts),Digits); if (OrderStopLoss()>stop || OrderStopLoss()==0) { bool retr =OrderModify(OrderTicket(),OrderOpenPrice(),stop,OrderTakeProfit(),0,White); //++alerte de verif // // if (retr == false) // { // Alert("OrderModify() error - ", GetLastError(),":s:",stop); // }else{ // Alert("OK modif"+stop); // } } } } } }
Bien a vous![]()