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 101
Statistics: Posted by Niveo74 — Thu May 16, 2024 5:02 pm — Replies 0 — Views 100
Statistics: Posted by newonetheblock — Wed May 15, 2024 9:56 am — Replies 5 — Views 286
Statistics: Posted by ionone — Tue May 14, 2024 6:21 pm — Replies 7 — Views 323
Statistics: Posted by ionone — Tue May 14, 2024 6:11 pm — Replies 0 — Views 123
Statistics: Posted by WOLF — Tue May 14, 2024 5:20 am — Replies 9 — Views 428
Statistics: Posted by funchi — Mon May 13, 2024 6:17 pm — Replies 6 — Views 401
Statistics: Posted by BoJo199 — Sat May 11, 2024 2:03 am — Replies 0 — Views 92
Statistics: Posted by Jedidiah — Thu May 09, 2024 5:33 am — Replies 6 — Views 510
Statistics: Posted by DAMPro69 — Tue May 07, 2024 8:02 am — Replies 2 — Views 500
Code: Select all
//@version=5indicator("v.0 WRBHG with Analysis", overlay = true, max_bars_back=5000, max_lines_count=4, max_labels_count=4, max_boxes_count = 4)group0 = 'Period under study'startDate = input.time(title='Start Date', defval=timestamp("2000-01-19 09:00:00 GMT+2"), group=group0)endDate = input.time(title='End Date', defval=timestamp('2099-09-01 09:00:00 GMT+2'), tooltip='Date & time to stop analysis', group=group0)use_custom_period = input.bool(title='use_custom_period', defval=true, group=group0, inline='HLline')var withinSession = truevar WRBHG_upper = 0.0var WRBHG_lower = 0.0var fillColor = color.blackx_extend_count = input.int(title="x extend count", defval = 30)transp = input.int(title="Transparency", defval = 70)body = math.abs(open-close)wrb = body>body[1] and body>body[2] and body>body[3] ? math.avg(open,close) : nahg = (wrb[1] and (low>high[2] or high<low[2]))? wrb[1] : navar penetratedBox = falsevar boxEndTime = endDateif withinSession if hg if close[1] > open[1] and low > high [2] WRBHG_upper := low WRBHG_lower := high[2] fillColor := color.new(color.green, transp) else if close[1] < open[1] and low > high [2] WRBHG_upper := low WRBHG_lower := high[2] fillColor := color.new(color.green, transp) else WRBHG_upper := low[2] WRBHG_lower := high fillColor := color.new(color.red, transp) box.new(time[2], WRBHG_upper, endDate, WRBHG_lower, border_color = na, xloc = xloc.bar_time, bgcolor = fillColor) s3 = ta.ema(ohlc4, 3)plot(s3, color=color.new(color.black,0))
Statistics: Posted by dgrl — Mon May 06, 2024 11:14 pm — Replies 1 — Views 259
Statistics: Posted by ffsss — Sun May 05, 2024 3:32 am — Replies 0 — Views 215
Statistics: Posted by ionone — Fri May 03, 2024 2:36 am — Replies 8 — Views 797
Statistics: Posted by ionone — Fri May 03, 2024 1:54 am — Replies 5 — Views 457