[MT4-EA]专家比赛测试代码
主程序//+------------------------------------------------------------------+
//| 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
发表于:2015-02-10 12:03只看该作者
2楼
到底好用不好用
韬客社区www.talkfx.co
发表于:2015-09-14 14:59只看该作者
3楼
2006年的啊~現在還可以用嗎?
韬客社区www.talkfx.co