欢迎访问

交易顾问(EA)概述

author emer | 26 人阅读 | 0 人评论 |

交易顾问(EA)概述 这是一个专为交易设计的智能顾问(EA),具备紧凑的控制面板,包含39个元素,用于管理市价单、挂单及交易参数。EA支持止损、止盈、盈亏平衡和追踪止损功能,所有操作通过按钮控制。面板可自定义颜色并固定在图表任意位置,适用于实时交易和策略测试器。 控制面板布局(从上到下,从左到右) 货币对符号 当前价格(中心显示,右下角显示点差) 专家模式开关(最小化/扩展) 扩展模式:启用挂单功能。 最小化模式:简化面板,节省图表空间。 头寸量设置开关(利息/手数) 开仓价值占存款百分比(显示字段,非按钮) 调整开仓量按钮(两个箭头:增加/减少) 未平仓头寸成交量(百分比显示,与下方按钮联动) 注意:若通过止盈(TP)平仓,则忽略此字段,100%平仓。 全部平仓按钮(按字段7的百分比平仓所有头寸) 调整已平仓量按钮(两个箭头:增加/减少) 挂单管理(部分按钮在最小化模式下隐藏) 买入止损单按钮(高于当前价格) 买入止损单数量字段 删除所有买入止损单按钮 卖出限价单按钮(高于当前价格) 卖出限价单数量字段 删除所有卖出限价单按钮 买入限价单按钮(低于当前价格,显示距当前价点数) 买入限价单数量字段 删除所有买入限价单按钮 卖出止损单按钮(低于当前价格) 卖出止损单数量字段 删除所有卖出止损单按钮 市价单管理 买入按钮(按当前价开仓) 买入头寸数量字段 买入头寸手数字段 关闭所有买入头寸按钮(显示当前利润) 卖出按钮(按当前价开仓) 卖出头寸数量字段 卖出手数字段 关闭所有卖出头寸按钮(显示当前利润) 交易参数设置 止损模式开关(开/关,显示止损点数) 调整止损点数按钮(两个箭头:增加/减少) 追踪止损模式开关(开/关,显示触发点数) 追踪利润值在设置中预定义。 调整追踪止损点数按钮(两个箭头:增加/减少) 止盈模式开关(开/关,显示止盈点数) 调整止盈点数按钮(两个箭头:增加/减少) 盈亏平衡模式开关(开/关,显示触发点数) 调整盈亏平衡点数按钮(两个箭头:增加/减少) 信息显示 固定标签字段(无变量信息) 总盈亏字段(显示该货币对所有头寸的盈亏) cpp //+------------------------------------------------------------------+ //| 交易面板系统.mq4 | //| 版权 © 2023-2025, AI编程zblog | //| http://www.eawalk.com| //+------------------------------------------------------------------+ #propertycopyright "Copyright 2024, eawalk.com" #propertylink "http://eawalk.com" #propertyversion "2.00" #propertystrict #propertydescription "用于手动交易的专家顾问" #propertydescription "协助设置订单并管理交易" //默认参数(未声明为 extern/input 的变量) int 买入止损 = 100, // 买入止损(单位:点) 买入止盈 = 100, // 买入止盈(单位:点) 买入追踪止损 = 33, // 买入追踪止损(单位:点,若为 0 则无追踪,追踪止损是从当前价格到止损的距离) 买入无损 = 2, //买入转为无损(单位:点,若为 0 则不转为无损) 卖出止损 = 100, // 卖出止损(单位:点) 卖出止盈 = 100, // 卖出止盈(单位:点) 卖出追踪止损 = 33, // 卖出追踪止损(单位:点,若为 0 则无追踪,追踪止损是从当前价格到止损的距离) 卖出无损 = 2; //卖出转为无损(单位:点,若为 0 则不转为无损) //输入参数 inputint 追踪步长 = 1, // 追踪止损的步长(单位:点) 追踪起始 = 1; // 追踪止损启动的最小利润(单位:点) externdouble 订单手数 = 0.01; // 订单手数 inputint 滑点容差 = 2; // 滑点容差(单位:点) inputint 挂单偏移 = 50; // 从当前价格到挂单的偏移(单位:点) inputint 止损调整步长 = 1; // 止损调整的步长(单位:点) inputdouble 手数调整系数 = 1.5; // 手数调整的倍率 inputdouble 风险调整步长 = 0; // 风险百分比调整的步长 inputint 平仓百分比步长 = 10; // 平仓百分比调整的步长 inputbool 操作确认 = true; // 是否需要确认操作 externbool 买入无损止损 = true; // 买入止损基于无损级别 externbool 卖出无损止损 = true; // 卖出止损基于无损级别 externint 魔法数字 = -1; // 魔法数字(-1 表示监控所有订单) inputstring 字体 = "Times New Roman"; // 字体 inputint 字体大小 = 10; // 字体大小 externint 窗口类型 = 1; // 窗口类型 externint 颜色主题 = 0; // 颜色主题 inputcolor 颜色1 = clrBlack; // 颜色1 inputcolor 颜色2 = clrWhite; // 颜色2 inputcolor 颜色3 = clrBlue; // 颜色3 inputcolor 颜色4 = clrRed; // 颜色4 inputcolor 颜色5 = clrGreen; // 颜色5 inputcolor 颜色6 = clrLemonChiffon; // 颜色6 inputcolor 颜色7 = clrLightGray; // 颜色7 inputcolor 颜色8 = clrSnow; // 颜色8 inputcolor 颜色9 = clrGray; // 颜色9 externbool 可移动窗口 = true; // 是否允许移动窗口 inputlong X = 0; // 窗口 X 坐标 inputlong Y = 50; // 窗口 Y 坐标 //longUGOL=0; //全局变量 double止损B,止盈B, 追踪止损B, 无损B, 止损S, 止盈S, 追踪止损S, 无损S; stringInpName = "cm-Trade System"; doublebid, 风险 = 1, 平仓百分比 = 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 = 颜色1; Color_2 = 颜色2; Color_3 = 颜色3; Color_4 = 颜色4; Color_5 = 颜色5; Color_6 = 颜色6; Color_7 = 颜色7; Color_8 = 颜色8; Color_9 = 颜色9; break; case 1: Color_1 = clrWhite; Color_2 = clrBlack; Color_3 = 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; Color_1 = clrWhite; Color_3 = clrLime; Color_4 = clrRed; Color_5 = 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_5 = clrLime; Color_6 = clrDarkGray; 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_7 = clrDarkGray; Color_8 = clrSilver; Color_9 = clrBlack; break; } } //+------------------------------------------------------------------+ intOnInit() { _color(颜色主题); 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, 可移动窗口, 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-差一个E(0, InpName); Del(); ObjectDelet-差一个E(0, "kn min"); ObjectDelet-差一个E(0, "kn color"); ObjectDelet-差一个E(0, "Symbol"); ObjectDelet-差一个E(0, "_fon1_"); ObjectDelet-差一个E(0, "_fon2_"); ObjectDelet-差一个E(0, "NoLoss_NLb"); ObjectDelet-差一个E(0, "NoLoss_NLs"); ObjectDelet-差一个E(0, "NoLoss_NL"); EventKillTimer(); } //-------------------------------------------------------------------- voidDel() { ObjectDelet-差一个E(0, "_fon3_"); ObjectDelet-差一个E(0, "_5_"); ObjectDelet-差一个E(0, "_6_"); ObjectDelet-差一个E(0, "_7_"); ObjectDelet-差一个E(0, "_8_"); ObjectDelet-差一个E(0, "_9_"); ObjectDelet-差一个E(0, "_10_"); ObjectDelet-差一个E(0, "_11_"); ObjectDelet-差一个E(0, "_12_"); ObjectDelet-差一个E(0, "_13_"); ObjectDelet-差一个E(0, "_14_"); ObjectDelet-差一个E(0, "_15_"); ObjectDelet-差一个E(0, "_16_"); ObjectDelet-差一个E(0, "_17_"); ObjectDelet-差一个E(0, "2"); ObjectDelet-差一个E(0, "3"); ObjectDelet-差一个E(0, "4"); ObjectDelet-差一个E(0, "5"); ObjectDelet-差一个E(0, "6"); ObjectDelet-差一个E(0, "7"); ObjectDelet-差一个E(0, "8"); ObjectDelet-差一个E(0, "9"); ObjectDelet-差一个E(0, "10"); ObjectDelet-差一个E(0, "11"); ObjectDelet-差一个E(0, "12"); ObjectDelet-差一个E(0, "kn Buy"); ObjectDelet-差一个E(0, "kn Sell"); ObjectDelet-差一个E(0, "kn BuyStop"); ObjectDelet-差一个E(0, "kn SellLimit"); ObjectDelet-差一个E(0, "kn BuyLimit"); ObjectDelet-差一个E(0, "kn SellStop"); ObjectDelet-差一个E(0, "kn Del BuyStop"); ObjectDelet-差一个E(0, "kn Del SellLimit"); ObjectDelet-差一个E(0, "kn Close Buy"); ObjectDelet-差一个E(0, "kn Close Sell"); ObjectDelet-差一个E(0, "kn Del BuyLimit"); ObjectDelet-差一个E(0, "kn Del SellStop"); ObjectDelet-差一个E(0, knTpB); ObjectDelet-差一个E(0, knSlB); ObjectDelet-差一个E(0, knTsB); ObjectDelet-差一个E(0, knNlB); ObjectDelet-差一个E(0, knTpS); ObjectDelet-差一个E(0, knSlS); ObjectDelet-差一个E(0, knTsS); ObjectDelet-差一个E(0, knNlS); ObjectDelet-差一个E(0, knTrNlB); ObjectDelet-差一个E(0, knTrNlS); ObjectDelet-差一个E(0, StringConcatenate(knTpB, " up")); ObjectDelet-差一个E(0, StringConcatenate(knSlB, " up")); ObjectDelet-差一个E(0, StringConcatenate(knTsB, " up")); ObjectDelet-差一个E(0, StringConcatenate(knNlB, " up")); ObjectDelet-差一个E(0, StringConcatenate(knTpS, " up")); ObjectDelet-差一个E(0, StringConcatenate(knSlS, " up")); ObjectDelet-差一个E(0, StringConcatenate(knTsS, " up")); ObjectDelet-差一个E(0, StringConcatenate(knNlS, " up")); ObjectDelet-差一个E(0, StringConcatenate(knTpB, " dn")); ObjectDelet-差一个E(0, StringConcatenate(knSlB, " dn")); ObjectDelet-差一个E(0, StringConcatenate(knTsB, " dn")); ObjectDelet-差一个E(0, StringConcatenate(knNlB, " dn")); ObjectDelet-差一个E(0, StringConcatenate(knTpS, " dn")); ObjectDelet-差一个E(0, StringConcatenate(knSlS, " dn")); ObjectDelet-差一个E(0, StringConcatenate(knTsS, " dn")); ObjectDelet-差一个E(0, StringConcatenate(knNlS, " dn")); ObjectDelet-差一个E(0, "lot_"); ObjectDelet-差一个E(0, "kn lot pr"); ObjectDelet-差一个E(0, "kn lot l"); ObjectDelet-差一个E(0, "kn lot up"); ObjectDelet-差一个E(0, "kn lot dn"); ObjectDelet-差一个E(0, "kn CZ1"); ObjectDelet-差一个E(0, "_CZ1_"); ObjectDelet-差一个E(0, "kn CZ"); ObjectDelet-差一个E(0, "kn cz up"); ObjectDelet-差一个E(0, "kn cz dn"); ObjectDelet-差一个E(0, "spread"); ObjectDelet-差一个E(0, "Profit"); ObjectDelet-差一个E(0, "_Profit"); ObjectDelet-差一个E(0, "Equity"); ObjectDelet-差一个E(0, "_Equity"); ObjectDelet-差一个E(0, "Balance"); ObjectDelet-差一个E(0, "_Balance"); } //-------------------------------------------------------------------- voidOnTick() { OnTimer(); } voidOnTimer() { TRADE = IsTradeAllowed(); if (ObjectGetInteger(0, "kn min", OBJPROP_STATE)) { 窗口类型++; if (窗口类型 > 3) 窗口类型 = 0; Del(); ObjectSetInteger(0, "kn min", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn color", OBJPROP_STATE)) { 颜色主题++; if (颜色主题 > 4) 颜色主题 = 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__, ": 无法创建文本标签!错误代码 = ",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 (操作确认) { string txt; if (tip == OP_BUY) txt = StringConcatenate("打开买入仓位 ",DoubleToStr(lot, 2), " 手,价格 ", DoubleToStr(p,Digits), " ?"); if (tip == OP_SELL) txt = StringConcatenate("打开卖出仓位 ",DoubleToStr(lot, 2), " 手,价格 ", DoubleToStr(p,Digits), " ?"); if (tip == OP_BUYSTOP) txt = StringConcatenate("设置买入止损单 ",DoubleToStr(lot, 2), " 手,价格 ", DoubleToStr(p,Digits), " ?"); if (tip == OP_SELLSTOP) txt = StringConcatenate("设置卖出止损单 ",DoubleToStr(lot, 2), " 手,价格 ", DoubleToStr(p,Digits), " ?"); if (tip == OP_BUYLIMIT) txt = StringConcatenate("设置买入限价单 ",DoubleToStr(lot, 2), " 手,价格 ", DoubleToStr(p,Digits), " ?"); if (tip == OP_SELLLIMIT) txt = StringConcatenate("设置卖出限价单 ",DoubleToStr(lot, 2), " 手,价格 ", 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, 滑点容差, 0, 0, NULL, 魔法数字, 0, clrNONE) == -1) { Print("订单发送错误 ", GetLastError(), " 手数 ", 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; 止损B = Kn(knSlB, 止损B); 止盈B = Kn(knTpB, 止盈B); 无损B = Kn(knNlB, 无损B); 追踪止损B = Kn(knTsB, 追踪止损B); 止损S = Kn(knSlS, 止损S); 止盈S = Kn(knTpS, 止盈S); 无损S = Kn(knNlS, 无损S); 追踪止损S = Kn(knTsS, 追踪止损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() && (魔法数字 == -1 || 魔法数字 == 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 - 止损B * Point, Digits) >= stoplevel && 止损B != 0) { SL =NormalizeDouble(OOP - 止损B * Point, Digits); } if (止损B == 0 && 无损B == 0 && 追踪止损B == 0) SL = 0; if (止盈B == 0) TP = 0; if (!TrNoLossB) { if (OTP == 0 &&NormalizeDouble(OOP + 止盈B * Point, Digits) - Ask >= stoplevel && 止盈B != 0) { TP =NormalizeDouble(OOP + 止盈B * Point, Digits); } if (OSL < OOP&& 无损B!= 0) { if (Bid -OOP >= 无损B* Point && Bid - OOP >= stoplevel) SL = OOP + Point; } if (追踪止损B != 0) { StLo =NormalizeDouble(Bid - 追踪止损B * Point, Digits); if (StLo>= OOP + 追踪起始 * Point && StLo > OSL + 追踪步长 *Point && StLo <= NormalizeDouble(Bid - stoplevel, Digits)) SL =StLo; } } if (TRADE && (SL >OSL || TP != OTP)) { Comment("修改订单 ", Ticket," 买入,止损 ", OSL, "->", SL,", 止盈 ", OTP, "->", TP); if(!OrderModify(Ticket, OOP, SL, TP, 0, White)) Print("订单修改错误 ",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 + 止损S * Point, Digits) - Ask >= stoplevel && 止损S != 0) { SL =NormalizeDouble(OOP + 止损S * Point, Digits); } if (止损S == 0 && 无损S == 0 && 追踪止损S == 0) SL = 0; if (止盈S == 0) TP = 0; if (!TrNoLossS) { if (OTP == 0 &&Bid - NormalizeDouble(OOP - 止盈S * Point, Digits) >= stoplevel && 止盈S != 0) { TP =NormalizeDouble(OOP - 止盈S * Point, Digits); } if ((OSL > OOP ||OSL == 0) && 无损S != 0) { if (OOP -Ask >= 无损S* Point && (OOP < OSL || OSL == 0) && OOP - Ask >=stoplevel) SL = OOP - Point; } if (追踪止损S != 0) { StLo =NormalizeDouble(Ask + 追踪止损S * Point, Digits); if (StLo<= OOP - 追踪起始 * Point && (StLo < OSL - 追踪步长 *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() && (魔法数字 == -1 || 魔法数字 == 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+ 止盈B* Point, Digits) - Ask >= stoplevel && 止盈B!= 0) { TP =NormalizeDouble(NLb + 止盈B * Point, Digits); } if (OSL < OOP&& 无损B!= 0) { if (Bid -NLb >= 无损B* Point && Bid - NLb >= stoplevel) SL = NLb + Point; } if (追踪止损B != 0) { StLo =NormalizeDouble(Bid - 追踪止损B * Point, Digits); if (StLo>= NLb + 追踪起始 * Point && StLo > OSL + 追踪步长 *Point && StLo <= NormalizeDouble(Bid - stoplevel, Digits)) SL =StLo; } if (TRADE &&(SL > OSL || TP != OTP)) { Comment("从无损级别修改订单 ",Ticket, " 买入 止损 ", OSL, "->",SL, ", 止盈 ", OTP, "->", TP); if(!OrderModify(Ticket, OOP, SL, TP, 0, White)) Print("订单修改错误 ",GetLastError()); } } if (tip == OP_SELL &&TrNoLossS) { if (Bid -NormalizeDouble(NLs - 止盈S * Point, Digits) >= stoplevel && 止盈S != 0) { TP =NormalizeDouble(NLs - 止盈S * Point, Digits); } if ((OSL > NLs ||OSL == 0) && 无损S != 0) { if (NLs -Ask >= 无损S* Point && (NLs < OSL || OSL == 0) && NLs - Ask >=stoplevel) SL = NLs - Point; } if (追踪止损S != 0) { StLo =NormalizeDouble(Ask + 追踪止损S * Point, Digits); if (StLo<= NLs - 追踪起始 * Point && (StLo < OSL - 追踪步长 *Point || OSL == 0) && StLo >= NormalizeDouble(Ask + stoplevel,Digits)) SL = StLo; } if (TRADE &&((SL < OSL || (OSL == 0 && SL != 0)) || TP != OTP)) { Comment("从无损级别修改订单 ", Ticket, " 卖出 止损 ", OSL,"->", SL, ", 止盈 ", OTP,"->", TP); if(!OrderModify(Ticket, OOP, SL, TP, 0, White)) Print("订单修改错误 ",GetLastError()); } } } } } } Redr(LB, LS, ProfitB, ProfitS, bs, ss, b, s, sl, bl); return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ boolclose(int tip) { if (操作确认) { string txt = "关闭所有仓位 "; if (tip == OP_BUY) txt = StringConcatenate(txt, "买入 ?"); if (tip == OP_SELL) txt = StringConcatenate(txt, "卖出 ?"); 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() && (魔法数字 == -1 || 魔法数字 == 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("错误 ", err, " 关闭订单号 ", OrderTicket(), " ",TimeToStr(TimeCurrent(), TIME_SECONDS)); } } } } int n = 0; for (j = 0; j < OrdersTotal(); j++) { if (OrderSelect(j, SELECT_BY_POS)) { if (OrderSymbol() == Symbol() && (魔法数字 == -1 || 魔法数字 == 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 (操作确认) { string txt = "删除挂单 "; if (tip == OP_BUYSTOP) txt = StringConcatenate(txt, "买入止损单 ?"); if (tip == OP_SELLSTOP) txt = StringConcatenate(txt, "卖出止损单 ?"); if (tip == OP_BUYLIMIT) txt = StringConcatenate(txt, "买入限价单 ?"); if (tip == OP_SELLLIMIT) txt = StringConcatenate(txt, "卖出限价单 ?"); 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() && (魔法数字 == -1 || 魔法数字 == 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, 订单手数, NormalizeDouble(Ask, Digits))) ObjectSetInteger(0,"kn Buy", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Sell", OBJPROP_STATE)) { if (SendOrder(OP_SELL, 订单手数,NormalizeDouble(Bid, Digits))) ObjectSetInteger(0, "kn Sell",OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn BuyStop", OBJPROP_STATE)) { if (SendOrder(OP_BUYSTOP, 订单手数,NormalizeDouble(Ask + 挂单偏移 * Point, Digits)))ObjectSetInteger(0, "kn BuyStop", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn SellLimit", OBJPROP_STATE)) { if (SendOrder(OP_SELLLIMIT, 订单手数,NormalizeDouble(Ask + 挂单偏移 * Point, Digits)))ObjectSetInteger(0, "kn SellLimit", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn BuyLimit", OBJPROP_STATE)) { if (SendOrder(OP_BUYLIMIT, 订单手数,NormalizeDouble(Bid - 挂单偏移 * Point, Digits)))ObjectSetInteger(0, "kn BuyLimit", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn SellStop", OBJPROP_STATE)) { if (SendOrder(OP_SELLSTOP, 订单手数,NormalizeDouble(Bid - 挂单偏移 * 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-差一个E(OP_BUYSTOP); ObjectSetInteger(0, "kn DelBuyStop", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Del SellLimit",OBJPROP_STATE)) { Delet-差一个E(OP_SELLLIMIT); ObjectSetInteger(0, "kn DelSellLimit", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Del BuyLimit",OBJPROP_STATE)) { Delet-差一个E(OP_BUYLIMIT); ObjectSetInteger(0, "kn DelBuyLimit", OBJPROP_STATE, false); } if (ObjectGetInteger(0, "kn Del 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)) 订单手数 *= 手数调整系数; else { 风险 += 风险调整步长; 订单手数 =AccountBalance() * 风险 / 100 / MarketInfo(Symbol(),MODE_MARGINREQUIRED); } ObjectSetInteger(0, "kn lot up", OBJPROP_STATE, false); if (订单手数 > MarketInfo(Symbol(), MODE_MAXLOT)) 订单手数 = MarketInfo(Symbol(), MODE_MAXLOT); } if (ObjectGetInteger(0, "kn lot dn", OBJPROP_STATE)) { PlaySound("Ok.wav"); if (ObjectGetInteger(0, "kn lot l", OBJPROP_STATE)) 订单手数 /= 手数调整系数; else { 风险 -= 风险调整步长; 订单手数 =AccountBalance() * 风险 / 100 / MarketInfo(Symbol(), MODE_MARGINREQUIRED);} ObjectSetInteger(0, "kn lot dn", OBJPROP_STATE, false); if (订单手数 < MarketInfo(Symbol(), MODE_MINLOT)) 订单手数 = MarketInfo(Symbol(), MODE_MINLOT); } if (ObjectGetInteger(0, "kn cz up", OBJPROP_STATE)) { PlaySound("Ok.wav"); 平仓百分比 += 平仓百分比步长; ObjectSetInteger(0, "kn cz up", OBJPROP_STATE, false); if (平仓百分比 > 100) 平仓百分比 = 100; } if (ObjectGetInteger(0, "kn cz dn", OBJPROP_STATE)) { PlaySound("Ok.wav"); 平仓百分比 -= 平仓百分比步长; ObjectSetInteger(0, "kn cz dn", OBJPROP_STATE, false); if (平仓百分比 < 0) 平仓百分比 = 0; } kn_UP_DN(knSlB, 止损B); kn_UP_DN(knTpB, 止盈B); kn_UP_DN(knTsB, 追踪止损B); kn_UP_DN(knNlB, 无损B); kn_UP_DN(knSlS, 止损S); kn_UP_DN(knTpS, 止盈S); kn_UP_DN(knTsS, 追踪止损S); kn_UP_DN(knNlS, 无损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 += 止损调整步长; 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 -= 止损调整步长; if (Par <= 0) GlobalVariableDel(StringConcatenate(name, "PIPS")); else { GlobalVariableSet(StringConcatenate(name, "PIPS"), Par); } ObjectSetInteger(0, StringConcatenate(name, " dn"),OBJPROP_STATE, false); } } //-------------------------------------------------------------------- boolcloseCZ() { if (操作确认) { int ret = MessageBox(StringConcatenate("关闭 ", 平仓百分比, "% 的所有仓位 ?"), "",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() && (魔法数字 == -1 || 魔法数字 == OrderMagicNumber())) { OT = OrderType(); if (OT > 1) continue; if (OT == OP_BUY) { error =OrderClose(OrderTicket(), NormalizeDouble(OrderLots() / 100 * 平仓百分比, 2),NormalizeDouble(Bid, Digits), 3, Blue); } if (OT == OP_SELL) { error =OrderClose(OrderTicket(), NormalizeDouble(OrderLots() / 100 * 平仓百分比, 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, " 请设置大于止损级别的值"); 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"))) 止损B = GlobalVariableGet(StringConcatenate(knSlB, " PIPS")); else 止损B = 买入止损; if (GlobalVariableCheck(StringConcatenate(knTpB, " PIPS"))) 止盈B = GlobalVariableGet(StringConcatenate(knTpB, " PIPS")); else 止盈B = 买入止盈; if (GlobalVariableCheck(StringConcatenate(knTsB, " PIPS"))) 追踪止损B =GlobalVariableGet(StringConcatenate(knTsB, " PIPS")); else 追踪止损B = 买入追踪止损; if (GlobalVariableCheck(StringConcatenate(knNlB, " PIPS"))) 无损B = GlobalVariableGet(StringConcatenate(knNlB, " PIPS")); else 无损B = 买入无损; if (GlobalVariableCheck(StringConcatenate(knSlS, " PIPS"))) 止损S = GlobalVariableGet(StringConcatenate(knSlS, " PIPS")); else 止损S = 卖出止损; if (GlobalVariableCheck(StringConcatenate(knTpS, " PIPS"))) 止盈S = GlobalVariableGet(StringConcatenate(knTpS, " PIPS")); else 止盈S = 卖出止盈; if (GlobalVariableCheck(StringConcatenate(knTsS, " PIPS"))) 追踪止损S =GlobalVariableGet(StringConcatenate(knTsS, " PIPS")); else 追踪止损S = 卖出追踪止损; if (GlobalVariableCheck(StringConcatenate(knNlS, " PIPS"))) 无损S = GlobalVariableGet(StringConcatenate(knNlS, " PIPS")); else 无损S = 卖出无损; } //-------------------------------------------------------------------- voidRedr(double LB, double LS, double ProfitB, double ProfitS, int bs, int ss, intb, int s, int sl, int bl) { color cl; _color(颜色主题); double Profit = ProfitB + ProfitS; if (ObjectFind(InpName) == 0) { if (窗口类型 == 0) { RectLabelCreate(0, InpName, 0, X, Y, 152, 140,Color_2, Color_1, STYLE_SOLID, 3, false, false, false, 0); Del(); } else { if (窗口类型 == 1) RectLabelCreate(0, InpName, 0, X, Y, 300, 240,Color_2, Color_2, STYLE_SOLID, 3, false, true, true, 1); if (窗口类型 == 2) RectLabelCreate(0, InpName, 0, X, Y, 300, 360,Color_2, Color_2, STYLE_SOLID, 3, false, true, true, 1); if (窗口类型 == 3) RectLabelCreate(0, InpName, 0, X, Y, 300, 360,Color_2, Color_2, STYLE_SOLID, 3, false, true, true, 1); } } long y = Y; RectLabelCreate(0, "_fon1_", 0, X, y, 150, 40, Color_6,Color_7, STYLE_SOLID, 1, false, false, true, 0); if (窗口类型 > 0) RectLabelCreate(0, "_fon2_", 0, X + 150, y, 150,40, Color_6, Color_7, STYLE_SOLID, 1, false, false, true, 0); else ObjectDelet-差一个E("_fon2_"); ButtonCreate(0, "kn min", 0, X + 2, y + 2, 18, 18,CharToStr(244), "Wingdings", 字体大小, Color_1, Color_8, Color_7, false); ButtonCreate(0, "kn color", 0, X + 2, y + 20, 18, 18,CharToStr(83), "Wingdings", 字体大小, Color_1, Color_8, Color_7, false); LabelCreate(0, "Symbol", 0, X + 80, y + 20, CORNER_LEFT_UPPER,Symbol(), 字体,字体大小 + 4, Color_1, 0, ANCHOR_CENTER, false, false,true, 0); if (窗口类型 > 0) { GV(); if (bid > NormalizeDouble(Bid, Digits)) cl = Color_4; else cl= Color_3; bid = NormalizeDouble(Bid, Digits); LabelCreate(0, "2", 0, X + 225, y + 20,CORNER_LEFT_UPPER, DoubleToStr(Bid, Digits), 字体, 字体大小 + 4,cl, 0, ANCHOR_CENTER, false, false, true, 0); LabelCreate(0, "spread", 0, X + 285, y + 32,CORNER_LEFT_UPPER, DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD), 0), 字体, 字体大小 - 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(订单手数, 2), " 手"), 字体, 字体大小, 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, X + 151, y, 128, 18,Color_2, Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "kn CZ1", 0, X + 220, y + 9,CORNER_LEFT_UPPER, StringConcatenate("关闭 ", 平仓百分比,"%"), 字体, 字体大小,Color_1, 0, ANCHOR_CENTER, false, false, true, 0); ButtonCreate(0, "kn CZ", 0, X + 151, y + 20, 128, 18,StringConcatenate(DoubleToStr(Profit / 100 * 平仓百分比, 2), AC), 字体, 字体大小, Color_1, Color_8, Color_7, false); y+= 20; ButtonCreate(0, "kn lot pr", 0, X + 2, y, 130, 18, StringConcatenate(DoubleToStr(订单手数 * 100 *MarketInfo(Symbol(), MODE_MARGINREQUIRED) / AccountBalance(), 2), "%"), 字体, 字体大小, 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); ButtonCreate(0, "kn cz dn", 0, X + 281, y, 18, 18,CharToStr(218), "Wingdings", 8, Color_1, Color_8, Color_7, false); y+= 22; if (窗口类型 == 2) { RectLabelCreate(0, "_5_", 0, X + 151, y,73, 26, Color_2, Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "5", 0, X + 185, y + 13,CORNER_LEFT_UPPER, DoubleToStr(bs, 0), 字体, 字体大小 + 0,Color_1, 0, ANCHOR_CENTER, false, false, true, 0); ButtonCreate(0, "kn Del BuyStop", 0, X +225, y, 73, 26, "删除", 字体, 字体大小,Color_5, Color_9, Color_7, false); ButtonCreate(0, "kn BuyStop", 0, X + 1, y,148, 26, StringConcatenate("买入止损单 ", 挂单偏移), 字体, 字体大小, 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, X + 185, y + 13,CORNER_LEFT_UPPER, DoubleToStr(sl, 0), 字体, 字体大小 + 0,Color_1, 0, ANCHOR_CENTER, false, false, true, 0); ButtonCreate(0, "kn Del SellLimit", 0, X +225, y, 73, 26, "删除", 字体, 字体大小,Color_4, Color_9, Color_7, false); ButtonCreate(0, "kn SellLimit", 0, X + 1,y, 148, 26, StringConcatenate("卖出限价单 ", 挂单偏移), 字体, 字体大小,Color_4, Color_9, Color_7, false); y += 30; } else { ObjectDelet-差一个E("5"); ObjectDelet-差一个E("6"); ObjectDelet-差一个E("_5_"); ObjectDelet-差一个E("_6_"); ObjectDelet-差一个E("kn BuyStop"); ObjectDelet-差一个E("kn SellLimit"); ObjectDelet-差一个E("kn Del BuyStop"); ObjectDelet-差一个E("kn Del SellLimit"); } } else y += 42; int W = 26; if (窗口类型 > 0) W = 56; ButtonCreate(0, "kn Buy", 0, X + 2, y, 66, W, "买入", 字体, 字体大小, Color_5, Color_9, Color_7, false); RectLabelCreate(0, "_7_", 0, X + 70, 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, X + 85, y + 13, CORNER_LEFT_UPPER,DoubleToStr(b, 0), 字体, 字体大小 + 0, Color_1, 0, ANCHOR_CENTER,false, false, true, 0); LabelCreate(0, "8", 0, X + 125, y + 13, CORNER_LEFT_UPPER,DoubleToStr(LB, 2), 字体, 字体大小 + 0, Color_1, 0, ANCHOR_CENTER,false, false, true, 0); if (窗口类型 > 0) { ButtonCreate(0, knTrNlB, 0, X + 151, y, 18, 56, "追踪无损B", 字体, 字体大小, Color_1, Color_8, Color_7,GlobalVariableCheck(knTrNlB)); ButtonCreate(0, knSlB, 0, X + 170, y, 50, 28,StringConcatenate("止损 ", 止损B), 字体, 字体大小, Color_1, Color_8, Color_7,GlobalVariableCheck(knSlB)); ButtonCreate(0, knTpB, 0, X + 235, y, 50, 28, StringConcatenate("止盈 ", 止盈B), 字体, 字体大小,Color_1, Color_8, Color_7, GlobalVariableCheck(knTpB)); ButtonCreate(0, StringConcatenate(knSlB, " up"), 0, X +222, y, 13, 13, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTpB, " up"), 0, X +285, y, 13, 13, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; ButtonCreate(0, StringConcatenate(knSlB, " dn"), 0, X +222, y, 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTpB, " dn"), 0, X +285, y, 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; if (ProfitB > 0) cl = Color_5; else cl = Color_4; ButtonCreate(0, "kn Close Buy", 0, X + 68, y, 82, 26,DoubleToStr(ProfitB, 2), 字体, 字体大小, cl, Color_9, Color_7,false); ButtonCreate(0, knNlB, 0, X + 170, y, 50, 28,StringConcatenate("无损 ", 无损B), 字体, 字体大小, Color_1, Color_8, Color_7,GlobalVariableCheck(knNlB)); ButtonCreate(0, knTsB, 0, X + 235, y, 50, 28,StringConcatenate("追踪 ", 追踪止损B), 字体, 字体大小, Color_1, Color_8, Color_7,GlobalVariableCheck(knTsB)); ButtonCreate(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, X +285, y, 13, 13, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; ButtonCreate(0, StringConcatenate(knNlB, " dn"), 0, X +222, y, 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTsB, " dn"), 0, X +285, y, 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, "卖出", 字体, 字体大小, 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); RectLabelCreate(0, "_10_", 0, X + 100, y, 50, 27, Color_2,Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "9", 0, X + 85, y + 13, CORNER_LEFT_UPPER,DoubleToStr(s, 0), 字体, 字体大小 + 0, Color_1, 0, ANCHOR_CENTER,false, false, true, 0); LabelCreate(0, "10", 0, X + 125, y + 13, CORNER_LEFT_UPPER,DoubleToStr(LS, 2), 字体, 字体大小 + 0, Color_1, 0, ANCHOR_CENTER,false, false, true, 0); if (窗口类型 > 0) { ButtonCreate(0, knTrNlS, 0, X + 151, y, 18, 56, "追踪无损S", 字体, 字体大小, Color_1, Color_8, Color_7,GlobalVariableCheck(knTrNlS)); ButtonCreate(0, knSlS, 0, X + 170, y, 50, 28,StringConcatenate("止损 ", 止损S), 字体, 字体大小, Color_1, Color_8, Color_7,GlobalVariableCheck(knSlS)); ButtonCreate(0, knTpS, 0, X + 235, y, 50, 28,StringConcatenate("止盈 ", 止盈S), 字体, 字体大小, Color_1, Color_8, Color_7,GlobalVariableCheck(knTpS)); ButtonCreate(0, StringConcatenate(knSlS, " up"), 0, X +222, y, 13, 13, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTpS, " up"), 0, X +285, y, 13, 13, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; ButtonCreate(0, StringConcatenate(knSlS, " dn"), 0, X +222, y, 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTpS, " dn"), 0, X +285, y, 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; if (ProfitS > 0) cl = Color_5; else cl = Color_4; ButtonCreate(0, "kn Close Sell", 0, X + 68, y, 82, 26,DoubleToStr(ProfitS, 2), 字体, 字体大小, cl, Color_9, Color_7,false); ButtonCreate(0, knNlS, 0, X + 170, y, 50, 28,StringConcatenate("无损 ", 无损S), 字体, 字体大小, Color_1, Color_8, Color_7,GlobalVariableCheck(knNlS)); ButtonCreate(0, knTsS, 0, X + 235, y, 50, 28, StringConcatenate("追踪 ", 追踪止损S), 字体, 字体大小,Color_1, Color_8, Color_7, GlobalVariableCheck(knTsS)); ButtonCreate(0, StringConcatenate(knNlS, " up"), 0, X +222, y, 13, 13, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTsS, " up"), 0, X +285, y, 13, 13, CharToStr(217), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; ButtonCreate(0, StringConcatenate(knNlS, " dn"), 0, X +222, y, 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); ButtonCreate(0, StringConcatenate(knTsS, " dn"), 0, X +285, y, 13, 13, CharToStr(218), "Wingdings", 5, Color_1, Color_8,Color_7, false); y += 15; if (窗口类型 == 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, X + 185, y + 13,CORNER_LEFT_UPPER, DoubleToStr(bl, 0), 字体, 字体大小 + 0,Color_1, 0, ANCHOR_CENTER, false, false, true, 0); ButtonCreate(0, "kn Del BuyLimit", 0, X +225, y, 73, 26, "删除", 字体, 字体大小,Color_5, Color_9, Color_7, false); ButtonCreate(0, "kn BuyLimit", 0, X + 1,y, 148, 26, StringConcatenate("买入限价单 ", 挂单偏移), 字体, 字体大小,Color_5, Color_9, Color_7, false); y += 30; RectLabelCreate(0, "_13_", 0, X + 151, y,73, 26, Color_2, Color_7, STYLE_SOLID, 1, false, false, true, 0); LabelCreate(0, "12", 0, X + 185, y + 13,CORNER_LEFT_UPPER, DoubleToStr(ss, 0), 字体, 字体大小 + 0,Color_1, 0, ANCHOR_CENTER, false, false, true, 0); ButtonCreate(0, "kn Del SellStop", 0, X +225, y, 73, 26, "删除", 字体, 字体大小,Color_4, Color_9, Color_7, false); ButtonCreate(0, "kn SellStop", 0, X + 1,y, 148, 26, StringConcatenate("卖出止损单 ", 挂单偏移), 字体, 字体大小,Color_4, Color_9, Color_7, false); y += 30; } else { ObjectDelet-差一个E("11"); ObjectDelet-差一个E("12"); ObjectDelet-差一个E("_12_"); ObjectDelet-差一个E("_13_"); ObjectDelet-差一个E("kn BuyLimit"); ObjectDelet-差一个E("kn SellStop"); ObjectDelet-差一个E("kn Del BuyLimit"); ObjectDelet-差一个E("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; else cl = Color_4; LabelCreate(0, "Profit", 0, X + 50, y + 13,CORNER_LEFT_UPPER, "利润", 字体, 字体大小, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); LabelCreate(0, "_Profit", 0, X + 50, y + 27,CORNER_LEFT_UPPER, StringConcatenate(DoubleToStr(Profit, 2), AC), 字体, 字体大小, cl, 0, ANCHOR_CENTER, false, false, true, 0); LabelCreate(0, "Equity", 0, X + 150, y + 13,CORNER_LEFT_UPPER, "净值", 字体, 字体大小, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); LabelCreate(0, "_Equity", 0, X + 150, y + 27,CORNER_LEFT_UPPER, DoubleToStr(AccountEquity(), 2), 字体, 字体大小, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); LabelCreate(0, "Balance", 0, X + 250, y + 13,CORNER_LEFT_UPPER, "余额", 字体, 字体大小, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); LabelCreate(0, "_Balance", 0, X + 250, y + 27,CORNER_LEFT_UPPER, DoubleToStr(AccountBalance(), 2), 字体, 字体大小, Color_1, 0, ANCHOR_CENTER, false, false, true, 0); } else { ObjectDelet-差一个E("kn SellStop"); ObjectDelet-差一个E("kn BuyLimit"); ObjectDelet-差一个E("kn SellLimit"); ObjectDelet-差一个E("kn BuyStop"); ObjectDelet-差一个E("kn Close Sell"); ObjectDelet-差一个E("kn Close Buy"); ObjectDelet-差一个E("kn Del BuyStop"); ObjectDelet-差一个E("kn Del SellLimit"); ObjectDelet-差一个E("kn Del BuyLimit"); ObjectDelet-差一个E("kn Del SellStop"); ObjectDelet-差一个E(knTrNlB); ObjectDelet-差一个E(knTrNlS); ObjectDelet-差一个E(knSlB); ObjectDelet-差一个E(knTpB); ObjectDelet-差一个E(knTsB); ObjectDelet-差一个E(knNlB); ObjectDelet-差一个E(knSlS); ObjectDelet-差一个E(knTpS); ObjectDelet-差一个E(knTsS); ObjectDelet-差一个E(knNlS); ObjectDelet-差一个E("2"); ObjectDelet-差一个E("spread"); ObjectDelet-差一个E("lot_"); ObjectDelet-差一个E("kn lot pr"); ObjectDelet-差一个E("kn lot l"); ObjectDelet-差一个E("kn lot up"); ObjectDelet-差一个E("kn lot dn"); ObjectDelet-差一个E("kn CZ1"); ObjectDelet-差一个E("_CZ1_"); ObjectDelet-差一个E("kn CZ"); ObjectDelet-差一个E("kn cz up"); ObjectDelet-差一个E("kn cz dn"); ObjectDelet-差一个E("_fon3_"); ObjectDelet-差一个E("Profit"); ObjectDelet-差一个E("_Profit"); ObjectDelet-差一个E("Equity"); ObjectDelet-差一个E("_Equity"); ObjectDelet-差一个E("Balance"); ObjectDelet-差一个E("_Balance"); } } //+------------------------------------------------------------------+

还没有人打赏,支持一下