新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 - 页 1371 1...136413651366136713681369137013711372137313741375137613771378...1953 新评论 Сергей Дыбленко 2021.01.30 10:36 #13701 MakarFX:到了EA的最底部。 不幸的是,它并没有成倍增长!()()()。 Tretyakov Rostyslav 2021.01.30 10:41 #13702 Сергей Дыбленко:不幸的是,它并没有成倍增长!()()()。 这个函数计算出与自由保证金和指定风险有关的手数! 你说的是什么乘法? Сергей Дыбленко 2021.01.30 10:47 #13703 MakarFX:这个函数计算出与自由保证金和指定风险有关的手数!你说的是什么乘法? 每次获利后的手数增加! Tretyakov Rostyslav 2021.01.30 10:52 #13704 Сергей Дыбленко:关于每次盈利后增加手数的问题! 该函数将在盈利后增加手数,但如果盈利允许增加最小手数的增量 [删除] 2021.01.30 10:54 #13705 Сергей Дыбленко:关于每次盈利后增加手数! 下面是一个例子,在10 000以下,你的余额将以0.1手为单位,从10 000到20 000以0.5手为单位。 从20000到40000,批次1.0,超过40000,批次2.0。 //+------------------------------------------------------------------+ //| Moving Average.mq4 | //| Copyright 2005-2014, MetaQuotes Software Corp. | //| http://www.mql4.com | //+------------------------------------------------------------------+ #property copyright "2005-2014, MetaQuotes Software Corp." #property link "http://www.mql4.com" #property description "Moving Average sample expert advisor" #define MAGICMA 20131111 //--- Inputs input double InpLots =0.1; input int MovingPeriod =12; input int MovingShift =6; //+------------------------------------------------------------------+ //| Calculate open positions | //+------------------------------------------------------------------+ 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()==MAGICMA) { 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 Lots=InpLots; double ab=AccountBalance(); if(ab>=10000 && ab<20000) Lots=0.5; if(ab>=20000 && ab<40000) Lots=1.0; if(ab>=40000) Lots=2.0; return(Lots); } //+------------------------------------------------------------------+ //| Check for open order conditions | //+------------------------------------------------------------------+ void CheckForOpen() { double ma; int res; //--- go trading only for first tiks of new bar if(Volume[0]>1) return; //--- get Moving Average ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0); //--- sell conditions if(Open[1]>ma && Close[1]<ma) { res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red); return; } //--- buy conditions if(Open[1]<ma && Close[1]>ma) { res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,0,0,"",MAGICMA,0,Blue); return; } //--- } //+------------------------------------------------------------------+ //| Check for close order conditions | //+------------------------------------------------------------------+ void CheckForClose() { double ma; //--- go trading only for first tiks of new bar if(Volume[0]>1) return; //--- get Moving Average ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0); //--- for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue; //--- check order type if(OrderType()==OP_BUY) { if(Open[1]>ma && Close[1]<ma) { if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White)) Print("OrderClose error ",GetLastError()); } break; } if(OrderType()==OP_SELL) { if(Open[1]<ma && Close[1]>ma) { if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White)) Print("OrderClose error ",GetLastError()); } break; } } //--- } //+------------------------------------------------------------------+ //| OnTick function | //+------------------------------------------------------------------+ void OnTick() { //--- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; //--- calculate open orders by current symbol if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); else CheckForClose(); //--- } //+------------------------------------------------------------------+ Tretyakov Rostyslav 2021.01.30 11:05 #13706 SanAlex:下面是一个例子,在10 000以下,你的余额将以0.1手为单位,从10 000到20 000以0.5手为单位。从20000到40000,1.0手,超过40000,2.0手 这是一个固定的地段增量。 对我来说,如果利润大于或等于 MarketInfo(Symbol(), MODE_MARGINREQUIRED)*MarketInfo(Symbol(), MODE_LOTSTEP) 它将增加该地段。 但如果没有其他使用保证金的未结订单。 [删除] 2021.01.30 11:13 #13707 MakarFX:它是一个固定的增加地段。在我的案例中,如果利润大于或等于那么,该地段就会有增加。但如果没有其他使用保证金的未结订单。 我在作弊--如果头寸处于亏损状态,就会增加地段。 //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double OptimizedBuy(void) { double PROFIT_BUY=0.00; for(int i=OrdersTotal()-1; i>=0; i--) // returns the number of open positions { if(OrderSelect(i,SELECT_BY_POS) && OrderSymbol()==Symbol()) { if(OrderSymbol()==Symbol() && OrderType()==OP_BUY) { PROFIT_BUY=PROFIT_BUY+NormalizeDouble(OrderProfit(),2); } } } double Lots=InpLots; double ab=PROFIT_BUY; if(ab<-1 && ab>=-InpLots_01) Lots=InpLots1; if(ab<-InpLots_01 && ab>=-InpLots_02) Lots=InpLots2; if(ab<-InpLots_02 && ab>=-InpLots_03) Lots=InpLots3; if(ab<-InpLots_03) Lots=InpLots4; //--- return trading volume return(Lots); } //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double OptimizedSell(void) { double PROFIT_SELL=0.00; for(int i=OrdersTotal()-1; i>=0; i--) // returns the number of open positions { if(OrderSelect(i,SELECT_BY_POS) && OrderSymbol()==Symbol()) { if(OrderSymbol()==Symbol() && OrderType()==OP_SELL) { PROFIT_SELL=PROFIT_SELL+NormalizeDouble(OrderProfit(),2); } } } double Lots=InpLots; double ab=PROFIT_SELL; if(ab<-1 && ab>=-InpLots_01) Lots=InpLots1; if(ab<-InpLots_01 && ab>=-InpLots_02) Lots=InpLots2; if(ab<-InpLots_02 && ab>=-InpLots_03) Lots=InpLots3; if(ab<-InpLots_03) Lots=InpLots4; //--- return trading volume return(Lots); } //+------------------------------------------------------------------+ Сергей Дыбленко 2021.01.30 11:32 #13708 谢谢大家的帮助,但我的大脑没有足够的能力去做我需要的事情。 Tretyakov Rostyslav 2021.01.30 11:39 #13709 Сергей Дыбленко: 谢谢大家的帮助,但我的大脑不足以完成我需要做的事情。 你逐点解释需要什么。 工作中的订单有多少,你同时交易多少个货币对,每笔交易的风险是什么(如果有)? 还有你的其他东西) Tretyakov Rostyslav 2021.01.30 11:42 #13710 SanAlex:我一直在作弊--如果头寸处于亏损状态,那么这批货会增加。 萨沙对其进行了一些调整,以增加该地段的赔率 input double factor=1.05; // коофициент умножения //+------------------------------------------------------------------+ //| Calculate optimal lot size | //+------------------------------------------------------------------+ double OptimizedSell(void) { double Lots =0.00; double PROFIT_BUY =0.00; double LOT_BUY =0.00; double PROFIT_SELL=0.00; double LOT_SELL =0.00; for(int i=OrdersTotal()-1; i>=0; i--) // returns the number of open positions { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true) { if(OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { PROFIT_BUY=PROFIT_BUY+NormalizeDouble(OrderProfit(),2); LOT_BUY =LOT_BUY+NormalizeDouble(OrderLots(),2); } if(OrderType()==OP_SELL) { PROFIT_SELL=PROFIT_SELL+NormalizeDouble(OrderProfit(),2); LOT_SELL =LOT_SELL+NormalizeDouble(OrderLots(),2); } } } } if(PROFIT_BUY<0) Lots=LOT_BUY*factor; else Lots=LOT_BUY; if(PROFIT_SELL<0) Lots=LOT_SELL*factor; else Lots=LOT_SELL; //--- return trading volume return(Lots); } //+------------------------------------------------------------------+ 1...136413651366136713681369137013711372137313741375137613771378...1953 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
到了EA的最底部。
不幸的是,它并没有成倍增长!()()()。
不幸的是,它并没有成倍增长!()()()。
这个函数计算出与自由保证金和指定风险有关的手数!
你说的是什么乘法?
这个函数计算出与自由保证金和指定风险有关的手数!
你说的是什么乘法?
每次获利后的手数增加!
关于每次盈利后增加手数的问题!
该函数将在盈利后增加手数,但如果盈利允许增加最小手数的增量
关于每次盈利后增加手数!
下面是一个例子,在10 000以下,你的余额将以0.1手为单位,从10 000到20 000以0.5手为单位。
从20000到40000,批次1.0,超过40000,批次2.0。
下面是一个例子,在10 000以下,你的余额将以0.1手为单位,从10 000到20 000以0.5手为单位。
从20000到40000,1.0手,超过40000,2.0手
这是一个固定的地段增量。
对我来说,如果利润大于或等于
它将增加该地段。
但如果没有其他使用保证金的未结订单。
它是一个固定的增加地段。
在我的案例中,如果利润大于或等于
那么,该地段就会有增加。
但如果没有其他使用保证金的未结订单。
我在作弊--如果头寸处于亏损状态,就会增加地段。
谢谢大家的帮助,但我的大脑不足以完成我需要做的事情。
你逐点解释需要什么。
工作中的订单有多少,你同时交易多少个货币对,每笔交易的风险是什么(如果有)?
还有你的其他东西)
我一直在作弊--如果头寸处于亏损状态,那么这批货会增加。
萨沙对其进行了一些调整,以增加该地段的赔率