论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:733回复:0
草龙
注册时间2004-12-17
[MT4-EA]E-Bay_Clone_1v1程序
楼主发表于:2014-03-12 10:27只看该作者倒序浏览
1楼 电梯直达
电梯直达
//+---------------------------------------------------------------------+ //| E-Bay_Clone_1v1.mq4 | //| Copyright ? 2007, [email protected] | //| [email protected] | //+---------------------------------------------------------------------+ #property copyright "Copyright ? 2007, [email protected]" #property link "[email protected]" // This Expert created by => Copy Over Paste Yippee Code Assembly Technician <= , aka "C.O.P.Y.C.A.T." // For Demo Testing Only , [email protected] will not accept responsibility for any loses incurred // If you're not sure what incurred means , go here http://dictionary.reference.com/browse/incurred #include #include extern bool SuspendAfterClose = False; extern double StartLots = 0.01; extern bool UseMM = False; extern int PipsBetweenTrades = 20; extern double TakeProfitPips = 2; extern bool ReverseTrading = True; int SendRequest; bool FirstRun = True; string Accfreemargin; string MaxLots; string usedmargin; string openbuys; string opensells; extern bool ShowComments = True; int Magic; int cnt; double lotsi; double mylotsi; int OpenOrders; double Profit; double lotstote; double LastLots; int buytote; double buylots; double LastBuyPrice; double LastBuyLots; double BuyPips; int selltote; double selllots; double LastSellPrice; double LastSellLots; double SellPips; extern bool CloseM = False; double goober; //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- if (!IsDemo())return(0); lotsi = StartLots; if (UseMM) { lotsi=MathFloor(AccountBalance()/2000)*StartLots; } if (lotsi < StartLots) lotsi = StartLots; SendRequest = -1; if (FirstRun) { if (Symbol()=="EURUSD"){Magic=110+ReverseTrading;} if (Symbol()=="GBPUSD"){Magic=220+ReverseTrading;} if (Symbol()=="USDJPY"){Magic=330+ReverseTrading;} if (Symbol()=="USDCHF"){Magic=440+ReverseTrading;}// copy this line , paste below it // after you paste , change "USDCHF" to whatever symbol you are running and change Magic= "xxx" +ReverseTrading;. if (Magic < 2){Magic=5+ReverseTrading;} Accfreemargin = AccountNumber()+"_Accfreemargin"; MaxLots = AccountNumber()+"_"+Symbol()+"_"+Magic+"_MaxLots"; usedmargin = AccountNumber()+"_"+Symbol()+"_"+Magic+"_usedmargin"; openbuys = AccountNumber()+"_"+Symbol()+"_"+Magic+"_openbuys"; opensells = AccountNumber()+"_"+Symbol()+"_"+Magic+"_opensells"; if (!GlobalVariableCheck(Accfreemargin)) { GlobalVariableSet(Accfreemargin,200000000); } if (!GlobalVariableCheck(MaxLots)) { GlobalVariableSet(MaxLots,lotstote); } if (!GlobalVariableCheck(usedmargin)) { GlobalVariableSet(usedmargin,0); } if (!GlobalVariableCheck(openbuys)) { GlobalVariableSet(openbuys,buytote); } if (!GlobalVariableCheck(opensells)) { GlobalVariableSet(opensells,selltote); } FirstRun=False; } OpenOrders = 0; Profit = 0; lotstote = 0; LastLots = 0; buytote = 0; buylots = 0; LastBuyPrice = 0; LastBuyLots = 0; BuyPips = 0; selltote = 0; selllots = 0; LastSellPrice = 0; LastSellLots = 0; SellPips = 0; mylotsi = 0; if (OrdersTotal() > 0) { for (cnt = 0; cnt < OrdersTotal(); cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if ((OrderSymbol()==Symbol()) && (OrderMagicNumber() == Magic)) { OpenOrders++; Profit+=OrderProfit(); lotstote+=OrderLots(); LastLots = OrderLots(); if ((OrderSymbol()==Symbol()) && (OrderType()==OP_BUY) && (OrderMagicNumber() == Magic)) { buytote++; buylots+=OrderLots(); LastBuyPrice = OrderOpenPrice(); LastBuyLots = OrderLots(); BuyPips += (OrderClosePrice()-OrderOpenPrice()); } if ((OrderSymbol()==Symbol()) && (OrderType()==OP_SELL) && (OrderMagicNumber() == Magic)) { selltote++; selllots-=OrderLots(); LastSellPrice = OrderOpenPrice(); LastSellLots = OrderLots(); SellPips += (OrderOpenPrice()-OrderClosePrice()); } } } } if ((CloseM) && (OpenOrders <= 0)) { CloseM = False; return(0); } if ((CloseM) && (OpenOrders > 0)) CloseAll(); if (!CloseM) { if ((BuyPips+SellPips) >= TakeProfitPips*Point) { CloseM = True; CloseAll(); } if ((!SuspendAfterClose) && (OpenOrders <= 0)) { if ((SuspendAfterClose) && (OpenOrders <= 0)) { return(0); } //if ( LastSellPrice = 0; LastBuyPrice = 0; RequestBuy(); } if ((OpenOrders == 1) && (selltote == 0)) { RequestSell(); } if ( (!ReverseTrading) && (OpenOrders >= 2) ) { if (NormalizeDouble(Bid,Digits) <= (LastSellPrice-(PipsBetweenTrades*Point)) ) { RequestAdditionalSell(); } else if (NormalizeDouble(Ask,Digits) >= (LastBuyPrice+(PipsBetweenTrades*Point)) ) { RequestAdditionalBuy(); } } if ( (ReverseTrading) && (OpenOrders >= 2) ) { if (NormalizeDouble(Ask,Digits) <= (LastBuyPrice-(PipsBetweenTrades*Point)) ) { RequestAdditionalBuy(); } else if (NormalizeDouble(Bid,Digits) >= (LastSellPrice+(PipsBetweenTrades*Point)) ) { RequestAdditionalSell(); } } } if (AccountFreeMargin() < GlobalVariableGet(Accfreemargin)) GlobalVariableSet(Accfreemargin,AccountFreeMargin()); if (lotstote > GlobalVariableGet(MaxLots)) GlobalVariableSet(MaxLots,lotstote); if (buytote > GlobalVariableGet(openbuys)) GlobalVariableSet(openbuys,buytote); if (selltote > GlobalVariableGet(opensells)) GlobalVariableSet(opensells,selltote); if ((MarketInfo(Symbol(),MODE_MARGINREQUIRED)*lotstote) != GlobalVariableGet(usedmargin)) { GlobalVariableSet(usedmargin,(MarketInfo(Symbol(),MODE_MARGINREQUIRED)*lotstote)); } if (ShowComments) { Comment("\n LastBuyPrice = ",DoubleToStr(LastBuyPrice,Digits)," , LastSellPrice = ",DoubleToStr(LastSellPrice,Digits), "\n Account Lowest Free Margin = $ ",DoubleToStr(GlobalVariableGet(Accfreemargin),2)," , Max Open Lots = ",DoubleToStr(GlobalVariableGet(MaxLots),2), "\n Open Buys = ",buytote," , Open Sells = ",selltote," , Margin In Use = $ ",DoubleToStr(GlobalVariableGet(usedmargin),2), "\n Pips Between Trades = ",DoubleToStr(PipsBetweenTrades*Point,Digits)," , Start Lots = ",StartLots," , UseMM = ",UseMM," , Start Lots = ",lotsi, "\n Open Buy Lots = ",DoubleToStr(buylots,2)," , Open Sell Lots = ",DoubleToStr(selllots,2)," , Total Lots Bias = ",DoubleToStr(buylots+selllots,2), "\n BuyPips = ",DoubleToStr(BuyPips,Digits)," , SellPips = ",DoubleToStr(SellPips,Digits)," , BuyPips+SellPips = ",DoubleToStr(BuyPips+SellPips,Digits), "\n SuspendAfterClose = ",SuspendAfterClose," , Magic = ",Magic," , Margin Required For 1 Lot = $ ",DoubleToStr(MarketInfo(Symbol(),MODE_MARGINREQUIRED),2)); } if ((!ShowComments) && (goober != Time[0])) { Comment(""); goober = Time[0]; } //---- return(0); } //+------------------------------------------------------------------+ void CloseAll() { int crumbs = OrdersTotal(); for (cnt = 0; cnt < crumbs; cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if ((Symbol() == Symbol()) && (OrderMagicNumber() == Magic)) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0,White); CloseM = True; } } } void RequestAdditionalBuy() { SendRequest = -1; mylotsi = LastLots * 2; if (mylotsi>100) { mylotsi=100; } SendRequest = OrderSend(Symbol(),OP_BUY,mylotsi,Ask,3,0,0,""+Symbol()+" E-Bay_Clone_1v1 "+Magic+"",Magic,0,Blue); if (SendRequest < 0) { Print("Error - OrderSend Buy @ ",Ask); ReportError(); } } void RequestAdditionalSell() { SendRequest = -1; mylotsi = LastLots * 2; if (mylotsi>100) { mylotsi=100; } SendRequest = OrderSend(Symbol(),OP_SELL,mylotsi,Bid,3,0,0,""+Symbol()+" E-Bay_Clone_1v1 "+Magic+"",Magic,0,Red); if (SendRequest < 0) { Print("Error - OrderSend Sell @ ",Bid); ReportError(); } } void RequestBuy() { if ((!SuspendAfterClose) && (buytote == 0) && (!CloseM)) { SendRequest = -1; SendRequest = OrderSend(Symbol(),OP_BUY,lotsi,Ask,3,0,0,""+Symbol()+" E-Bay_Clone_1v1 "+Magic+"",Magic,0,Blue); if (SendRequest < 0) { Print("Error - OrderSend Buy @ ",Ask); ReportError(); } } } void RequestSell() { if ((!SuspendAfterClose) && (selltote == 0) && (!CloseM)) { SendRequest = -1; SendRequest = OrderSend(Symbol(),OP_SELL,lotsi,Bid,3,0,0,""+Symbol()+" E-Bay_Clone_1v1 "+Magic+"",Magic,0,Red); if (SendRequest < 0) { Print("Error - OrderSend Sell @ ",Bid); ReportError(); } } } void ReportError() { int err = GetLastError(); Print("Error(",err,"): ", ErrorDescription(err)); }
TK29帖子1楼右侧xm竖版广告90-240
个性签名

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

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告

本站免责声明:

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

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

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

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

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

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