论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
帖子
作者
回复/查看
最后发表
没有添加任何其他附加要求的代码,测试结果感觉在调整期还是不太理想,所以还需要增加移动止损及开仓限制,不然赚的不够亏得,先把最基本的发上来供楼主改进。//+------------------------------------------------------------------+ //| Mid721.mq4 | //| fantasize //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "fantasize" extern int Period_1 = 21; extern double TakeProfit = 200; extern double Lots = 0.1; double MA7[3000]; double MA21[3000]; double MA3[3000]; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- int counted_bars=IndicatorCounted(); //---- double High1; int cnt, ticket, total; int i,k; double sum; // 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(Period_1 <= 1 ) return(0); if(Bars <= Period_1 ) return(0); //calculate 7 days Min Open . i = Bars - Period_1 + 1; if(counted_bars > Period_1 - 1) i = Bars - counted_bars - 1; while(i >= 0) { k = i + 7 - 1; sum=Open[k]; while(k >= i) { sum= MathMin(sum,Open[k]); k--; } MA7=sum; i--; } //calculate 21 days Max Open . i = Bars - Period_1 + 1; if(counted_bars > Period_1 - 1) i = Bars - counted_bars - 1; while(i >= 0) { k = i + 21 - 1; sum=Open[k]; while(k >= i) { sum = MathMax(sum,Open[k]); k--; } MA21=sum; i--; } //MA3 i = Bars - Period_1 + 1; if(counted_bars > Period_1 - 1) i = Bars - counted_bars - 1; //--EMA(VAR1,13) while(i >= 0) { MA3 = 0.5*(MA7+MA21)-Close ; i--; } //buy and sell judge High1=MA3[1]; //Alert(MA7[0],MA21[0],MA3[0],Close[0]); total=OrdersTotal(); if(total<1) { //1 // no opened orders identified if(AccountFreeMargin()<(1000*Lots)) { //2 Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); }//2 if(High1<0.00001) { //2 ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Red); if(ticket>0) {//3 if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); }//3 else Print("Error opening BUY order : ",GetLastError()); return(0); }//2 // check for short position (SELL) possibility if(High1>0.00001) {//2 ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"macd sample",16384,0,Green); if(ticket>0) {//3 if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); }//3 else Print("Error opening SELL order : ",GetLastError()); return(0); }//2 }//1 // it is important to enter the market correctly, // but it is more important to exit it correctly... for(cnt=0;cnt0.00001 ) {//4 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position return(0); // exit }//4 }//3 else // go to short position {//3 // should it be closed? if(High1<0.00001) {//4 OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit }//4 }//end else 3 }//2 // }//1 return(0); }
2008-10-06 12:27
2007-07-19 10:56
3
4999
2007-08-03 03:05
2007-07-30 15:16
37
12351
2017-10-17 11:50
2007-07-31 07:13

本站免责声明:

1、本站所有广告及宣传信息均与韬客无关,如需投资请依法自行决定是否投资、斟酌资金安全及交易亏损风险;

2、韬客是独立的、仅为投资者提供交流的平台,网友发布信息不代表韬客的观点与意思表示,所有因网友发布的信息而造成的任何法律后果、风险与责任,均与韬客无关;

3、金融交易存在极高法律风险,未必适合所有投资者,请不要轻信任何高额投资收益的诱导而贸然投资;投资保证金交易导致的损失可能超过您投入的资金和预期。请您考虑自身的投资经验及风险承担能力,进行合法、理性投资;

4、所有投资者的交易帐户应仅限本人使用,不应交由第三方操作,对于任何接受第三方喊单、操盘、理财等操作的投资和交易,由此导致的任何风险、亏损及责任由投资者个人自行承担;

5、韬客不隶属于任何券商平台,亦不受任何第三方控制,韬客不邀约客户投资任何保证金交易,不接触亦不涉及投资者的任何资金及账户信息,不代理任何交易操盘行为,不向客户推荐任何券商平台,亦不存在其他任何推荐行为。投资者应自行选择券商平台,券商平台的任何行为均与韬客无关。投资者注册及使用韬客即表示其接受和认可上述声明,并自行承担法律风险。

版权所有:韬客外汇论坛 www.talkfx.com 联络我们:[email protected]