Statistics: Posted by xard777 — Fri May 17, 2024 5:09 pm — Replies 15218 — Views 3805768
Statistics: Posted by charli — Fri May 17, 2024 5:02 pm — Replies 811 — Views 41256
Statistics: Posted by boytoy — Fri May 17, 2024 4:38 pm — Replies 3288 — Views 373990
Statistics: Posted by WOLF — Fri May 17, 2024 4:23 pm — Replies 2847 — Views 172141
Statistics: Posted by WOLF — Fri May 17, 2024 4:15 pm — Replies 49 — Views 2748
Statistics: Posted by WOLF — Fri May 17, 2024 4:07 pm — Replies 3871 — Views 1119761
Statistics: Posted by Ogee — Fri May 17, 2024 3:57 pm — Replies 693 — Views 60889
Statistics: Posted by Banzai — Fri May 17, 2024 1:45 pm — Replies 82 — Views 17434
Statistics: Posted by opita — Fri May 17, 2024 11:47 am — Replies 20449 — Views 5085585
Statistics: Posted by JohnnyRy — Fri May 17, 2024 7:21 am — Replies 209 — Views 8272
Statistics: Posted by WOLF — Fri May 17, 2024 6:11 am — Replies 805 — Views 483233
Statistics: Posted by JohnnyRy — Fri May 17, 2024 5:58 am — Replies 4 — Views 1155
Code: Select all
//+------------------------------------------------------------------+//| MonEA.mq4 |//| Copyright 2017, MetaQuotes Software Corp. |//| http://www.metaquotes.net/ |//+------------------------------------------------------------------+#property strictextern double LotSize = 0.1;extern int BreakEvenPips = 200;extern bool TradeLondonSession = true;extern bool TradeUSSession = true;extern bool TradeTokyoSession = false;// Heures définies pour les sessions en GMT+0#define LONDON_OPEN 8#define LONDON_CLOSE 16#define NEW_YORK_OPEN 13#define NEW_YORK_CLOSE 22#define TOKYO_OPEN 0#define TOKYO_CLOSE 9//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+int OnInit(){ return(INIT_SUCCEEDED);}//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+void OnTick(){ if(!IsTradingAllowed()) return; double upSignal = iCustom(NULL, 0, "DonchianBreakoutSystem_v1.1.2", 5, 30, 0, 10, 0, 0, 1); double dnSignal = iCustom(NULL, 0, "DonchianBreakoutSystem_v1.1.2", 5, 30, 0, 10, 1, 0, 1); ManageOrder(OP_BUY, "Buy Order", Ask, BreakEvenPips); ManageOrder(OP_SELL, "Sell Order", Bid, BreakEvenPips);}//+------------------------------------------------------------------+//| Vérifie si le trading est autorisé selon la session |//+------------------------------------------------------------------+bool IsTradingAllowed(){ int hour = TimeHour(TimeCurrent()); if((TradeLondonSession && hour >= LONDON_OPEN && hour < LONDON_CLOSE) || (TradeUSSession && hour >= NEW_YORK_OPEN && hour < NEW_YORK_CLOSE) || (TradeTokyoSession && hour >= TOKYO_OPEN && hour < TOKYO_CLOSE)) return true; return false;}//+------------------------------------------------------------------+//| Fonction pour gérer les ordres |//+------------------------------------------------------------------+void ManageOrder(int orderType, string orderComment, double price, int pipsToBreakEven){ bool orderFound = false; for(int i = 0; i < OrdersTotal(); i++) { if(OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() == 0 && OrderType() == orderType) { orderFound = true; double openPrice = OrderOpenPrice(); double currentProfit = NormalizeDouble((price - openPrice) * (orderType == OP_BUY ? 1 : -1) * Point, 2); // Vérifier si le trade doit être mis en break-even if(currentProfit >= pipsToBreakEven * Point) { double newStopLoss = orderType == OP_BUY ? openPrice + (pipsToBreakEven * Point) : openPrice - (pipsToBreakEven * Point); if(OrderModify(OrderTicket(), openPrice, newStopLoss, OrderTakeProfit(), 0, clrYellow)) Print("Break-even stop loss set for order #", OrderTicket()); else Print("Error setting break-even: ", GetLastError()); } break; // Sortir après la gestion du premier ordre trouvé } } // Si aucun ordre existant n'est modifié, placer un nouvel ordre if(!orderFound) { int ticket = OrderSend(Symbol(), orderType, LotSize, price, 2, 0, 0, orderComment, 0, 0, orderType == OP_BUY ? clrGreen : clrRed); if(ticket < 0) { Print("Order Send failed with error #", GetLastError()); } else { Print("Order successfully placed with ticket #", ticket); } }}//+------------------------------------------------------------------+
Statistics: Posted by Xxcoincoin — Fri May 17, 2024 4:47 am — Replies 0 — Views 67
Statistics: Posted by Redman — Fri May 17, 2024 4:40 am — Replies 4130 — Views 1106715