Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Trading Advisor (EA) Overview Source Code Download and Deployment Instructions Source Code Download and Deployment Instructions | Foreign Exchange EA Download - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

Overview of Trading Advisor (EA) This is an intelligent advisor (EA) specially designed for trading. It has a compact control panel and contains 39 elements for managing market orders, pending orders and trading parameters. EA supports stop loss, take profit, breakeven and trailing stop functions, and all operations are controlled by buttons. Panels can be customized in color and fixed anywhere on the chart, suitable for real-time trading and strategy testers. Control panel layout (top to bottom, left to right) Currency pair symbol current price (center display, spreads in the lower right corner) Expert mode switch (minimize/expand) Extended mode: Enable pending orders functionality. Minimize mode: Simplify the panel and save chart space. Position volume setting switch (interest/lots) Open position value as a percentage of deposit (display field, not button) Adjust open position volume button (two arrows: increase/decrease) Open position volume (percentage display, linked to the button below) Note: If the position is closed through take profit (TP), this field is ignored and the position is 100% closed. Close all button (close all positions by percentage of field 7) Adjust closed volume button (two arrows: increase/decrease) Pending order management (some buttons are hidden in minimized mode) Buy stop order button (above current price) Buy stop order quantity field deletes all buy stop order button Sell limit order button (above current price) Sell limit order quantity field deletes all sell limit order button Buy limit order button (below the current price, displays the number of points from the current price) Buy limit order quantity field Delete all buy limit orders button Sell stop order button (below current price) Sell stop order quantity field delete all sell stop order button Market order management Buy button (open position at current price) Buy position quantity field Buy position lot field Close all buy positions button (displays current profit) Sell button (open position at current price) Sell position quantity field Sell lot field close all sell positions button (display current profit) Trading parameters settings Stop loss mode switch (on/off, displays stop loss points) Adjust stop loss points button (two arrows: increase/decrease) Trailing stop mode switch (on/off, displays trigger points) Trailing profit value is predefined in settings. Adjust the trailing stop loss points button (two arrows: increase/decrease) Take profit mode switch (on/off, display the take profit points) Adjust the take profit points button (two arrows: increase/decrease) Breakeven mode switch (on/off, display the trigger points) Adjust the breakeven points button (two arrows: increase/decrease) Information display fixed label field (no variable information) Total profit and loss field (display the profit and loss of all positions of this currency pair) cpp //+------------------------------------------------------------------+ //| Trading Panel System.mq4 | //| Copyright © 2023-2025, AI Programming zblog | //| http://www.eawalk.com| //+------------------------------------------------------------------+ #propertycopyright "Copyright 2024, eawalk.com" #propertylink "http://eawalk.com" #propertyversion "2.00" #propertystrict #propertydescription "Expert advisor for manual trading" #propertydescription "Assist in setting up orders and managing trades" //Default parameters (variables not declared as extern/input) int Buy stop loss = 100, // Buy stop loss (unit: points) Buy stop loss = 100, // Buy take profit (unit: points) Buy trailing stop = 33, // Buy trailing stop loss (unit: points, if 0 Then there is no tracking, and the trailing stop is the distance from the current price to the stop loss) Buying no loss = 2, // Buying will be converted to no loss (unit: points, if it is 0, it will not be converted to no loss) Selling stop loss = 100, // Selling stop loss (unit: points) Selling stop loss = 100, // Sell taking profit (unit: points) Selling trailing stop = 33, // Selling trailing stop (unit: points, if it is 0) Then there is no tracking, and the trailing stop is the distance from the current price to the stop loss) Sell no loss = 2; //Selling will be converted to no loss (unit: points, if it is 0, it will not be converted to no loss) //Input parameter inputint Tracking step = 1, // Step size of the trailing stop (unit: points) Tracking start = 1; // Minimum profit for starting the trailing stop (unit: points) externdouble order lot size = 0.01; // Order lot inputint Slippage tolerance = 2; // Slippage tolerance (unit: points) inputint Pending order offset = 50; // Offset from the current price to the pending order (unit: pip) inputint Stop loss adjustment step = 1; // Stop loss adjustment step (unit: points) inputdouble Lot adjustment coefficient = 1.5; // Multiplier of lot adjustment inputdouble Risk adjustment step = 0; // Step size for risk percentage adjustment inputint Closing percentage step size = 10; // Step size for closing percentage adjustment inputbool Operation confirmation = true; // Whether the operation needs to be confirmed externbool Buy no-loss stop = true; // Buy stop-loss is based on the loss-free level externbool Sell no-loss stop-loss = true; // Sell stop-loss is based on the no-loss level externint Magic number = -1; // Magic number (-1 means monitoring all orders) inputstring font = "Times New Roman"; // font inputint font size = 10; // font size externint window type = 1; // window type externint color theme = 0; // color theme inputcolor color 1 = clrBlack; // color 1 inputcolor color 2 = clrWhite; // color 2 inputcolor color 3 = clrBlue; // color 3 inputcolor color 4 = clrRed; // color 4 inputcolor Color 5 = clrGreen; // Color 5 inputcolor Color 6 = clrLemonChiffon; // Color 6 inputcolor Color 7 = clrLightGray; // Color 7 inputcolor Color 8 = clrSnow; // Color 8 inputcolor Color 9 = clrGray; // Color 9 externbool Movable window = true; // Whether to allow moving windows inputlong X = 0; // Window X coordinate inputlong Y = 50; // Window Y coordinate // longUGOL=0; // Global variables double stop loss B, take profit B, trailing stop B, no loss B, stop loss S, take profit S, trailing stop S, no loss S; stringInpName = "cm-Trade System"; doublebid, risk = 1, closing percentage = 100; intSTOPLEVEL; stringAC, knTpB, knSlB, knTsB, knNlB, knTpS, knSlS, knTsS, knNlS, knTrNlB, knTrNlS; colorColor_1, Color_2, Color_3, Color_4, Color_5, Color_6, Color_7, Color_8,Color_9; boolTRADE; //+--------------------------------------------------------------------------------+ void_color(int t) { switch(t) { case 0: Color_1 = color 1; Color_2 = color 2; Color_3 = color 3; Color_4 = color 4; Color_5 = color 5; Color_6 = color 6; Color_7 = color 7; clrLime; Color_4 = clrRed; Color_5 = clrLime; Color_6 = clrGray; Color_7 = clrGray; Color_8 = clrDarkGray; Color_9 = clrBlack; break; case 2: Color_2 = clrBlack; clrLime; Color_6 = clrSlateGray; Color_7 = clrSlateGray; Color_8 = clrLightSteelBlue; Color_9 = clrBlack; break; case 3: Color_2 = clrBlack; Color_1 = clrWhite; Color_3 = clrLime; Color_4 = clrRed; Color_7 = clrDarkGray; Color_8 = clrSilver; Color_9 = clrBlack; break; default: Color_1 = clrWhite; Color_2 = clrBlack; Color_3 = clrLime; Color_4 = clrRed; Color_5 = clrLime; Color_6 = clrDarkGray; Color_9 = clrBlack; break; } } //+------------------------------------------------------------------+ intOnInit() { _color(color theme); AC = " " + AccountCurrency(); knTpB = StringConcatenate("kn TakeProfit B ", Symbol()); knSlB = StringConcatenate("kn StopLoss B ", Symbol()); knTsB = StringConcatenate("kn TrailingStop B ", Symbol()); knNlB = StringConcatenate("kn NoLoss B ", Symbol()); knTpS = StringConcatenate("kn TakeProfit S ", Symbol()); knSlS = StringConcatenate("kn StopLoss S ", Symbol()); knTsS = StringConcatenate("kn TrailingStop S ", Symbol()); knNlS = StringConcatenate("kn NoLoss S ", Symbol()); knTrNlB = StringConcatenate("kn Tr NoLoss B ", Symbol()); knTrNlS = StringConcatenate("kn Tr NoLoss S ", Symbol()); GV(); RectLabelCreate(0, InpName, 0, 10, 30, 270, 360, Color_2, Color_1,STYLE_SOLID, 1, false, movable window, true, 0); Redr(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); bid = Bid; Redraw(); EventSetTimer(1); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ voidOnDeinit(const int reason) { ObjectDelet-is one E(0, InpName); Del(); ObjectDelet-is one E(0, "kn color"); ObjectDelet-is one E(0, "kn color"); ObjectDelet-is one E(0, "Symbol"); } //------------------------------------------------------------------------ voidDel() { ObjectDelet-The difference is one E(0, "_fon3_"); ObjectDelet-The difference is one E(0, "_5_"); ObjectDelet-The difference is one E(0, "_6_"); ObjectDelet-The difference is one E(0, "_7_"); ObjectDelet-The difference is one E(0, "_8_"); ObjectDelet-The difference is one E(0, "_8_"); "_9_"); ObjectDelet-is one E(0, "_10_"); ObjectDelet-is one E(0, "_11_"); ObjectDelet-is one E(0, "_12_"); ObjectDelet-is one E(0, "_13_"); ObjectDelet-is one E(0, "_14_"); ObjectDelet-is one E(0, "_15_"); ObjectDelet-a difference of E(0, "_16_"); ObjectDelet-a difference of E(0, "_17_"); ObjectDelet-a difference of E(0, "2"); ObjectDelet-a difference of E(0, "3"); ObjectDelet-a difference of E(0, "4"); ObjectDelet-a difference of E(0, "5"); ObjectDelet-The difference is one E(0, "6"); ObjectDelet-The difference is one E(0, "7"); ObjectDelet-The difference is one E(0, "8"); ObjectDelet-The difference is one E(0, "9"); ObjectDelet-The difference is one E(0, "10"); ObjectDelet-The difference is one E(0, "11"); ObjectDelet-The difference is one E(0, "12"); ObjectDelet-The difference is one E(0, "kn Buy"); ObjectDelet-The difference is one E(0, "kn Sell"); ObjectDelet-The difference is one E(0, "kn BuyStop"); ObjectDelet-The difference is one E(0, "kn SellLimit"); ObjectDelet-The difference is one E(0, "kn BuyLimit"); ObjectDelet-The difference is one E(0, "kn SellStop"); ObjectDelet-The difference is one E(0, "kn Del BuyStop"); ObjectDelet-The difference is one E(0, "kn Del SellLimit"); ObjectDelet-The difference is one E(0, "kn Close Buy"); ObjectDelet-The difference is one E(0, "kn Close Sell"); ObjectDelet-The difference is one E(0, "kn Del BuyLimit"); ObjectDelet-The difference is one E(0, "kn Del SellStop"); ObjectDelet-The difference is one E(0, knTpB); ObjectDelet-The difference is one E(0, knSlB); ObjectDelet-The difference is one E(0, knTsB); ObjectDelet-The difference is one E(0, knNlB); ObjectDelet-The difference is one E(0, knTpS); ObjectDelet-The difference is one E(0, knSlS); ObjectDelet-The difference is one E(0, knTsS); ObjectDelet-The difference is one E(0, knNlS); ObjectDelet-The difference is one E(0, knTrNlB); ObjectDelet-The difference is one E(0, knTrNlS); ObjectDelet-The difference is one E(0, StringConcatenate(knTpB, " up")); ObjectDelet-The difference is one E(0, StringConcatenate(knSlB, " up")); ObjectDelet-The difference is one E(0, StringConcatenate(knTsB, " up")); ObjectDelet-The difference is one E(0, StringConcatenate(knNlB, " up")); ObjectDelet-The difference is one E(0, StringConcatenate(knTpS, " up")); ObjectDelet-The difference is one E(0, StringConcatenate(knSlS, " up")); ObjectDelet - one E(0, StringConcatenate(knTsS, " up")); ObjectDelet - one E(0, StringConcatenate(knNlS, " up")); ObjectDelet - one E(0, StringConcatenate(knTpB, " dn")); ObjectDelet - one E(0, StringConcatenate(knSlB, " dn")); ObjectDelet-The difference is one E(0, StringConcatenate(knTsB, " dn")); ObjectDelet-The difference is one E(0, StringConcatenate(knNlB, " dn")); ObjectDelet-The difference is one E(0, StringConcatenate(knTpS, " dn")); ObjectDelet-The difference is one E(0, StringConcatenate(knSlS, " dn")); ObjectDelet-The difference is one E(0, StringConcatenate(knTsS, " dn")); ObjectDelet-The difference is one E(0, StringConcatenate(knNlS, " dn")); ObjectDelet-The difference is one E(0, "lot_"); ObjectDelet-The difference is one E(0, "kn lot pr"); ObjectDelet-The difference is one E(0, "kn lot l"); ObjectDelet-The difference is one E(0, "kn lot up"); ObjectDelet-The difference is one E(0, "kn lot dn"); ObjectDelet-The difference is one E(0, "kn CZ1"); ObjectDelet-The difference is one E(0, "_CZ1_"); ObjectDelet-The difference is one E(0, "kn CZ"); ObjectDelet-The difference is one E(0, "kn cz up"); ObjectDelet-The difference is one E(0, "kn cz dn"); ObjectDelet-The difference is one E(0, "spread"); ObjectDelet-The difference is one E(0, "Profit"); ObjectDelet-The difference is one E(0, "_Profit"); ObjectDelet-The difference is one E(0, "Equity"); ObjectDelet-The difference is one E(0, "_Equity"); ObjectDelet-Difference by one E(0, "Balance"); ObjectDelet-Difference by one E(0, "_Balance"); } //----------------------------------------------------------------------------- voidOnTick() { OnTimer(); } voidOnTimer() { TRADE = IsTradeAllowed(); if (ObjectGetInteger(0, "kn min", OBJPROP_STATE)) { Window type++; if (Window type > 3) Window type = 0; Del(); ObjectSetInteger(0, "kn min", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn color", OBJPROP_STATE)) { Color theme++; if (color theme > 4) Color theme = 0; ObjectSetInteger(0, "kn color", OBJPROP_STATE, false); } chekbuttom(); return; } //----------------------------------------------------------------------------- boolButtonCreate(const long chart_ID = 0, const string name = "Button", const int sub_window = 0, const long x = 0, constlong y = 0, const int width = 50, const int height = 18, const string text = "Button", const string font = "Arial", const int font_size= 10, const color clr =clrNONE, const color clrON = clrNONE, const color clrOFF = clrNONE, const bool state =false) { if (ObjectFind(chart_ID, name) == -1) { ObjectCreate(chart_ID, name, OBJ_BUTTON, sub_window, 0, 0); ObjectSetInteger(chart_ID, name, OBJPROP_XSIZE, width); ObjectSetInteger(chart_ID, name, OBJPROP_YSIZE, height); ObjectSetInteger(chart_ID, name, OBJPROP_CORNER,CORNER_LEFT_UPPER); ObjectSetString(chart_ID, name, OBJPROP_FONT, font); ObjectSetInteger(chart_ID, name, OBJPROP_FONTSIZE, font_size); ObjectSetInteger(chart_ID, name, OBJPROP_BACK, 0); ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, 0); ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, 0); ObjectSetInteger(chart_ID, name, OBJPROP_HIDDEN, 1); ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, 0); ObjectSetInteger(chart_ID, name, OBJPROP_STATE, state); ObjectSetInteger(chart_ID, name, OBJPROP_BORDER_COLOR, clrNONE); } color back_clr; if (ObjectGetInteger(chart_ID, name, OBJPROP_STATE)) back_clr = clrON;else back_clr = clrOFF; ObjectSetInteger(chart_ID, name, OBJPROP_BGCOLOR, back_clr); ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr); ObjectSetString(chart_ID, name, OBJPROP_TEXT, text); ObjectSetInteger(chart_ID, name, OBJPROP_XDISTANCE, x); ObjectSetInteger(chart_ID, name, OBJPROP_YDISTANCE, y); return(true); } //-------------------------------------------------------------------- boolRectLabelCreate(const long chart_ID = 0, const string name = "RectLabel", const int sub_window = 0, const longx = 0, const long y = 0, const int width = 50, const int height = 18, constcolor back_clr = clrNONE, const color clr = clrNONE, const ENUM_LINE_STYLEstyle = STYLE_SOLID, const intline_width = 1, const bool back = false, const bool selection = false, const boolhidden = true, const long z_order = 0) { ResetLastError(); if (ObjectFind(chart_ID, name) == -1) { ObjectCreate(chart_ID, name, OBJ_RECTANGLE_LABEL, sub_window, 0,0); ObjectSetInteger(chart_ID, name, OBJPROP_BORDER_TYPE,BORDER_FLAT); ObjectSetInteger(chart_ID, name, OBJPROP_CORNER,CORNER_LEFT_UPPER); ObjectSetInteger(chart_ID, name, OBJPROP_STYLE, style); ObjectSetInteger(chart_ID, name, OBJPROP_WIDTH, line_width); ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back); ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection); ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection); ObjectSetInteger(chart_ID, name, OBJPROP_HIDDEN, hidden); ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order); } ObjectSetInteger(chart_ID, name, OBJPROP_BGCOLOR, back_clr); ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr); ObjectSetInteger(chart_ID, name, OBJPROP_XSIZE, width); ObjectSetInteger(chart_ID, name, OBJPROP_YSIZE, height); ObjectSetInteger(chart_ID, name, OBJPROP_XDISTANCE, x); ObjectSetInteger(chart_ID, name, OBJPROP_YDISTANCE, y); return(true); } //----------------------------------------------------------------------------- boolLabelCreate(const long chart_ID = 0, const string name = "Label", const int sub_window = 0, const long x = 0, constlong y = 0, const ENUM_BASE_CORNER corner = CORNER_LEFT_UPPER, const string text ="Label", const string font = "Arial", const int font_size =10, const color clr =clrNONE, const double angle = 0.0, const ENUM_ANCHOR_POINT anchor = ANCHOR_LEFT_UPPER, const bool back = false, const bool selection = true, const bool hidden = true, const long z_order = 0) { ResetLastError(); if (ObjectFind(chart_ID, name) == -1) { if (!ObjectCreate(chart_ID, name, OBJ_LABEL, sub_window, 0, 0)) { Print(__FUNCTION__, ": Unable to create text label! Error code = ",GetLastError()); return(false); } ObjectSetInteger(chart_ID, name, OBJPROP_CORNER, corner); ObjectSetString(chart_ID, name, OBJPROP_FONT, font); ObjectSetInteger(chart_ID, name, OBJPROP_FONTSIZE, font_size); ObjectSetDouble(chart_ID, name, OBJPROP_ANGLE, angle); ObjectSetInteger(chart_ID, name, OBJPROP_ANCHOR, anchor); ObjectSetInteger(chart_ID, name, OBJPROP_BACK, back); ObjectSetInteger(chart_ID, name, OBJPROP_SELECTABLE, selection); ObjectSetInteger(chart_ID, name, OBJPROP_SELECTED, selection); ObjectSetInteger(chart_ID, name, OBJPROP_HIDDEN, hidden); ObjectSetInteger(chart_ID, name, OBJPROP_ZORDER, z_order); } ObjectSetInteger(chart_ID, name, OBJPROP_COLOR, clr); ObjectSetInteger(chart_ID, name, OBJPROP_XDISTANCE, x); ObjectSetInteger(chart_ID, name, OBJPROP_YDISTANCE, y); ObjectSetString(chart_ID, name, OBJPROP_TEXT, text); return(true); } //---------------------------------------------------------------------------------- boolSendOrder(int tip, double lot, double p) { if (operation confirmation) { string txt; if (tip == OP_BUY) txt = StringConcatenate("Open a buying position",DoubleToStr(lot, 2), "Lot, price", DoubleToStr(p,Digits), "?"); if (tip == OP_SELL) txt = StringConcatenate("Open a sell position",DoubleToStr(lot, 2), "Lot, price", DoubleToStr(p,Digits), "?"); if (tip == OP_BUYSTOP) txt = StringConcatenate("Set a buy stop order",DoubleToStr(lot, 2), "Lot, price", DoubleToStr(p,Digits), "?"); if (tip == OP_BUYSTOP) == OP_SELLSTOP) txt = StringConcatenate("Set a sell stop order",DoubleToStr(lot, 2), "Lot, price", DoubleToStr(p,Digits), "?"); if (tip == OP_BUYLIMIT) txt = StringConcatenate("Set a buy limit order",DoubleToStr(lot, 2), "Lot, price", DoubleToStr(p,Digits), " ?"); if (tip == OP_SELLLIMIT) txt = StringConcatenate("Set sell limit order",DoubleToStr(lot, 2), "Lot, price", DoubleToStr(p,Digits), " ?"); int ret = MessageBox(txt, "", MB_YESNO); if (ret == IDNO) return(true); } int nn = 0; while (true) { RefreshRates(); if (OrderSend(Symbol(), tip, lot, p, slippage tolerance, 0, 0, NULL, magic number, 0, clrNONE) == -1) { Print("Order sending error", GetLastError(), "Lot size", lot); Sleep(1000); } else return(true); nn++; if (nn > 10) return(false); } return(false); } //----------------------------------------------------------------------------- intRedraw() { RefreshRates(); double StLo, OSL, OTP, OOP, SL, TP; STOPLEVEL = StrToInteger(DoubleToStr(MarketInfo(Symbol(),MODE_STOPLEVEL), 0)); double stoplevel = STOPLEVEL * Point; int b = 0, s = 0, bs = 0, ss = 0, bl = 0, sl = 0, tip; double OL, LB = 0, LS = 0, ProfitB = 0, ProfitS = 0; Stop loss B = Kn(knSlB, Stop loss B); Take profit B = Kn(knTpB, Take profit B); No loss B = Kn(knNlB, no loss B); Trailing stop B = Kn(knTsB, trailing stop B); Stop loss S = Kn(knSlS, stop loss S); Take profit S = Kn(knTpS, take profit S); No loss S = Kn(knNlS, no loss S); Trailing stop S = Kn(knTsS, trailing stop S); bool TrNoLossB = Kn(knTrNlB, 1) == 1; bool TrNoLossS = Kn(knTrNlS, 1) == 1; int i, Ticket; double price_b = 0, price_s = 0; for (i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && (Magic Number == -1 || Magic Number == OrderMagicNumber())) { OSL = NormalizeDouble(OrderStopLoss(),Digits); OTP = NormalizeDouble(OrderTakeProfit(),Digits); OOP = NormalizeDouble(OrderOpenPrice(),Digits); Ticket = OrderTicket(); SL = OSL; TP = OTP; tip = OrderType(); OL = OrderLots(); if (tip == OP_BUY) { b++; LB += OL; price_b += (Bid - OOP)* OL + (OrderCommission() + OrderSwap()) * Point; ProfitB += OrderProfit() +OrderCommission() + OrderSwap(); if (OSL == 0 && Bid -NormalizeDouble(OOP - Stop Loss B * Point, Digits) >= stoplevel && Stop Loss B != 0) { SL =NormalizeDouble(OOP - Stop Loss B * Point, Digits); } if (Stop Loss B == 0 && No Loss B == 0 && Trailing Stop Loss B == 0) SL = 0; if (Take Profit B == 0) TP = 0; if (!TrNoLossB) { if (OTP == 0 &&NormalizeDouble(OOP + Take Profit B * Point, Digits) - Ask >= stoplevel && Take Profit B != 0) { TP =NormalizeDouble(OOP + Take Profit B * Point, Digits); } if (OSL < OOP&& No Loss B!= 0) { if (Bid -OOP >= No Loss B* Point && Bid - OOP >= stoplevel) SL = OOP + Point; } if (Trailing Stop B != 0) { StLo =NormalizeDouble(Bid - Trailing Stop B * Point, Digits); if (StLo>= OOP + Trailing Start* Point && StLo > OSL + tracking step*Point && StLo <= NormalizeDouble(Bid - stoplevel, Digits)) SL =StLo; } } if (TRADE && (SL >OSL || TP != OTP)) { Comment("Modify order", Ticket,"Buy, Stop Loss", OSL, "->", SL,", Take Profit", OTP, "->", TP); if(!OrderModify(Ticket, OOP, SL, TP, 0, White)) Print("Order modification error",GetLastError()); } } if (tip == OP_SELL) { s++; LS += OL; price_s += (OOP -Ask) * OL + (OrderCommission() + OrderSwap()) * Point; ProfitS += OrderProfit() +OrderCommission() + OrderSwap(); if (OSL == 0 &&NormalizeDouble(OOP + Stop Loss S * Point, Digits) - Ask >= stoplevel && Stop Loss S != 0) { SL =NormalizeDouble(OOP + Stop Loss S * Point, Digits); } if (Stop Loss S == 0 && No Loss S == 0 && Trailing Stop Loss S == 0) SL = 0; if (Take Profit S == 0) TP = 0; if (!TrNoLossS) { if (OTP == 0 &&Bid - NormalizeDouble(OOP - Take Profit S * Point, Digits) >= stoplevel && Take Profit S != 0) { TP =NormalizeDouble(OOP - Take Profit S * Point, Digits); } if ((OSL > OOP ||OSL == 0) && No Loss S != 0) { if (OOP -Ask >= No Loss S* Point && (OOP < OSL || OSL == 0) && OOP - Ask >=stoplevel) SL = OOP - Point; } if (Trailing Stop S != 0) { StLo =NormalizeDouble(Ask + Trailing Stop S * Point, Digits); if (StLo<= OOP - Tracking Start*Point && (StLo < OSL - Tracking Step*Point || OSL == 0) && StLo >= NormalizeDouble(Ask + stoplevel,Digits)) SL = StLo; } } if (TRADE && ((SL 0) NLb = Bid - price_b / LB; ARROW("NoLoss_NLb", NLb, 6, Color_3); if (LS > 0) NLs = Ask + price_s / LS; ARROW("NoLoss_NLs", NLs, 6, Color_4); if (LB - LS > 0) NL = Bid - (price_b + price_s) / (LB - LS); if (LB - LS < 0) NL = Ask - (price_b + price_s) / (LB - LS); ARROW("NoLoss_NL", NL, 6, clrYellow); //--- if (TrNoLossB || TrNoLossS) { for (i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && (Magic Number == -1 || Magic Number == OrderMagicNumber())) { OSL =NormalizeDouble(OrderStopLoss(), Digits); OTP =NormalizeDouble(OrderTakeProfit(), Digits); OOP =NormalizeDouble(OrderOpenPrice(), Digits); Ticket = OrderTicket(); SL = OSL; TP = OTP; tip = OrderType(); OL = OrderLots(); if (tip == OP_BUY &&TrNoLossB) { if (NormalizeDouble(NLb+ Take profit B* Point, Digits) - Ask >= stoplevel && Take profit B!= 0) { TP =NormalizeDouble(NLb + Take profit B * Point, Digits); } if (OSL < OOP&& No loss B!= 0) { if (Bid -NLb >= No loss B* Point && Bid - NLb >= stoplevel) SL = NLb + Point; } if (Trailing Stop B != 0) { StLo =NormalizeDouble(Bid - Trailing Stop B * Point, Digits); if (StLo>= NLb + Tracking Start * Point && StLo > OSL + Tracking Step *Point && StLo <= NormalizeDouble(Bid - stoplevel, Digits)) SL =StLo; } if (TRADE &&(SL > OSL || TP != OTP)) { Comment("Modify order from lossless level",Ticket, "Buy Stop Loss", OSL, "->",SL, ", Take Profit", OTP, "->", TP); if(!OrderModify(Ticket, OOP, SL, TP, 0, White)) Print("Order Modify Error",GetLastError()); } } if (tip == OP_SELL &&TrNoLossS) { if (Bid -NormalizeDouble(NLs - Take Profit S * Point, Digits) >= stoplevel && Take Profit S != 0) { TP =NormalizeDouble(NLs - Take Profit S * Point, Digits); } if ((OSL > NLs ||OSL == 0) && No Loss S != 0) { if (NLs -Ask >= No Loss S* Point && (NLs < OSL || OSL == 0) && NLs - Ask >=stoplevel) SL = NLs - Point; } if (Trailing Stop S != 0) { StLo =NormalizeDouble(Ask + Trailing Stop S * Point, Digits); if (StLo<= NLs - Trailing Start* Point && (StLo < OSL - Tracking step *Point || OSL == 0) && StLo >= NormalizeDouble(Ask + stoplevel,Digits)) SL = StLo; } if (TRADE &&((SL < OSL || (OSL == 0 && SL != 0)) || TP != OTP)) { Comment("Modify order from no-loss level", Ticket, "Sell Stop", OSL,"->", SL, ", Take Profit", OTP,"->", TP); if(!OrderModify(Ticket, OOP, SL, TP, 0, White)) Print("Order modification error",GetLastError()); } } } } } } Redr(LB, LS, ProfitB, ProfitS, bs, ss, b, s, sl, bl); return(0); } //+------------------------------------------------------------------+ //+----------------------------------------------------------------------------------+ boolclose(int tip) { if (operation confirmation) { string txt = "Close all positions"; if (tip == OP_BUY) txt = StringConcatenate(txt, "Buy?"); if (tip == OP_SELL) txt = StringConcatenate(txt, "Sell?"); int ret = MessageBox(txt, "", MB_YESNO); if (ret == IDNO) return(true); } bool error = true; int j, err, nn = 0, OT; while (!IsStopped()) { for (j = OrdersTotal() - 1; j >= 0; j--) { if (OrderSelect(j, SELECT_BY_POS)) { if (OrderSymbol() == Symbol() && (Magic Number == -1 || Magic Number == OrderMagicNumber())) { OT = OrderType(); if (tip != OT) continue; if (OT == OP_BUY) { error =OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, Digits), 3, Blue); } if (OT == OP_SELL) { error =OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, Digits), 3, Red); } if (!error) { err = GetLastError(); if (err < 2)continue; if (err == 129) { RefreshRates(); continue; } if (err == 146) { if(IsTradeContextBusy()) Sleep(2000); continue; } Print("Error", err, "Close order number", OrderTicket(), " ",TimeToStr(TimeCurrent(), TIME_SECONDS)); } } } } int n = 0; for (j = 0; j < OrdersTotal(); j++) { if (OrderSelect(j, SELECT_BY_POS)) { if (OrderSymbol() == Symbol() && (Magic Number == -1 || Magic Number == OrderMagicNumber())) { OT = OrderType(); if (tip != OT) continue; if (OT == OP_BUY || OT ==OP_SELL) n++; } } } if (n == 0) break; nn++; if (nn > 10) { return(false); } Sleep(1000); RefreshRates(); } return(true); } //----------------------------------------------------------------------------- boolDelet-E(int tip) { if (operation confirmation) { string txt = "Delete pending order"; if (tip == OP_BUYSTOP) txt = StringConcatenate(txt, "Buy stop order?"); if (tip == OP_SELLSTOP) txt = StringConcatenate(txt, "Sell stop order?"); if (tip == OP_BUYLIMIT) txt = StringConcatenate(txt, "Buy limit order?"); if (tip == OP_SELLLIMIT) txt = StringConcatenate(txt, "Sell limit order?"); int ret = MessageBox(txt, "", MB_YESNO); if (ret == IDNO) return(true); } bool error = true; int OT; for (int j = OrdersTotal() - 1; j >= 0; j--) { if (OrderSelect(j, SELECT_BY_POS)) { if (OrderSymbol() == Symbol() && (magic number == -1 || magic number == OrderMagicNumber())) { OT = OrderType(); if (tip != OT || OT < 2) continue; error = OrderDelet-E(OrderTicket()); } } } return(true); } //----------------------------------------------------------------------------- voidchekbuttom() { if (TRADE) { if (ObjectGetInteger(0, "kn Buy", OBJPROP_STATE)) { if (SendOrder(OP_BUY, order lot size, NormalizeDouble(Ask, Digits))) ObjectSetInteger(0,"kn Buy", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Sell", OBJPROP_STATE)) { if (SendOrder(OP_SELL, order lot size,NormalizeDouble(Bid, Digits))) ObjectSetInteger(0, "kn Sell",OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn BuyStop", OBJPROP_STATE)) { if (SendOrder(OP_BUYSTOP, order lot size,NormalizeDouble(Ask + pending order offset* Point, Digits)))ObjectSetInteger(0, "kn BuyStop", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn SellLimit", OBJPROP_STATE)) { if (SendOrder(OP_SELLLIMIT, order lot size,NormalizeDouble(Ask + pending order offset* Point, Digits)))ObjectSetInteger(0, "kn SellLimit", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn BuyLimit", OBJPROP_STATE)) { if (SendOrder(OP_BUYLIMIT, order lot size,NormalizeDouble(Bid - pending order offset * Point, Digits)))ObjectSetInteger(0, "kn BuyLimit", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn SellStop", OBJPROP_STATE)) { if (SendOrder(OP_SELLSTOP, order lot size,NormalizeDouble(Bid - pending order offset * Point, Digits)))ObjectSetInteger(0, "kn SellStop", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Close Buy", OBJPROP_STATE)) { close(OP_BUY); ObjectSetInteger(0, "kn CloseBuy", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Close Sell",OBJPROP_STATE)) { close(OP_SELL); ObjectSetInteger(0, "kn CloseSell", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Del BuyStop",OBJPROP_STATE)) { Delet-One E(OP_BUYSTOP); ObjectSetInteger(0, "kn DelBuyStop", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Del SellLimit",OBJPROP_STATE)) { Delet-One E(OP_SELLLIMIT); ObjectSetInteger(0, "kn DelSellLimit", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Del BuyLimit",OBJPROP_STATE)) { SellStop",OBJPROP_STATE)) { Delet-E(OP_SELLSTOP); ObjectSetInteger(0, "kn DelSellStop", OBJPROP_STATE, false); } } if (ObjectGetInteger(0, "kn lot l", OBJPROP_STATE))ObjectSetInteger(0, "kn lot pr", OBJPROP_STATE, false); else ObjectSetInteger(0, "kn lot pr", OBJPROP_STATE, true); if (ObjectGetInteger(0, "kn lot up", OBJPROP_STATE)) { PlaySound("Ok.wav"); if (ObjectGetInteger(0, "kn lot l", OBJPROP_STATE)) order lot size*= lot adjustment coefficient; else { risk+= Risk adjustment step size; Order lot size = AccountBalance() * Risk / 100 / MarketInfo(Symbol(), MODE_MARGINREQUIRED); } ObjectSetInteger(0, "kn lot up", OBJPROP_STATE, false); if (Order lot size > MarketInfo(Symbol(), MODE_MAXLOT)) Order lot size = MarketInfo(Symbol(), MODE_MAXLOT); } if (ObjectGetInteger(0, "kn lot dn", OBJPROP_STATE)) { PlaySound("Ok.wav"); if (ObjectGetInteger(0, "kn lot l", OBJPROP_STATE)) Order lot/= lot adjustment coefficient; else { Risk-= risk adjustment step; Order lot size = AccountBalance() * Risk / 100 / MarketInfo(Symbol(), MODE_MARGINREQUIRED);} ObjectSetInteger(0, "kn lot dn", OBJPROP_STATE, false); if (Order lot size < MarketInfo(Symbol(), MODE_MINLOT)) Order lot size = MarketInfo(Symbol(), MODE_MINLOT); } if (ObjectGetInteger(0, "kn cz up", OBJPROP_STATE)) { PlaySound("Ok.wav"); Close percentage += Close percentage step; ObjectSetInteger(0, "kn cz up", OBJPROP_STATE, false); if (Close percentage > 100) Close percentage = 100; } if (ObjectGetInteger(0, "kn cz dn", OBJPROP_STATE)) { PlaySound("Ok.wav"); Closing percentage -= Closing percentage step; ObjectSetInteger(0, "kn cz dn", OBJPROP_STATE, false); if (Closing percentage < 0) Closing percentage = 0; } kn_UP_DN(knSlB, Stop loss B); kn_UP_DN(knTpB, take profit B); kn_UP_DN(knTsB, trailing stop B); kn_UP_DN(knNlB, no loss B); kn_UP_DN(knSlS, stop loss S); kn_UP_DN(knTpS, take profit S); kn_UP_DN(knTsS, trailing stop S); kn_UP_DN(knNlS, lossless S); GV(); if (ObjectGetInteger(0, "kn CZ", OBJPROP_STATE)) { closeCZ(); PlaySound("Ok.wav"); ObjectSetInteger(0, "kn CZ", OBJPROP_STATE, false); } Redraw(); return; } //-------------------------------------------------------------------------------- voidkn_UP_DN(string name, double Price) { double Par; if (GlobalVariableCheck(StringConcatenate(name, " PIPS"))) Par= GlobalVariableGet(StringConcatenate(name, " PIPS")); else Par = Price; if (ObjectGetInteger(0, StringConcatenate(name, " up"),OBJPROP_STATE)) { PlaySound("Ok.wav"); Par += Stop loss adjustment step size; GlobalVariableSet(StringConcatenate(name, " PIPS"),Par); ObjectSetInteger(0, StringConcatenate(name, " up"),OBJPROP_STATE, false); } if (ObjectGetInteger(0, StringConcatenate(name, " dn"),OBJPROP_STATE)) { PlaySound("Ok.wav"); Par -= Stop loss adjustment step; if (Par <= 0) GlobalVariableDel(StringConcatenate(name, "PIPS")); else { GlobalVariableSet(StringConcatenate(name, "PIPS"), Par); } ObjectSetInteger(0, StringConcatenate(name, " dn"),OBJPROP_STATE, false); } } //-------------------------------------------------------------------- boolcloseCZ() { if (operation confirmation) { int ret = MessageBox(StringConcatenate("Close", closing percentage, "% of all positions?"), "",MB_YESNO); if (ret == IDNO) return(true); } bool error = true; int j, OT; for (j = OrdersTotal() - 1; j >= 0; j--) { if (OrderSelect(j, SELECT_BY_POS)) { if (OrderSymbol() ==Symbol() && (Magic number == -1 || Magic number == OrderMagicNumber())) { OT = OrderType(); if (OT > 1) continue; if (OT == OP_BUY) { error =OrderClose(OrderTicket(), NormalizeDouble(OrderLots() / 100 * closing percentage, 2),NormalizeDouble(Bid, Digits), 3, Blue); } if (OT == OP_SELL) { error =OrderClose(OrderTicket(), NormalizeDouble(OrderLots() / 100 * Closing percentage, 2),NormalizeDouble(Ask, Digits), 3, Red); } } } } return(true); } //-------------------------------------------------------------------- doubleKn(string Name, double Price) { if (ObjectFind(0, Name) != -1) { if (ObjectGetInteger(0, Name, OBJPROP_STATE)) { if (Price == 0) { Alert(Name, "Please set a value greater than the stop loss level"); ObjectSetInteger(0, Name, OBJPROP_STATE,false); GlobalVariableDel(Name); } if (!GlobalVariableCheck(Name))GlobalVariableSet(Name, 1); return(Price); } else { if (GlobalVariableCheck(Name))GlobalVariableDel(Name); return(0); } } return(0); } //----------------------------------------------------------------------------- voidARROW(string Name, double Price, int ARROWCODE, color c) { ObjectDelet-E(Name); ObjectCreate(Name, OBJ_ARROW, 0, Time[0], Price, 0, 0, 0, 0); ObjectSetInteger(0, Name, OBJPROP_ARROWCODE, ARROWCODE); ObjectSetInteger(0, Name, OBJPROP_COLOR, c); ObjectSetInteger(0, Name, OBJPROP_WIDTH, 1); } //------------------------------------------------------------------------ voidGV() { if (GlobalVariableCheck(StringConcatenate(knSlB, " PIPS"))) Stop loss B = GlobalVariableGet(StringConcatenate(knSlB, " PIPS")); else Stop loss B = Buy stop loss; if (GlobalVariableCheck(StringConcatenate(knTpB, " PIPS"))) Stop loss B = GlobalVariableGet(StringConcatenate(knTpB, " PIPS")); else Take Profit B = Buy Take Profit; if (GlobalVariableCheck(StringConcatenate(knTsB, " PIPS"))) Trailing Stop B =GlobalVariableGet(StringConcatenate(knTsB, " PIPS")); else Trailing Stop B = Buy Trailing Stop; if (GlobalVariableCheck(StringConcatenate(knNlB, " PIPS"))) No loss B = GlobalVariableGet(StringConcatenate(knNlB, " PIPS")); else No loss B = Buy without loss; if (GlobalVariableCheck(StringConcatenate(knSlS, " PIPS"))) Stop loss S = GlobalVariableGet(StringConcatenate(knSlS, " PIPS")); else Stop Loss S = Sell Stop Loss; if (GlobalVariableCheck(StringConcatenate(knTpS, " PIPS"))) Take Profit S = GlobalVariableGet(StringConcatenate(knTpS, " PIPS")); else Take Profit S = Sell Stop Loss; if (GlobalVariableCheck(StringConcatenate(knTsS, " PIPS"))) Trailing Stop Loss S =GlobalVariableGet(StringConcatenate(knTsS, " PIPS")); else Trailing Stop S = Sell Trailing Stop; if (GlobalVariableCheck(StringConcatenate(knNlS, " PIPS"))) No Loss S = GlobalVariableGet(StringConcatenate(knNlS, " PIPS")); else No Loss S = Sell No Loss; } //-------------------------------------------------------------------------------- voidRedr(double LB, double LS, double ProfitB, double ProfitS, int bs, int ss, intb, int s, int sl, int bl) { color cl; _color(color theme); double Profit = ProfitB + ProfitS; if (ObjectFind(InpName) == 0) { if (Window type == 0) { RectLabelCreate(0, InpName, 0, false, true, true, 1); if (Window type== 2) RectLabelCreate(0, InpName, 0, X, Y, 300, 360,Color_2, Color_2, STYLE_SOLID, 3, false, true, true, 1); if (Window type== 3) RectLabelCreate(0, InpName, 0, 360,Color_2, Color_2, STYLE_SOLID, 3, false, true, true, 1); } } long y = Y; RectLabelCreate(0, "_fon1_", 0, RectLabelCreate(0, "_fon2_", 0, 18,CharToStr(244), "Wingdings", font size, Color_1, Color_8, Color_7, false); ButtonCreate(0, "kn color", 0, X + 2, y + 20, 18, 18,CharToStr(83), "Wingdings", font size, Color_1, Color_8, Color_7, false); LabelCreate(0, "Symbol", 0, Color_3; bid = NormalizeDouble(Bid, Digits); LabelCreate(0, "2", 0, X + 285, y + 32,CORNER_LEFT_UPPER, DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD), 0), Font, Font Size - 2, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); y += 42; ButtonCreate(0, "kn lot l", 0, X + 2, y, 130, 18,StringConcatenate(DoubleToStr(order lot, 2), "lot"), font, font size, Color_1, Color_8, Color_7, true); ButtonCreate(0, "kn lot up", 0, X + 131, y, 18, 18,CharToStr(217), "Wingdings", 8, Color_1, Color_8, Color_7, false); ButtonCreate(0, "kn cz up", 0, X + 281, y, 18, 18,CharToStr(217), "Wingdings", 8, Color_1, Color_8, Color_7, false); RectLabelCreate(0, "_CZ1_", 0, StringConcatenate("Close", closing percentage, "%"), font, font size, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); ButtonCreate(0, "kn CZ", 0, X + 151, y + 20, 128, 18, StringConcatenate(DoubleToStr(Profit / 100 * closing percentage, 2), AC), font, font size, Color_1, Color_8, Color_7, false); y+= 20; ButtonCreate(0, "kn lot pr", 0, AccountBalance(), 2), "%"), Font, FontSize, Color_1,Color_8, Color_7, false); ButtonCreate(0, "kn lot dn", 0, X + 131, y, 18, 18,CharToStr(218), "Wingdings", 8, Color_1, Color_8, Color_7, false); "kn cz dn", 0, Color_2, Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "5", 0, ButtonCreate(0, "kn Del BuyStop", 0, Font size, Color_5, Color_9, Color_7, false); y+= 30; RectLabelCreate(0, "_6_", 0, X + 151, y,73, 26, Color_2, Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "6", 0, 13,CORNER_LEFT_UPPER, DoubleToStr(sl, 0), font, font size + 0,Color_1, 0, ANCHOR_CENTER, false, false, true, 0); ButtonCreate(0, "kn Del SellLimit", 0, X +225, y, 73, 26, "delete", font, font size,Color_4, Color_9, Color_7, false); ButtonCreate(0, "kn SellLimit", 0, ObjectDelet-is one E("6"); ObjectDelet-is one E("_5_"); ObjectDelet-is one E("_6_"); ObjectDelet-is one E("kn BuyStop"); ObjectDelet-is one E("kn SellLimit"); ObjectDelet-is one E("kn Del BuyStop"); ObjectDelet-is one E("kn Del SellLimit"); } } else y += 42; int W = 26; if (window type > 0) W = 56; ButtonCreate(0, "kn Buy", 0, y, 30, 27, Color_2, Color_7, STYLE_SOLID, 1, false, false, true, 0); RectLabelCreate(0, "_8_", 0, X + 100, y, 50, 27, Color_2,Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "7", 0, CORNER_LEFT_UPPER,DoubleToStr(LB, 2), font, font-size + 0, Color_1, 0, ANCHOR_CENTER,false, false, true, 0); if (WindowType > 0) { ButtonCreate(0, knTrNlB, 0, X + 151, y, 18, 56, "Tracking Lossless B", font, font-size, Color_1, Color_8, Color_7,GlobalVariableCheck(knTrNlB)); ButtonCreate(0, knSlB, 0, X + 170, y, 50, 28,StringConcatenate("Stop Loss", Stop Loss B), Font, Font Size, Color_1, Color_8, Color_7,GlobalVariableCheck(knSlB)); ButtonCreate(0, knTpB, 0, y, 13, 13, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTpB, " up"), 0, Color_8,Color_7, false); y += 15; ButtonCreate(0, StringConcatenate(knSlB, " dn"), 0, " dn"), 0, y, 82, 26,DoubleToStr(ProfitB, 2), font, font size, cl, Color_9, Color_7,false); ButtonCreate(0, knNlB, 0, X + 170, y, 50, 28,StringConcatenate("lossless", losslessB), font, font size, Color_1, Color_8, Color_7,GlobalVariableCheck(knNlB)); ButtonCreate(0, knTsB, 0, StringConcatenate(knNlB, " up"), 0, X +222, y, 13, 13, CharToStr(217),"Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTsB, " up"), 0, ButtonCreate(0, StringConcatenate(knNlB, " dn"), 0, X +222, y, 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; } else y += 31; ButtonCreate(0, "kn Sell", 0, X + 2, y, 66, W, "Sell", font, font size, Color_4, Color_9, Color_7, false); RectLabelCreate(0, "_9_", 0, X + 70, y, 30, 27, Color_2,Color_7, STYLE_SOLID, 1, false, false, true, 0); STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "9", 0, 0, 56, "Tracking Lossless S", Font, Font Size, Color_1, Color_8, Color_7, GlobalVariableCheck(knTrNlS)); ButtonCreate(0, knSlS, 0, X + 170, y, 50, 28, StringConcatenate("Stop Loss", Stop Loss S), Font, Font Size, Color_1, Color_8, Color_7,GlobalVariableCheck(knSlS)); ButtonCreate(0, knTpS, 0, StringConcatenate(knSlS, " up"), 0, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; ButtonCreate(0, StringConcatenate(knSlS, " dn"), 0, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTpS, " dn"), 0, cl = Color_4; ButtonCreate(0, "kn Close Sell", 0, 28,StringConcatenate("Lossless", LosslessS), Font, FontSize, Color_1, Color_8, Color_7,GlobalVariableCheck(knNlS)); ButtonCreate(0, knTsS, 0, X + 235, y, 50, 28, StringConcatenate("Tracking", TrailingStopS), Font, FontSize,Color_1, Color_8, Color_7, GlobalVariableCheck(knTsS)); ButtonCreate(0, StringConcatenate(knNlS, " up"), 0, " up"), 0, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTsS, " dn"), 0, += 15; if (Window type == 2) { RectLabelCreate(0, "_12_", 0, X + 151, y,73, 26, Color_2, Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "11", 0, 13,CORNER_LEFT_UPPER, DoubleToStr(bl, 0),Font,FontSize+0,Color_1, 0, ANCHOR_CENTER, false, false, true, 0); ButtonCreate(0, "kn Del BuyLimit", 0, Color_7, false); ButtonCreate(0, "kn BuyLimit", 0, y,73, 26, Color_2, Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "12", 0, false, true, 0); ButtonCreate(0, "kn Del SellStop", 0, StringConcatenate("Sell stop order", pending order offset), font, font size, Color_4, Color_9, Color_7, false); y += 30; } else { ObjectDelet-one difference of E("11"); ObjectDelet-one difference of E("12"); ObjectDelet-one difference of E("_12_"); ObjectDelet-one difference of E("_13_"); ObjectDelet - one E short ("kn BuyLimit"); ObjectDelet - one E short ("kn SellStop"); ObjectDelet - one E short ("kn Del BuyLimit"); ObjectDelet - one E short ("kn Del SellStop"); } RectLabelCreate(0, "_fon3_", 0, X + 1, y, 298, 40,Color_6, Color_7, STYLE_SOLID, 1, false, false, true, 0); if (Profit > 0) cl = Color_5; elsecl = Color_4; LabelCreate(0, "Profit", 0, 27,CORNER_LEFT_UPPER, StringConcatenate(DoubleToStr(Profit, 2), AC), font, font size, cl, 0, ANCHOR_CENTER, false, false, true, 0); LabelCreate(0, "Equity", 0, X + 150, y + 13,CORNER_LEFT_UPPER, "Equity", font, font size, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); LabelCreate(0, "_Equity", 0, LabelCreate(0, "Balance", 0, DoubleToStr(AccountBalance(), 2), Font, FontSize, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); } else { ObjectDelet-One less than E("kn SellStop"); ObjectDelet-One less than E("kn BuyLimit"); ObjectDelet-One less than E("kn SellLimit"); ObjectDelet-One less than E("kn BuyStop"); ObjectDelet - one E short ("kn Close Sell"); ObjectDelet - one E short ("kn Close Buy"); ObjectDelet - one E short ("kn Del BuyStop"); ObjectDelet - one E short ("kn Del SellLimit"); ObjectDelet - one E short ("kn Del BuyLimit"); ObjectDelet - one E short ("kn Del SellStop"); ObjectDelet - one E(knTrNlB); ObjectDelet-one E(knTrNlS); ObjectDelet-one E(knSlB); ObjectDelet-one E(knTpB); ObjectDelet-one E(knTsB); ObjectDelet-one E(knNlB); ObjectDelet-one E(knSlS); ObjectDelet-is one E(knTpS); ObjectDelet-is one E(knTsS); ObjectDelet-is one E(knNlS); ObjectDelet-is one E("2"); ObjectDelet-is one E("spread"); ObjectDelet-is one E("lot_"); ObjectDelet-is one E("kn lot pr"); ObjectDelet-is one E("kn lot" l"); ObjectDelet - one E short ("kn lot up"); ObjectDelet - one E short ("kn lot dn"); ObjectDelet - one E short ("kn CZ1"); ObjectDelet - one E short ("_CZ1_"); ObjectDelet - one E short ("kn CZ"); ObjectDelet - one E short ("kn cz up"); ObjectDelet - one E short ("kn cz dn"); ObjectDelet-a difference of one E("_fon3_"); ObjectDelet-a difference of an E("Profit"); ObjectDelet-a difference of an E("_Profit"); ObjectDelet-a difference of an E("Equity"); ObjectDelet-a difference of an E("_Equity"); ObjectDelet-a difference of an E("Balance"); ObjectDelet-E("_Balance"); } } //+------------------------------------------------------------------+

Trading Advisor (EA) Overview Source Code Download and Deployment Instructions Source Code Download and Deployment Instructions | Important points before downloading and using foreign exchange EA

This page has been reorganized according to the reading path of search users, focusing on the applicable scenarios of EA source code, MQL4/MQL5 platform compatibility, parameter testing methods and real-time risk warnings, so as to quickly judge whether it is worth continuing to test before downloading or deploying.

Suitable for who to use

  • Traders who need to quickly screen EA source code and are willing to do simulation verification first.
  • People who are already familiar with the MT4/MT5 installation process and want to compare different EAs, indicators or source code projects.
  • People who want to record the backtest, parameters and risk control before deciding whether to enter the real market.

Testing and risk control suggestions

  • First use the default parameters for basic backtesting, and then adjust them one by one according to the variety, cycle and spread.
  • Grid, Martin, and scalping strategies should focus on observing maximum drawdown, continuous losses, and trading frequency.
  • It is recommended to observe the simulated trading performance for at least 2-4 weeks before the actual trading, and limit the account risk proportion of a single strategy.

FAQ

Can this file be sold directly?
It is not recommended to make a direct offer. Any EA or indicator requires first checking the source, parameters, platform version and historical performance.

Can MT4 and MT5 be used interchangeably?
Usually it cannot be used directly. MQ4/EX4 corresponds to MT4, MQ5/EX5 corresponds to MT5, and the source code project also needs to be compiled in the corresponding MetaEditor.

What else can I continue to watch?
Forex EA download , foreign exchange indicator download , EA evaluation , GitHub open source EA , MQL5 CodeBase .

English Search Notes

This page is also optimized for English search intent around Trading Advisor (EA) overview source code download and deployment instructions source code download and deployment instructions | Forex EA download . Related search terms include: MQL4 source code, MQL5 source code. Test any Forex EA, Expert Advisor, MT4/MT5 indicator or MQL source code with historical data and a demo account before live trading.

Verification code Refresh