任何菜鸟问题,为了不给论坛添乱。专业人士,不要路过。没有你就无处可去 - 6. - 页 1139 1...113211331134113511361137113811391140114111421143114411451146...1178 新评论 Mist13 2017.03.26 23:51 #11381 kuznat399: 是否有适用于安卓的机器人? Metatrader的移动版中 没有自动交易,在可预见的未来也不太可能出现。如果你想从你的手机上控制机器人,你需要一个VPS,它将托管有机器人的终端,+手机上的远程访问软件。 Aleksey Alin 2017.03.27 14:15 #11382 你能告诉我在测试者(Build 1065)中没有显示可视化吗--这能被修复吗? sober 2017.03.27 14:31 #11383 我在MT5中打开10个货币对的周线图,800兆的tick历史 被加载到终端。虽然图表上几乎没有变化,但它一直在加载。问题是,如果我只使用周线图,为什么我需要刻度历史?顺便说一下,在MT4上,周线图是即时打开的,没有延迟。 Taras Slobodyanik 2017.03.27 14:34 #11384 sober: 我在MT5中打开十个货币对的周线图,终端加载了800兆的tick历史。它不断地被加载,尽管图表上几乎没有变化。问题是,如果我只使用周线图,为什么我需要刻度历史?顺便说一下,在MT4上,周线图是立即打开的,没有任何延迟。 这是mt5的一个特点--在m1上加载所有的东西,然后建立所需的时期.......因此,每一次,对于每个符号 mr-vasyu 2017.04.02 12:20 #11385 MT5有两个插件块(信号和下单块以及追踪块)。我是在MQL5中拍摄的。我已经把 "MQL5Include\Expert\Signal "和 "MQL5\Include\Expert "文件放好了。我在请求帮助。 ValerVL35 2017.04.03 08:53 #11386 EA的理念是在价格触及水平线或手动绘制的趋势线时买入或卖出。我把不同的工作EA和指标做成了一个EA。但是,该EA并不工作。或者说,它只打开了卖出,而在第一个勾股上没有任何信号。有什么问题吗?/+------------------------------------------------------------------+//| |//| Copyright © 2010, MetaQuotes Software Corp.//| http://www.mql4.com/ru/users/rustein |//+------------------------------------------------------------------+#define MAGIC 131313 //打开内向通道//---------------------------------------外部inttern TF=15。//+------------------------------------------------------------------+外来的int StopLoss = 300;//--------------------------------------------外部双倍TakeProfit = 3000。//--------------------------------------外置 int Per_MA= 20;//---- 常数#define OP_BUY_ 0#define OP_SELL_ 1//-------------------------------------------------------------------+外置双Lots = 0.1。外置双倍最大风险 = 1;外置双倍的DecreaseFactor = 0;bool b_1=true, s_1=true。//+------------------------------------------------------------------+//|计算未结头寸|//+------------------------------------------------------------------+double MA=iMA(NULL,TF,Per_MA,0,0,0,1)。int CalculateCurrentOrders(string symbol){int buys=0,sells=0。//----for(int i=0;i<OrdersTotal();i++){如果(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;如果(OrderSymbol()==Symbol() && OrderMagicNumber() ==MAGIC){如果(OrderType()==OP_BUY) buys++;如果(OrderType()==OP_SELL) sells++;}}//---- 退货订单量if(buys>0) return(buys)。否则返回(-sells)。}//+------------------------------------------------------------------+//|计算最佳手数|//+------------------------------------------------------------------+double LotsOptimized(){double lot=Lots。int orders=HistoryTotal(); // 历史订单总数int losses=0; // 亏损订单的数量,没有休息时间//---- 选择地段大小//lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,2)。lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/100/MarketInfo(Symbol(),MODE_TICKVALUE)/StopLoss,2) 。//----,计算无休止的损失订单的数量如果(DecreaseFactor>0){for(int i=orders-1;i>=0;i--){if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("历史中的错误!"); break; }如果(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) 继续。//----如果(OrderProfit()>0),则休息。if(OrderProfit()<0) losses++;}如果(损失>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,2)。}//----,返回地段大小如果(lot<0.01)lot=0.01。return(lot)。}//-------------------------------------------------/*这部分来自指标int CheckBreakoutLines(int shift){// 对象总数int obj_total = ObjectsTotal()。// 酒吧的时间datetime now = Time[shift];// 迭代for(int i = obj_total - 1; i >= 0; i--){// 对象名称string label = ObjectName(i);// 类型int OType = ObjectType(label)。bool trendline = false。bool hline = false。// 要评估的价格double cprice = 0;// 趋势线如果(OType == OBJ_TREND ){bool ray = ObjectGet(label, OBJPROP_RAY);if(!ray){datetime x1 = ObjectGet(label, OBJPROP_TIME1);datetime x2 = ObjectGet(label, OBJPROP_TIME2);if(x1 < now && x2 < now) 继续。}cprice = GetCurrentPriceOfLine(label, shift)。trendline = true。}else if(OType == OBJ_HLINE ) {cprice = ObjectGet(label, OBJPROP_PRICE1)。hline = true。}否则 {继续。}// 趋势线和h线的突破和假突破如果(MA>cprice &&Ask<cprice){如果(趋势线) { 返回(OP_BUY_); }else if(hline) { return(OP_BUY_); }}否则如果(MA>cprice &&Ask<cprice) {如果(趋势线) { 返回(OP_SELL_); }else if(hline) { return(OP_SELL_); }}}return(EMPTY_VALUE)。}double GetCurrentPriceOfLine(string label, int shift){double price1 = ObjectGet(label, OBJPROP_PRICE1);double price2 = ObjectGet(label, OBJPROP_PRICE2);datetime d1 = ObjectGet(label, OBJPROP_TIME1);datetime d2 = ObjectGet(label, OBJPROP_TIME2);int shiftfrom = iBarShift(Symbol(), 0, d1, false)。int shiftto = iBarShift(Symbol(), 0, d2, false)。int lapse = MathAbs(shiftto - shiftfrom)。int distance = MathAbs(shift - shiftfrom);double pendiente = (price2 - price1) / lapse;double cpoint = price1 + (distance * pendiente);return(cpoint)。}//-------------------------------------------------------------------------------------------------------------//+------------------------------------------------------------------+//| 检查未结订单的情况 |//+------------------------------------------------------------------+空白的CheckForOpen()。{int res;//--------------------------------------------------------------------+//--------------------------------------------------------------------+//---- 购买条件如果(OP_BUY_&&b_1){res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask-(StopLoss*Point),Ask+TakeProfit*Point," VV",MAGIC,0,Green) 。b_1=false; s_1=true。返回。}//---- 卖出条件如果(OP_SELL_&&s_1){res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Bid+(StopLoss*Point),Bid-TakeProfit*Point," VV",MAGIC,0,Red)。s_1=false;b_1=true。返回。}//----}//+------------------------------------------------------------------+//| 启动功能|//+------------------------------------------------------------------+空白启动()。{//---- 检查历史和交易情况如果(Bars<100 || IsTradeAllowed()==false) 返回。//---- 按当前符号计算未结订单如果(CalculateCurrentOrders(Symbol())==0) CheckForOpen()。}//+------------------------------------------------------------------+//|---------------------------// END //------------------------------|//+------------------------------------------------------------------+ Warstein www.mql5.com Профиль трейдера Any rookie question, so [存档!]我将免费写一份顾问报告 初学者的问题 MQL4 MT4 MetaTrader [删除] 2017.04.04 05:41 #11387 ValerVL35:EA的理念是在价格触及水平线或手动绘制的趋势线时买入或卖出。我把不同的工作EA和指标做成了一个EA。但是,该EA并不工作。或者说,它只打开了卖出,而在第一个勾股上没有任何信号。有什么问题吗?/+------------------------------------------------------------------+//| |//| Copyright © 2010, MetaQuotes Software Corp.//| http://www.mql4.com/ru/users/rustein |//+------------------------------------------------------------------+#define MAGIC 131313 //打开内向通道//---------------------------------------外部inttern TF=15。//+------------------------------------------------------------------+外来的int StopLoss = 300;//--------------------------------------------外部双倍TakeProfit = 3000。//--------------------------------------外置 int Per_MA= 20;//---- 常数#define OP_BUY_ 0#define OP_SELL_ 1.......................................................................... //---- 检查历史和交易情况如果(Bars<100 || IsTradeAllowed()==false) 返回。//---- 按当前符号计算未结订单如果(CalculateCurrentOrders(Symbol())==0) CheckForOpen();}//+------------------------------------------------------------------+//|---------------------------// END //------------------------------|//+------------------------------------------------------------------+将程序加载到记事本中,删除了空行。一目了然的覆盖成为可能。按了SRC按钮并粘贴了。以下是出现的情况。1) 为什么你需要定义 #define OP_BUY_ 0 #define OP_SELL_ 1 如果我们已经有了OP_BUY=0和OP_SELL=12)所有邪恶的根源就在这个片段中。一个相同的条件(MA>cprice &&Ask<cprice)被检查了两次,并采取了不同的决定。 // Breakouts and false breakouts of trendlines and hlines if(MA>cprice &&Ask<cprice) { if(trendline) { return(OP_BUY_); } else if(hline) { return(OP_BUY_); } } else if (MA>cprice &&Ask<cprice) { if(trendline) { return(OP_SELL_); } else if(hline) { return(OP_SELL_); } }3) 之后,每个分支都进行检查,但结果仍然是一样的。if(trendline) { return(OP_BUY_); } else if(hline) { return(OP_BUY_); }if(trendline) { return(OP_SELL_); } else if(hline) { return(OP_SELL_); } 一般来说,上面这句话可以简化,写成以下内容 if(trendline)return OP_BUY; if(hline) return OP_BUY; или еще проще if(trendline or hline) return OP_BUY; //+------------------------------------------------------------------+ //| Copyright © 2010, MetaQuotes Software Corp. | //| http://www.mql4.com/ru/users/rustein | //+------------------------------------------------------------------+ #define MAGIC 131313 // открытие внутрь канала //--------------------------------------- extern int TF=15; extern int StopLoss = 300; extern double TakeProfit = 3000; extern int Per_MA= 20; extern double Lots = 0.1; extern double MaximumRisk = 1; extern double DecreaseFactor = 0; //---- constants #define OP_BUY_ 0 #define OP_SELL_ 1 bool b_1=true, s_1=true; //+------------------------------------------------------------------+ //| Calculate open positions | //+------------------------------------------------------------------+ double MA=iMA(NULL,TF,Per_MA,0,0,0,1); int CalculateCurrentOrders(string symbol) { int buys=0,sells=0; //---- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++; } } //---- return orders volume if(buys>0) return(buys); else return(-sells); } //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double LotsOptimized() { double lot=Lots; int orders=HistoryTotal(); // history orders total int losses=0; // number of losses orders without a break //---- select lot size //lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,2); lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/100/MarketInfo(Symbol(),MODE_TICKVALUE)/StopLoss,2); //---- calcuulate number of losses orders without a break if(DecreaseFactor>0) { for(int i=orders-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; } if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue; //---- if(OrderProfit()>0) break; if(OrderProfit()<0) losses++; } if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,2); } //---- return lot size if(lot<0.01) lot=0.01; return(lot); } //------------------------------------------------- /* эта часть из индикатора*/ int CheckBreakoutLines(int shift) { // Total Objects int obj_total = ObjectsTotal(); // Time of bar datetime now = Time[shift]; // Iterate for(int i = obj_total - 1; i >= 0; i--) { // Object name string label = ObjectName(i); // Types int OType = ObjectType(label); bool trendline = false; bool hline = false; // Price to evaluate double cprice = 0; // Trendlines if(OType == OBJ_TREND ) { bool ray = ObjectGet(label, OBJPROP_RAY); if(!ray) { datetime x1 = ObjectGet(label, OBJPROP_TIME1); datetime x2 = ObjectGet(label, OBJPROP_TIME2); if(x1 < now && x2 < now) continue; } cprice = GetCurrentPriceOfLine(label, shift); trendline = true; } else if(OType == OBJ_HLINE ) { cprice = ObjectGet(label, OBJPROP_PRICE1); hline = true; } else { continue; } // Breakouts and false breakouts of trendlines and hlines if(MA>cprice &&Ask<cprice) { if(trendline) { return(OP_BUY_); } else if(hline) { return(OP_BUY_); } } else if (MA>cprice &&Ask<cprice) { if(trendline) { return(OP_SELL_); } else if(hline) { return(OP_SELL_); } } } return(EMPTY_VALUE); } double GetCurrentPriceOfLine(string label, int shift) { double price1 = ObjectGet(label, OBJPROP_PRICE1); double price2 = ObjectGet(label, OBJPROP_PRICE2); datetime d1 = ObjectGet(label, OBJPROP_TIME1); datetime d2 = ObjectGet(label, OBJPROP_TIME2); int shiftfrom = iBarShift(Symbol(), 0, d1, false); int shiftto = iBarShift(Symbol(), 0, d2, false); int lapse = MathAbs(shiftto - shiftfrom); int distance = MathAbs(shift - shiftfrom); double pendiente = (price2 - price1) / lapse; double cpoint = price1 + (distance * pendiente); return(cpoint); } //------------------------------------------------------------------------------------------------------------- //+------------------------------------------------------------------+ //| Check for open order conditions | //+------------------------------------------------------------------+ void CheckForOpen() { int res; //--------------------------------------------------------------------+ //---- buy conditions if(OP_BUY_&&b_1) { res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask-(StopLoss*Point),Ask+TakeProfit*Point," VV",MAGIC,0,Green); b_1=false; s_1=true; return; } //---- sell conditions if(OP_SELL_&&s_1) { res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Bid+(StopLoss*Point),Bid-TakeProfit*Point," VV",MAGIC,0,Red); s_1=false;b_1=true; return; } //---- } //+------------------------------------------------------------------+ //| Start function | //+------------------------------------------------------------------+ void start() { //---- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; //---- calculate open orders by current symbol if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); } //+------------------------------------------------------------------+ //|---------------------------// END //------------------------------| //+------------------------------------------------------------------+ ValerVL35 2017.04.04 08:15 #11388 LRA:将方案加载到记事本中,并删除了空行。一目了然的覆盖成为可能。按了SRC按钮并粘贴了。以下是出现的情况。1) 为什么你需要定义 如果我们已经有了OP_BUY=0和OP_SELL=12)邪恶的根源在于这个片段。一个相同的条件(MA>cprice &&Ask<cprice)被检查了两次,并采取了不同的决定。3) 之后,每个分支都进行检查,但结果仍然是一样的。上面这一行可以简化,写成如下 谢谢你的回答,但它仍然只打开SELL,因为我看到OP_SELL=1。这个条件总是得到满足。我把它改写成这样订单已经停止打开,在我看来,int CheckBreakoutLines(int shift)不起作用。//+------------------------------------------------------------------+ //| Copyright © 2010, MetaQuotes Software Corp. | //| http://www.mql4.com/ru/users/rustein | //+------------------------------------------------------------------+ #define MAGIC 131313 // открытие внутрь канала //--------------------------------------- extern int TF=15; extern int StopLoss = 300; extern double TakeProfit = 3000; extern int Per_MA= 20; extern double Lots = 0.1; extern double MaximumRisk = 1; extern double DecreaseFactor = 0; bool OP_BUY_= false; bool OP_SELL_ =false; bool b_1=true, s_1=true; //+------------------------------------------------------------------+ //| Calculate open positions | //+------------------------------------------------------------------+ double MA=iMA(NULL,TF,Per_MA,0,0,0,1); int CalculateCurrentOrders(string symbol) { int buys=0,sells=0; //---- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++; } } //---- return orders volume if(buys>0) return(buys); else return(-sells); } //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double LotsOptimized() { double lot=Lots; int orders=HistoryTotal(); // history orders total int losses=0; // number of losses orders without a break //---- select lot size //lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,2); lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/100/MarketInfo(Symbol(),MODE_TICKVALUE)/StopLoss,2); //---- calcuulate number of losses orders without a break if(DecreaseFactor>0) { for(int i=orders-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; } if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue; //---- if(OrderProfit()>0) break; if(OrderProfit()<0) losses++; } if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,2); } //---- return lot size if(lot<0.01) lot=0.01; return(lot); } //------------------------------------------------- /* эта часть из индикатора*/ int CheckBreakoutLines(int shift) { // Total Objects int obj_total = ObjectsTotal(); // Time of bar datetime now = Time[shift]; // Iterate for(int i = obj_total - 1; i >= 0; i--) { // Object name string label = ObjectName(i); // Types int OType = ObjectType(label); bool trendline = false; bool hline = false; // Price to evaluate double cprice = 0; // Trendlines if(OType == OBJ_TREND ) { bool ray = ObjectGet(label, OBJPROP_RAY); if(!ray) { datetime x1 = ObjectGet(label, OBJPROP_TIME1); datetime x2 = ObjectGet(label, OBJPROP_TIME2); if(x1 < now && x2 < now) continue; } cprice = GetCurrentPriceOfLine(label, shift); trendline = true; } else if(OType == OBJ_HLINE ) { cprice = ObjectGet(label, OBJPROP_PRICE1); hline = true; } else { continue; } // Breakouts and false breakouts of trendlines and hlines if(MA>cprice &&Ask<cprice) {OP_BUY_= true; if(trendline ||hline) return (OP_BUY_); } else if (MA<cprice &&Bid>cprice) {OP_SELL_ =true; if(trendline ||hline) return (OP_SELL_); } } return(EMPTY_VALUE); } double GetCurrentPriceOfLine(string label, int shift) { double price1 = ObjectGet(label, OBJPROP_PRICE1); double price2 = ObjectGet(label, OBJPROP_PRICE2); datetime d1 = ObjectGet(label, OBJPROP_TIME1); datetime d2 = ObjectGet(label, OBJPROP_TIME2); int shiftfrom = iBarShift(Symbol(), 0, d1, false); int shiftto = iBarShift(Symbol(), 0, d2, false); int lapse = MathAbs(shiftto - shiftfrom); int distance = MathAbs(shift - shiftfrom); double pendiente = (price2 - price1) / lapse; double cpoint = price1 + (distance * pendiente); return(cpoint); } //------------------------------------------------------------------------------------------------------------- //+------------------------------------------------------------------+ //| Check for open order conditions | //+------------------------------------------------------------------+ void CheckForOpen() { int res; //--------------------------------------------------------------------+ //---- buy conditions if(OP_BUY_&&b_1) { res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask-(StopLoss*Point),Ask+TakeProfit*Point," VV",MAGIC,0,Green); b_1=false; s_1=true; return; } //---- sell conditions if(OP_SELL_ &&s_1) { res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Bid+(StopLoss*Point),Bid-TakeProfit*Point," VV",MAGIC,0,Red); s_1=false;b_1=true; return; } //---- } //+------------------------------------------------------------------+ //| Start function | //+------------------------------------------------------------------+ void start() { //---- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; //---- calculate open orders by current symbol if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); } //+------------------------------------------------------------------+ //|---------------------------// END //------------------------------| //+------------------------------------------------------------------+ Warstein www.mql5.com Профиль трейдера piranija 2017.04.05 09:57 #11389 亲爱的专业人士。在安装MT4之前或之后,我应该怎么做,才能使之后的报价历史可以从任何磁盘写入/读取,除了系统磁盘,否则就不可能了?所有经纪商的MT4都会将所有内容转储到C:\Users\MAN\AppData\Roaming\MetaQuotes\Terminal\100.......001\history\downloads(分别为每个经纪商和每个终端)。两家经纪公司的两个MT4,3-4个货币对,吃了25GB,即所有的自由内存。同时,必要的引文也在测试者C:\Users\.......\tester\history中加载。请帮助提供建议,不要考虑到重新安装Windows(我有7),重新分配磁盘大小。也许我做错了什么?如果我错过了,而且已经在某个地方讨论过了--请向我抛出一个链接......。提前感谢。 Alexey Viktorov 2017.04.05 10:44 #11390 piranija:亲爱的专业人士。在安装MT4之前或之后,我应该怎么做,才能使之后的报价历史可以从任何磁盘写入/读取,除了系统磁盘,否则就不可能了?所有经纪商的MT4都会将所有内容转储到C:\Users\MAN\AppData\Roaming\MetaQuotes\Terminal\100.......001\history\downloads(分别为每个经纪商和每个终端)。两个MT4在两个经纪公司的3-4个货币对吃了25GB,也就是所有的可用内存。同时,必要的引文也在测试者C:\Users\.......\tester\history中加载。请帮助提供建议,不要考虑到重新安装Windows(我有7),重新分配磁盘大小。也许我做错了什么?如果我错过了,而且已经在某个地方讨论过了--请向我抛出一个链接......。提前感谢。只需将整个终端文件夹 复制到一个非系统驱动器上,创建一个快捷方式,并写入/portable开关 1...113211331134113511361137113811391140114111421143114411451146...1178 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
是否有适用于安卓的机器人?
Metatrader的移动版中 没有自动交易,在可预见的未来也不太可能出现。如果你想从你的手机上控制机器人,你需要一个VPS,它将托管有机器人的终端,+手机上的远程访问软件。
我在MT5中打开十个货币对的周线图,终端加载了800兆的tick历史。它不断地被加载,尽管图表上几乎没有变化。问题是,如果我只使用周线图,为什么我需要刻度历史?顺便说一下,在MT4上,周线图是立即打开的,没有任何延迟。
这是mt5的一个特点--在m1上加载所有的东西,然后建立所需的时期.......
因此,每一次,对于每个符号
EA的理念是在价格触及水平线或手动绘制的趋势线时买入或卖出。我把不同的工作EA和指标做成了一个EA。但是,该EA并不工作。或者说,它只打开了卖出,而在第一个勾股上没有任何信号。有什么问题吗?
/+------------------------------------------------------------------+
//| |
//| Copyright © 2010, MetaQuotes Software Corp.
//| http://www.mql4.com/ru/users/rustein |
//+------------------------------------------------------------------+
#define MAGIC 131313 //打开内向通道
//---------------------------------------
外部inttern TF=15。
//+------------------------------------------------------------------+
外来的int StopLoss = 300;
//--------------------------------------------
外部双倍TakeProfit = 3000。
//--------------------------------------
外置 int Per_MA= 20;
//---- 常数
#define OP_BUY_ 0
#define OP_SELL_ 1
//-------------------------------------------------------------------+
外置双Lots = 0.1。
外置双倍最大风险 = 1;
外置双倍的DecreaseFactor = 0;
bool b_1=true, s_1=true。
//+------------------------------------------------------------------+
//|计算未结头寸|
//+------------------------------------------------------------------+
double MA=iMA(NULL,TF,Per_MA,0,0,0,1)。
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0。
//----
for(int i=0;i<OrdersTotal();i++)
{
如果(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
如果(OrderSymbol()==Symbol() && OrderMagicNumber() ==MAGIC)
{
如果(OrderType()==OP_BUY) buys++;
如果(OrderType()==OP_SELL) sells++;
}
}
//---- 退货订单量
if(buys>0) return(buys)。
否则返回(-sells)。
}
//+------------------------------------------------------------------+
//|计算最佳手数|
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots。
int orders=HistoryTotal(); // 历史订单总数
int losses=0; // 亏损订单的数量,没有休息时间
//---- 选择地段大小
//lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,2)。
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/100/MarketInfo(Symbol(),MODE_TICKVALUE)/StopLoss,2) 。
//----,计算无休止的损失订单的数量
如果(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("历史中的错误!"); break; }
如果(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) 继续。
//----
如果(OrderProfit()>0),则休息。
if(OrderProfit()<0) losses++;
}
如果(损失>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,2)。
}
//----,返回地段大小
如果(lot<0.01)lot=0.01。
return(lot)。
}
//-------------------------------------------------
/*这部分来自指标
int CheckBreakoutLines(int shift)
{
// 对象总数
int obj_total = ObjectsTotal()。
// 酒吧的时间
datetime now = Time[shift];
// 迭代
for(int i = obj_total - 1; i >= 0; i--)
{
// 对象名称
string label = ObjectName(i);
// 类型
int OType = ObjectType(label)。
bool trendline = false。
bool hline = false。
// 要评估的价格
double cprice = 0;
// 趋势线
如果(OType == OBJ_TREND )
{
bool ray = ObjectGet(label, OBJPROP_RAY);
if(!ray)
{
datetime x1 = ObjectGet(label, OBJPROP_TIME1);
datetime x2 = ObjectGet(label, OBJPROP_TIME2);
if(x1 < now && x2 < now) 继续。
}
cprice = GetCurrentPriceOfLine(label, shift)。
trendline = true。
}else if(OType == OBJ_HLINE ) {
cprice = ObjectGet(label, OBJPROP_PRICE1)。
hline = true。
}否则 {
继续。
}
// 趋势线和h线的突破和假突破
如果(MA>cprice &&Ask<cprice)
{
如果(趋势线) { 返回(OP_BUY_); }else if(hline) { return(OP_BUY_); }
}否则如果(MA>cprice &&Ask<cprice) {
如果(趋势线) { 返回(OP_SELL_); }else if(hline) { return(OP_SELL_); }
}
}
return(EMPTY_VALUE)。
}
double GetCurrentPriceOfLine(string label, int shift)
{
double price1 = ObjectGet(label, OBJPROP_PRICE1);
double price2 = ObjectGet(label, OBJPROP_PRICE2);
datetime d1 = ObjectGet(label, OBJPROP_TIME1);
datetime d2 = ObjectGet(label, OBJPROP_TIME2);
int shiftfrom = iBarShift(Symbol(), 0, d1, false)。
int shiftto = iBarShift(Symbol(), 0, d2, false)。
int lapse = MathAbs(shiftto - shiftfrom)。
int distance = MathAbs(shift - shiftfrom);
double pendiente = (price2 - price1) / lapse;
double cpoint = price1 + (distance * pendiente);
return(cpoint)。
}
//-------------------------------------------------------------------------------------------------------------
//+------------------------------------------------------------------+
//| 检查未结订单的情况 |
//+------------------------------------------------------------------+
空白的CheckForOpen()。
{
int res;
//--------------------------------------------------------------------+
//--------------------------------------------------------------------+
//---- 购买条件
如果(OP_BUY_&&b_1)
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask-(StopLoss*Point),Ask+TakeProfit*Point," VV",MAGIC,0,Green) 。
b_1=false; s_1=true。
返回。
}
//---- 卖出条件
如果(OP_SELL_&&s_1)
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Bid+(StopLoss*Point),Bid-TakeProfit*Point," VV",MAGIC,0,Red)。
s_1=false;b_1=true。
返回。
}
//----
}
//+------------------------------------------------------------------+
//| 启动功能|
//+------------------------------------------------------------------+
空白启动()。
{
//---- 检查历史和交易情况
如果(Bars<100 || IsTradeAllowed()==false) 返回。
//---- 按当前符号计算未结订单
如果(CalculateCurrentOrders(Symbol())==0) CheckForOpen()。
}
//+------------------------------------------------------------------+
//|---------------------------// END //------------------------------|
//+------------------------------------------------------------------+
EA的理念是在价格触及水平线或手动绘制的趋势线时买入或卖出。我把不同的工作EA和指标做成了一个EA。但是,该EA并不工作。或者说,它只打开了卖出,而在第一个勾股上没有任何信号。有什么问题吗?
/+------------------------------------------------------------------+
//| |
//| Copyright © 2010, MetaQuotes Software Corp.
//| http://www.mql4.com/ru/users/rustein |
//+------------------------------------------------------------------+
#define MAGIC 131313 //打开内向通道
//---------------------------------------
外部inttern TF=15。
//+------------------------------------------------------------------+
外来的int StopLoss = 300;
//--------------------------------------------
外部双倍TakeProfit = 3000。
//--------------------------------------
外置 int Per_MA= 20;
//---- 常数
#define OP_BUY_ 0
#define OP_SELL_ 1
.....................................
.....................................
//---- 检查历史和交易情况
如果(Bars<100 || IsTradeAllowed()==false) 返回。
//---- 按当前符号计算未结订单
如果(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
}
//+------------------------------------------------------------------+
//|---------------------------// END //------------------------------|
//+------------------------------------------------------------------+
将程序加载到记事本中,删除了空行。一目了然的覆盖成为可能。按了SRC按钮并粘贴了。以下是出现的情况。1) 为什么你需要定义
如果我们已经有了OP_BUY=0和OP_SELL=1
2)所有邪恶的根源就在这个片段中。一个相同的条件(MA>cprice &&Ask<cprice)被检查了两次,并采取了不同的决定。
3) 之后,每个分支都进行检查,但结果仍然是一样的。
一般来说,上面这句话可以简化,写成以下内容
if(trendline)return OP_BUY; if(hline) return OP_BUY; или еще проще if(trendline or hline) return OP_BUY;
将方案加载到记事本中,并删除了空行。一目了然的覆盖成为可能。按了SRC按钮并粘贴了。以下是出现的情况。1) 为什么你需要定义
如果我们已经有了OP_BUY=0和OP_SELL=1
2)邪恶的根源在于这个片段。一个相同的条件(MA>cprice &&Ask<cprice)被检查了两次,并采取了不同的决定。
3) 之后,每个分支都进行检查,但结果仍然是一样的。
上面这一行可以简化,写成如下
谢谢你的回答,但它仍然只打开SELL,因为我看到OP_SELL=1。这个条件总是得到满足。我把它改写成这样
订单已经停止打开,在我看来,int CheckBreakoutLines(int shift)不起作用。
亲爱的专业人士。在安装MT4之前或之后,我应该怎么做,才能使之后的报价历史可以从任何磁盘写入/读取,除了系统磁盘,否则就不可能了?
所有经纪商的MT4都会将所有内容转储到C:\Users\MAN\AppData\Roaming\MetaQuotes\Terminal\100.......001\history\downloads(分别为每个经纪商和每个终端)。两家经纪公司的两个MT4,3-4个货币对,吃了25GB,即所有的自由内存。同时,必要的引文也在测试者C:\Users\.......\tester\history中加载。
请帮助提供建议,不要考虑到重新安装Windows(我有7),重新分配磁盘大小。也许我做错了什么?如果我错过了,而且已经在某个地方讨论过了--请向我抛出一个链接......。
提前感谢。
亲爱的专业人士。在安装MT4之前或之后,我应该怎么做,才能使之后的报价历史可以从任何磁盘写入/读取,除了系统磁盘,否则就不可能了?
所有经纪商的MT4都会将所有内容转储到C:\Users\MAN\AppData\Roaming\MetaQuotes\Terminal\100.......001\history\downloads(分别为每个经纪商和每个终端)。两个MT4在两个经纪公司的3-4个货币对吃了25GB,也就是所有的可用内存。同时,必要的引文也在测试者C:\Users\.......\tester\history中加载。
请帮助提供建议,不要考虑到重新安装Windows(我有7),重新分配磁盘大小。也许我做错了什么?如果我错过了,而且已经在某个地方讨论过了--请向我抛出一个链接......。
提前感谢。
只需将整个终端文件夹 复制到一个非系统驱动器上,创建一个快捷方式,并写入/portable开关