[存档]任何菜鸟问题,为了不使论坛变得杂乱无章。专业人士,不要路过。没有你就无处可去 - 3. - 页 202 1...195196197198199200201202203204205206207208209...652 新评论 Vitaliy Andreischev 2011.09.22 09:38 #2011 Vinin: 或者,也许只是在EA的帮助下制定一个活跃工具的清单。这个方法有点复杂。可以用更简单的方法来解决这个问题 我们可以简单地在输入参数中指定一个数字,但问题是,在交易过程中,可能会出现某些货币暂停交易的情况。那么其他货币的EA应该重新计算他们的参数。 Victor Nikolaev 2011.09.22 09:41 #2012 forexnew: 你可以简单地在输入参数中指定一个数字,但问题是,在交易过程中,可能会出现某些货币暂停交易的情况。那么其他货币的EA就必须重新计算其参数。 为什么要说明。专家顾问可以自己得到它。同时,它还可以管理其他专家顾问。一切都取决于任务 noobys 2011.09.22 09:43 #2013 Figar0: В самой функции ошибок нет, наверно ошибки возникают при попытке ее использовать, но это вы нам не показываете. Выкладывайте то что не компилится прямо файлом и гадать будет не надо. //+------------------------------------------------------------------+ //| MACD Sample.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ extern double TakeProfit = 50; extern double TrailingStop = 30; extern double MACDOpenLevel=3; extern double MACDCloseLevel=2; extern double MATrendPeriod=26; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { double MacdCurrent, MacdPrevious, SignalCurrent; double SignalPrevious, MaCurrent, MaPrevious; int cnt, ticket, total; // initial data checks // it is important to make sure that the expert works with a normal // chart and the user did not make any mistakes setting external // variables (Lots, StopLoss, TakeProfit, // TrailingStop) in our case, we check TakeProfit // on a chart of less than 100 bars if(Bars<100) { Print("bars less than 100"); return(0); } if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); // check TakeProfit } double Lots() // Расчет используемого лота { double Lots; Lots=AccountFreeMargin()/10000*5; Lots=MathMin(15,MathMax(0.1,Lots)); if(Lots<0.1) Lots=NormalizeDouble(Lots,2); else { if(Lots<1) Lots=NormalizeDouble(Lots,1); else Lots=NormalizeDouble(Lots,0); } return(Lots); } //+------------------------------------------------------------------+ // to simplify the coding and speed up access // data are put into internal variables MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0); MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1); SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0); SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0); MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1); total=OrdersTotal(); if(total<1) { // no opened orders identified if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } // check for long position (BUY) possibility if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); return(0); } // check for short position (SELL) possibility if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDOpenLevel*Point) && MaCurrent<MaPrevious) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); return(0); } return(0); } // it is important to enter the market correctly, // but it is more important to exit it correctly... for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { if(OrderType()==OP_BUY) // long position is opened { // should it be closed? if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDCloseLevel*Point)) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position return(0); // exit } // check for trailing stop if(TrailingStop>0) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()<Bid-Point*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); return(0); } } } } else // go to short position { // should it be closed? if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*Point)) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit } // check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } // the end. Vitaliy Andreischev 2011.09.22 09:54 #2014 Vinin: 你为什么要指定这个?专家顾问可以自己获得。同时,它还可以管理其他专家顾问。这一切都取决于任务。我不知道管理其他EA的情况。该EA在所有货币对上都是一样的,模式是这样的。 如果有两个货币对:第一个货币对显示2,第二个货币对显示1。 如果3个货币对:第一个显示3,第二个显示2,第三个显示1 如果是4个货币对:第一个显示4,第二个显示3,第三个显示2,第四个显示1。 我有一种感觉,第一种货币的计算结果没有被其他货币对的专家顾问考虑在内,或者它在某种程度上取决于打开的窗口(货币对)的数量!我想这是一个问题。 Vitaliy Andreischev 2011.09.22 10:11 #2015 Vinin: 为什么要说明。议员可以自己去拿。同时,他还可以管理其他顾问。这一切都取决于任务。 谢谢你。我自己已经想明白了。我只需要删除这一行,并从1开始计算KP。 if(OrderSymbol()==Symbol()) break; [删除] 2011.09.22 10:34 #2016 skyjet: 对于初学者来说,你的手数计算函数是在start函数里面声明的。把它拿出来。然后会出现一些未声明变量的错误,但我认为你可以自己处理。 DDFedor 2011.09.22 11:55 #2017 skyjet: 为什么在手数计算中需要NormalizeDlouble()?为了使逗号后有两个数字。否则,0.009手的头寸将不会被打开,因为它不是最小手数的倍数。 double Lots; Lots=AccountFreeMargin()/10000*5; Lots=MathMin(15,MathMax(0.1,Lots)); if(Lots<0.1) Lots=NormalizeDouble(Lots,2); else { if(Lots<1) Lots=NormalizeDouble(Lots,1);// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! else Lots=NormalizeDouble(Lots,0);// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! } Artem Gulturyan 2011.09.22 12:33 #2018 伙计们! 我如何使每40个订单成为大批量?:: 市场和待定 这个怎么样? int Nom = OrderTicket(); // Номер ордера a= Nom%40; // к-во делить на 40 без остатка if a = 0 lot = 2; noobys 2011.09.22 13:48 #2019 Figar0: 对于初学者来说,你的手数计算函数是在start函数里面声明的。把它拿出来。然后会出现一些未声明变量的错误,但我认为你可以自己处理。 谢谢你的帮助。 noobys 2011.09.22 13:49 #2020 DDFedor: 空中喷气机。 在手数计算中,NormalizeDlouble()的作用是什么?为了使逗号后有两个数字。否则,一个手数为0.009的头寸将不会被打开,因为它不是最小手数的倍数步骤。 谢谢你的澄清。 1...195196197198199200201202203204205206207208209...652 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
或者,也许只是在EA的帮助下制定一个活跃工具的清单。这个方法有点复杂。可以用更简单的方法来解决这个问题
你可以简单地在输入参数中指定一个数字,但问题是,在交易过程中,可能会出现某些货币暂停交易的情况。那么其他货币的EA就必须重新计算其参数。
为什么要说明。专家顾问可以自己得到它。同时,它还可以管理其他专家顾问。一切都取决于任务
Figar0:
В самой функции ошибок нет, наверно ошибки возникают при попытке ее использовать, но это вы нам не показываете. Выкладывайте то что не компилится прямо файлом и гадать будет не надо.
你为什么要指定这个?专家顾问可以自己获得。同时,它还可以管理其他专家顾问。这一切都取决于任务。
我不知道管理其他EA的情况。该EA在所有货币对上都是一样的,模式是这样的。
如果有两个货币对:第一个货币对显示2,第二个货币对显示1。
如果3个货币对:第一个显示3,第二个显示2,第三个显示1
如果是4个货币对:第一个显示4,第二个显示3,第三个显示2,第四个显示1。
我有一种感觉,第一种货币的计算结果没有被其他货币对的专家顾问考虑在内,或者它在某种程度上取决于打开的窗口(货币对)的数量!我想这是一个问题。
为什么要说明。议员可以自己去拿。同时,他还可以管理其他顾问。这一切都取决于任务。
对于初学者来说,你的手数计算函数是在start函数里面声明的。把它拿出来。然后会出现一些未声明变量的错误,但我认为你可以自己处理。
为什么在手数计算中需要NormalizeDlouble()?
为了使逗号后有两个数字。否则,0.009手的头寸将不会被打开,因为它不是最小手数的倍数。
伙计们!
我如何使每40个订单成为大批量?:: 市场和待定
这个怎么样?
对于初学者来说,你的手数计算函数是在start函数里面声明的。把它拿出来。然后会出现一些未声明变量的错误,但我认为你可以自己处理。
在手数计算中,NormalizeDlouble()的作用是什么?
为了使逗号后有两个数字。否则,一个手数为0.009的头寸将不会被打开,因为它不是最小手数的倍数步骤。