论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:1349回复:3
草龙
注册时间2004-12-17
[MT4-EA]专家比赛测试代码
楼主发表于:2014-01-20 00:53只看该作者倒序浏览
1楼 电梯直达
电梯直达
主程序//+------------------------------------------------------------------+ //| AlexmanConcursExpert.mq4 | //| Copyright ? 2006, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #define copyright "Copyright ? 2006, AlexMan Studio" #define link "mailto:[email protected]" #import "AlexConcursLibrary.ex4" //湾觐蝾瘥? 趔黻鲨? 潆? 疣犷螓  耧屦蜞 // double StopValue(int i); bool IsByeTrade(int i); bool IsSellTrade(int i); bool IsStopByeTrade(int i); bool IsStopSellTrade(int i); double EmaStop(int PeriodEMA, int i); #import //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- GlobalVariableSet( "AlexmanConcursExpert", 0); //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } extern int _MagicNumber = 1440; // 禹桕嚯   爨汨麇耜栝 眍戾? 铕溴疣 extern int PeriodEMA = 15; // 襄痂钿 盘? 潆? 疣聍弪? 耱铒-腩襦 extern int Zazor = 7; // 狍趑屦睇? 玎镟? 磬 耱铒-腩耨 // 亦? 赅? 镱 篑腩忤?? 觐黻箴襦 怅膻鬣屐  羿殡? 礤 疣琊屮屙?, 桉镱朦珞屐  羿殡 // OneOrderControl.mq4 怦蜞怆屙 ? 蝈腩  耧屦蜞 礤镱耩邃耱忮眄?. // 扬囫栳? 玎 耔耱屐? 箫疣怆屙?? 铕溴疣扈 理漯妣 锗蜩祀?眈觐祗! //+------------------------------------------------------------------+ //| OneOrderControl.mq4 | //| Copyright ? 2006, komposter | //| mailto:[email protected] | //+------------------------------------------------------------------+ #property copyright "Copyright ? 2006, komposter" #property link "mailto:[email protected]" int _Ticket = 0, _Type = 0; double _Lots = 0.0, _OpenPrice = 0.0, _StopLoss = 0.0; double _TakeProfit = 0.0; datetime _OpenTime = -1; double _Profit = 0.0, _Swap = 0.0; double _Commission = 0.0; string _Comment = ""; datetime _Expiration = -1; void OneOrderInit( int magic ) { int _GetLastError, _OrdersTotal = OrdersTotal(); _Ticket = 0; _Type = 0; _Lots = 0.0; _OpenPrice = 0.0; _StopLoss = 0.0; _TakeProfit = 0.0; _OpenTime = -1; _Profit = 0.0; _Swap = 0.0; _Commission = 0.0; _Comment = ""; _Expiration = -1; for ( int z = _OrdersTotal - 1; z >= 0; z -- ) { if ( !OrderSelect( z, SELECT_BY_POS ) ) { _GetLastError = GetLastError(); Print( "OrderSelect( ", z, ", SELECT_BY_POS ) - Error #", _GetLastError ); continue; } if ( OrderMagicNumber() == magic && OrderSymbol() == Symbol() ) { _Ticket = OrderTicket(); _Type = OrderType(); _Lots = NormalizeDouble( OrderLots(), 1 ); _OpenPrice = NormalizeDouble( OrderOpenPrice(), Digits ); _StopLoss = NormalizeDouble( OrderStopLoss(), Digits ); _TakeProfit = NormalizeDouble( OrderTakeProfit(), Digits ); _OpenTime = OrderOpenTime(); _Profit = NormalizeDouble( OrderProfit(), 2 ); _Swap = NormalizeDouble( OrderSwap(), 2 ); _Commission = NormalizeDouble( OrderCommission(), 2 ); _Comment = OrderComment(); _Expiration = OrderExpiration(); return(0); } } } int Shift=1; int start() { // if (CurTime() < D'2006.07.01 00:00') return(0); int _GetLastError = 0; double spraid = Ask-Bid; double EmaStopValue = EmaStop(PeriodEMA,Shift); // 恹礤? ? 镥疱戾眄簋 潆? 疣玢痼珀? 镳铞? //---- 青镱扈磬屐 镟疣戾蝠? 铗牮 铋 镱玷鲨? (羼腓 铐? 羼螯) OneOrderInit( _MagicNumber ); //---- ? 蝈镥瘘 耢铗痂?, 羼螯 腓 铗牮 ?? 镱玷鲨?: if ( _Ticket > 0 ) { //---- 羼腓 铗牮 ? 晾?-镱玷鲨?, if ( _Type == OP_BUY ) { //---- 羼腓 ee 玎牮 囹?, if ( IsStopByeTrade(Shift) ) { //---- 玎牮 噱? 镱玷鲨? if ( !OrderClose( _Ticket, _Lots, Bid, 5, Green ) ) { _GetLastError = GetLastError(); Print( "硒栳赅 OrderClose ? ", _GetLastError ); return(-1); } } //---- 羼腓 耔沩嚯 礤 桤戾龛腭?, 恹躅滂? - 镱赅 疣眍 铗牮 囹? 眍怏? 镱玷鲨? else { // 犟蜞蜩, 祛驽? 镱疣 溻桡囹? 耱铒-腩耨? if ((_StopLoss==0 || _StopLoss < (EmaStopValue-(Zazor+5)*Point )) && (EmaStopValue-Zazor*Point ) < Bid) { if (!OrderModify(_Ticket,_OpenPrice,EmaStopValue-Zazor*Point,_TakeProfit,0,Blue)) { _GetLastError = GetLastError(); Print( "硒栳赅 -0- OrderModify ? ", _GetLastError ); return(-1); } GlobalVariableSet( "AlexmanConcursExpert", 1); } if ((_StopLoss==0 || _StopLoss < _OpenPrice) && _Profit>500 ) { if (!OrderModify(_Ticket,_OpenPrice,_OpenPrice,_TakeProfit,0,Blue)) { _GetLastError = GetLastError(); Print( "硒栳赅 OrderModify ? ", _GetLastError ); return(-1); } GlobalVariableSet( "AlexmanConcursExpert", 1); } return(0); } } //---- 羼腓 铗牮 ? 雅怂-镱玷鲨?, if ( _Type == OP_SELL ) { //---- 羼腓 邋 玎牮 囹?, if ( IsStopSellTrade(Shift) ) { //---- 玎牮 噱? 镱玷鲨? if ( !OrderClose( _Ticket, _Lots, Ask, 5, Red ) ) { _GetLastError = GetLastError(); Print( "硒栳赅 OrderClose ? ", _GetLastError ); return(-1); } } //---- 羼腓 耔沩嚯 礤 桤戾龛腭?, 恹躅滂? - 镱赅 疣眍 铗牮 囹? 眍怏? 镱玷鲨? else { // 犟蜞蜩, 祛驽? 镱疣 溻桡囹? 耱铒-腩耨? if ((_StopLoss==0 || _StopLoss > (EmaStopValue+spraid+(Zazor+5)*Point )) && (EmaStopValue+Zazor*Point ) > Bid) { if (!OrderModify(_Ticket,_OpenPrice,EmaStopValue+spraid+Zazor*Point,_TakeProfit,0,Blue)) { _GetLastError = GetLastError(); Print( "硒栳赅 -1- OrderModify ? ", _GetLastError ); return(-1); } GlobalVariableSet( "AlexmanConcursExpert", 1); } if ((_StopLoss==0 || _StopLoss > _OpenPrice) && _Profit>500 ) { if (!OrderModify(_Ticket,_OpenPrice,_OpenPrice,_TakeProfit,0,Blue)) { _GetLastError = GetLastError(); Print( "硒栳赅 OrderModify ? ", _GetLastError ); return(-1); } GlobalVariableSet( "AlexmanConcursExpert", 1); } return(0); } } } //---- 羼腓 礤? 镱玷鲨?, 铗牮 铋  耧屦蝾? ( _Ticket == 0 ) //- 蝾疸箦? 蝾朦觐 羼腓 觐眵桦?? 耱囵  耔沩嚯 if ((IsByeTrade(Shift+5) && IsStopByeTrade(Shift)) || (IsSellTrade(Shift+5) && IsStopSellTrade(Shift)) ) GlobalVariableSet( "AlexmanConcursExpert", 0); //-- 悟潲踵屐, 羼腓 ?  铗 鬣? 耩噌铗嚯 耱铒腩耨 if(GlobalVariableGet("AlexmanConcursExpert") ==1) return(0); //---- 湾镫铛? 猁 铗牮 ? 镱玷鲨?, 磬镳桁屦 牦镨螯 if ( IsByeTrade(Shift) && EmaStopValue<=Low[Shift] && EmaStopValue < Bid) { //---- 铗牮 噱? 晾? 镱玷鲨? if ( OrderSend( Symbol(), OP_BUY, 1.0, Ask, 5, 0.0, 0.0, "by AlexmanConcursExpert.mq4", _MagicNumber, 0, Green ) < 0 ) { _GetLastError = GetLastError(); Print( "硒栳赅 OrderSend ? ", _GetLastError ); return(-1); } return(0); } //---- 入? 祛驽? 镳钿囹??, if ( IsSellTrade(Shift) && EmaStopValue>=High[Shift] && EmaStopValue> Ask) { //---- 铗牮 噱? 雅怂 镱玷鲨? if ( OrderSend( Symbol(), OP_SELL, 1.0, Bid, 5, 0.0, 0.0, "by AlexmanConcursExpert.mq4", _MagicNumber, 0, Red ) < 0 ) { _GetLastError = GetLastError(); Print( "硒栳赅 OrderSend ? ", _GetLastError ); return(-1); } return(0); } return(0); }配合程序 AlexConcursLibrary.ex4
TK29帖子1楼右侧xm竖版广告90-240
个性签名

阅尽天下指标
搬砖开始,始于2014

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
ljwlxrll
注册时间2015-02-10
palllkimo
注册时间2015-07-12
发表于:2015-09-14 14:59只看该作者
3楼
2006年的啊~現在還可以用嗎?
brucecheng
注册时间2015-08-20
发表于:2015-09-28 08:57只看该作者
4楼
个性签名

韬客社区www.talkfx.co

广告
论坛谏言--外汇交易不应是你投资的全部,交易外汇也不应是你生活的全部

本站免责声明:

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

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

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

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

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

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