發表 外匯mt4 程式交易程式碼. for EURUSD. - 財經
By Suhail Hany
at 2010-01-29T12:03
at 2010-01-29T12:03
Table of Contents
前幾天逛到的,抓來研究看看,
用mt4跑測試,標的是 EURUSD ,績效卻是本金不斷遞減,
隨便改一些參數,以及小部分程式碼後,發現竟然是能穩定遞增.
測試數據小節,固定下 0.1 手. 時間範圍的選項:不打勾.
用H1跑,下單次數 150 多次,獲利約 500 左右. (不同天,好像也不一樣)
用M5跑,下單次數約 100多次,獲利約300左右.
有些細節我還不是很清楚,算是拋磚引玉,有興趣的歡迎切磋.
// 改自網友 "聖杯" 的範例 by Andrew Chen ,於 高雄.台灣.
// [email protected]
// 2010/1/29
// 原文網址 http://articles.mql4.com/cn/570
// 原作者資訊 Sergey Kovalyov, Dnepropetrovsk (Ukraine),[email protected],ICQ 64015987, http://autograf.dp.ua/
extern int TakeP =11; // 獲利
extern int StopL = 66; // 止損
extern int Distan = 12;
extern int Cls = 25;
extern int period_MA=16;
extern int Prots = 0;
//---------------------------------------------------------------------
int
Nom_bl,
Nom_sl,
total,
bl = 0,
sl = 0,
b = 0,
s = 0;
//---------------------------------------------------------------------
double
OP,
SL,
TP,
dist,
Level,
OP_bl,
OP_sl,
cls,
MA,
spred,
Lot;
int init()
{
Level=MarketInfo(Symbol(),MODE_STOPLEVEL);
Level=(Level+1)*Point;
SL=StopL*Point;
TP=Takep*Point;
dist=Distan*Point;
cls=Cls*Point;
spred=Ask-Bid;
return;
}
int start()
{
//====================================================================
total=OrdersTotal();
bl=0;
sl=0;
b=0;
s=0;
//---------------------------------------------------------------------
for (int i=total; i>=0; i--)
{
if (OrderSelect(i,SELECT_BY_POS)==true &&
OrderSymbol()==Symbol())
{
//---------------------------------------------------------------------
if (OrderType()==OP_BUY)
{
b =1;
Close_B(OrderTicket(),OrderLots());
}
//--------------------------------------------------------------------
if (OrderType()==OP_SELL)
{
s =1;
Close_S(OrderTicket(),OrderLots());
}
//-------------------------------------------------------------------
if (OrderType()==OP_BUYLIMIT)
{
OP_bl=NormalizeDouble(OrderOpenPrice(),Digits);
Nom_bl=OrderTicket();
bl=1;
}
//-------------------------------------------------------------------
if (OrderType()==OP_SELLLIMIT)
{
OP_sl=NormalizeDouble(OrderOpenPrice(),Digits);
Nom_sl=OrderTicket();
sl=1;
}
//------------------------------------------------------------------
}
}
//------------------------------------------------------------------
MA = iMA(NULL,0, period_MA, 0,MODE_LWMA, PRICE_TYPICAL, 0);
Open_order() ;
//==================================================================
return;
}
void Close_B(int Nomber, double lots)
{
if (NormalizeDouble(Bid-OrderOpenPrice(),Digits)>=cls)
{
OrderClose( Nomber, lots, Bid, 1, Yellow);
b = 0;
}
return;
}
void Close_S(int Nomber, double lots)
{
if (NormalizeDouble(OrderOpenPrice()-Ask,Digits)>=cls)
{
OrderClose( Nomber, lots, Ask, 1, Yellow);
s = 0;
}
return;
}
void Open_order()
{
if (b==0 && bl==0)
{
OP=MA-dist;
if(OP>Ask-Level) OP=Ask-Level;
OP=NormalizeDouble(OP,Digits);
OrderSend(Symbol(),OP_BUYLIMIT, Lots(),OP,3,OP-SL,OP+TP,"",0,0,Blue);// Open
bl=1;
}
if (s==0 && sl==0)
{
OP=MA+spred+dist;
if(OP<Bid+Level) OP=Bid+Level;
OP=NormalizeDouble(OP,Digits);
OrderSend(Symbol(),OP_SELLLIMIT,Lots(),OP,3,OP+SL,OP-TP,"",0,0,Red);
sl=1;
}
return;
}
double Lots()
{
Lot=0.1;
return(Lot);
}
--
Tags:
財經
All Comments
By Delia
at 2010-01-30T23:12
at 2010-01-30T23:12
By Leila
at 2010-01-31T19:02
at 2010-01-31T19:02
By Delia
at 2010-02-05T04:32
at 2010-02-05T04:32
By Heather
at 2010-02-06T20:06
at 2010-02-06T20:06
By Olive
at 2010-02-07T15:55
at 2010-02-07T15:55
By Annie
at 2010-02-10T07:11
at 2010-02-10T07:11
By Brianna
at 2010-02-14T21:44
at 2010-02-14T21:44
By Anonymous
at 2010-02-16T01:34
at 2010-02-16T01:34
By Anthony
at 2010-02-17T12:33
at 2010-02-17T12:33
By Tom
at 2010-02-18T08:39
at 2010-02-18T08:39
By Aaliyah
at 2010-02-21T07:51
at 2010-02-21T07:51
By Ivy
at 2010-02-25T10:52
at 2010-02-25T10:52
By David
at 2010-02-26T08:25
at 2010-02-26T08:25
By Erin
at 2010-02-27T12:02
at 2010-02-27T12:02
Related Posts
每天穩賺10點
By James
at 2010-01-28T21:52
at 2010-01-28T21:52
日本的股神BNF
By Rae
at 2010-01-28T20:24
at 2010-01-28T20:24
日本的股神BNF
By Skylar Davis
at 2010-01-28T20:16
at 2010-01-28T20:16
日本的股神BNF
By Dinah
at 2010-01-28T19:16
at 2010-01-28T19:16
永豐E-LEADER程式交易語法問題
By Xanthe
at 2010-01-28T16:35
at 2010-01-28T16:35