论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:1159回复:1
mqlbcg
注册时间2010-08-09
恳请版主或各位前辈帮忙使这个 EA能实际应用
楼主发表于:2011-10-14 03:33只看该作者倒序浏览
1楼 电梯直达
电梯直达
#define MAINSEEK 148 #define BARSIZE 44 // LONG_VALUE + 5 * DOUBLE_VALUE extern int Pips = 5; // BEST: (Pips = Spread + 1) extern double Lots = 0.001; extern int MAGIC = 112344; extern int slip = 3; extern double MaximumRisk=0.001; int handle; bool MainError; int GetTime( int Pos ) { int PosTime; FileSeek(handle, MAINSEEK + Pos, SEEK_SET); PosTime = FileReadInteger(handle); return(PosTime); } bool FindTimePlace( int SearchTime ) { int LeftTime, RightTime, PosTime; int Left, Right, Pos; Left = 0; Right = FileSize(handle) - MAINSEEK - BARSIZE; LeftTime = GetTime(Left); RightTime = GetTime(Right); while ((LeftTime < SearchTime) && (SearchTime < RightTime)) { Pos = (Left + Right) / 2; Pos -= Pos % BARSIZE; if (Pos == Left) break; PosTime = GetTime(Pos); if (SearchTime >= PosTime) { Left = Pos; LeftTime = GetTime(Left); } else // if (SearchTime < PosTime) { Right = Pos; RightTime = GetTime(Right); } } if (SearchTime <= RightTime) { FileSeek(handle, Left + MAINSEEK, SEEK_SET); return(TRUE); } else return(FALSE); } double LotSize() { double lot_min = MarketInfo( Symbol(), MODE_MINLOT ); double lot_max = MarketInfo( Symbol(), MODE_MAXLOT ); double lot_step = MarketInfo( Symbol(), MODE_LOTSTEP ); double freemargin = AccountFreeMargin(); int leverage = AccountLeverage(); int lotsize = MarketInfo( Symbol(), MODE_LOTSIZE ); if( lot_min < 0 || lot_max <= 0.0 || lot_step <= 0.0 || lotsize <= 0 ) { Print( "LotSize: invalid MarketInfo() results [", lot_min, ",", lot_max, ",", lot_step, ",", lotsize, "]" ); return(-1); } if( leverage <= 0 ) { Print( "LotSize: invalid AccountLeverage() [", leverage, "]" ); return(-1); } double lot = NormalizeDouble( freemargin * MaximumRisk / leverage / 10.0, 2 ); lot = NormalizeDouble( lot / lot_step, 0 ) * lot_step; if ( lot < lot_min ) lot = lot_min; if ( lot > lot_max ) lot = lot_max; double needmargin = NormalizeDouble( lotsize / leverage * Ask * lot, 2 ); if ( freemargin < needmargin ) { Print( "LotSize: We have no money. Free Margin = ", freemargin ); return(-1); } return(lot); } void init() { handle = FileOpenHistory(Symbol() + Period() + ".hst", FILE_BIN|FILE_READ); if (handle > 0) MainError = TRUE; else { MainError = FALSE; return; } MainError = FindTimePlace(Time[0]); if (!MainError) FileClose(handle); return; } void deinit() { if (MainError) FileClose(handle); return; } bool GetPrices( int& PriceTime, int& PriceLow, int& PriceHigh) { PriceTime = FileReadInteger(handle); FileSeek(handle, DOUBLE_VALUE, SEEK_CUR); PriceLow = FileReadDouble(handle) / Point + 0.1; PriceHigh = FileReadDouble(handle) / Point + 0.1; FileSeek(handle, 2 * DOUBLE_VALUE, SEEK_CUR); if (FileTell(handle) + BARSIZE <= FileSize(handle)) return(TRUE); else return(FALSE); } int GetTimeTrade( double& Price ) { static bool FlagUP = FALSE; static int Min = 999999; static int Max = 0; static int NTime; int ResTime; int PriceTime, PriceLow, PriceHigh; while (TRUE) { if (!GetPrices(PriceTime, PriceLow, PriceHigh)) return(-1); if (FlagUP) { if (PriceHigh > Max) { Max = PriceHigh; NTime = PriceTime; } else if (Max - PriceLow >= Pips) { FlagUP = FALSE; Min = PriceLow; Price = Max * Point; break; } } else // (FlagUP == FALSE) { if (PriceLow < Min) { Min = PriceLow; NTime = PriceTime; } else if (PriceHigh - Min >= Pips) { FlagUP = TRUE; Max = PriceHigh; Price = Min * Point; break; } } } ResTime = NTime; NTime = PriceTime; return(ResTime); } void CloseOrder( int Ticket ) { OrderSelect(Ticket, SELECT_BY_TICKET); if (OrderType() == OP_BUY) OrderClose(Ticket, OrderLots(), Bid, 0); else // (OrderType() == OP_SELL) OrderClose(Ticket, OrderLots(), Ask, 0); return; } int ReverseOrder( int Ticket) { if (Ticket == 0) Ticket = OrderSend(Symbol(), OP_BUY, LotSize(), Ask, slip, 0, 0,0,MAGIC,0,CLR_NONE); // static bool FlagUP = FALSE; else { OrderSelect(Ticket, SELECT_BY_TICKET); if (OrderType() == OP_BUY && OrderMagicNumber() == MAGIC) { OrderClose(Ticket, OrderLots(), Bid, 0); Ticket = OrderSend(Symbol(), OP_SELL, LotSize(), Bid, slip, 0, 0,0,MAGIC,0,CLR_NONE); } else // (OrderType() == OP_SELL) { OrderClose(Ticket, OrderLots(), Ask, 0); Ticket = OrderSend(Symbol(), OP_BUY, LotSize(), Ask, slip, 0, 0,0,MAGIC,0,CLR_NONE); } } return(Ticket); } void System() { static int Ticket = 0; static int NewTime = 0; static double PriceOpen; if (NewTime == 0) NewTime = GetTimeTrade(PriceOpen); else if (NewTime < 0) return; if (Time[0] == NewTime) { if (NormalizeDouble(Bid - PriceOpen, Digits) == 0) { NewTime = GetTimeTrade(PriceOpen); if (NewTime < 0) CloseOrder(Ticket); else Ticket = ReverseOrder(Ticket); } } return; } void start() { if (!MainError) return; System(); return; }
TK29帖子1楼右侧xm竖版广告90-240
个性签名

韬客社区www.talkfx.co

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
boji
注册时间2011-10-17
发表于:2011-10-17 07:36只看该作者
2楼
能实际应用什么意思啊, 这个ea能跑阿 [ 本帖最后由 boji 于 2011-10-17 15:54 编辑 ]
个性签名

韬客社区www.talkfx.co

本站免责声明:

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

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

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

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

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

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