论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:1501回复:13
草龙
注册时间2004-12-17
[MT4指标]通道用ea指标
楼主发表于:2014-10-19 23:17只看该作者倒序浏览
1楼 电梯直达
电梯直达
通道用ea指标 //+------------------------------------------------------------------+ //| Charles.mq4 | //| Copyright 2012, AlFa Corp. | //| alessio.fabiani @ gmail.com | //+------------------------------------------------------------------+ #property copyright \"Copyright 2012, AlFa\" #property link \"alessio.fabiani @ gmail.com\" #define VER \"2.1.8\" #define DECIMAL_CONVERSION 10 extern string Comment_1 = \" -- Comma separated list of Symbol Pairs: EURUSD,USDCHF\"; extern string Comment_1a = \" --- must be equal to the string of your account provider.\"; //extern string Symbols = \"EURUSD,EURGBP,EURJPY,CHFJPY,GBPUSD,GBPJPY,GBPCHF,GBPAUD,USDCAD,USDCHF,USDJPY,AUDNZD,AUDUSD,NZDUSD\"; extern string Symbols = \"\"; extern int MagicNumber = 3939; extern double xFactor = 2; extern string TimeSet = \"07:32\"; extern string Comment_2 = \" -- Balance percentage order balance and Lot value\"; extern double RiskPercent = 10; extern string Comment_3 = \" -- Percentage of the risk for each Lot\"; extern string Comment_3a = \" --- auto-adapted to number of pairs.\"; extern double RiskPerTrade = 30; extern int MaxAllowedOrders = 15; extern int MaxOpenHours = 0; extern int ProfitCheckPeriod = 3; extern string Comment_4 = \" -- Whether or not use more strict supports and resistances\"; extern bool Aggressive = false; extern bool UsePivots = true; extern string Comment_5 = \" -- Whether or not leave open profitable orders\"; extern int FastPeriod = 18; extern int SlowPeriod = 60; extern int Selectivity = 14; extern string Comment_6 = \" -- Fixed value if RiskPerTrade == 0\"; extern double Lots = 0.01; extern int Slippage = 3; extern string Comment_7 = \" -- Set to true if broker is ECN/STP needing stops adding after order\"; extern bool ECN = true; extern double MarginPercent = 20; extern string Comment_8 = \" -- On all orders\"; extern int StopLoss = 0; extern int TrailStart = 25; extern int TrailingAmount = 5; extern int TakeProfit = 25; extern string Comment_9 = \" -- Whether or not manage ALL opened orders (manual too)\"; extern bool AllOrders = true; extern string Comment_10 = \" -- Whether or not compute the Profit on ALL pairs\"; extern bool AllSymbols = false; extern string Comment_11 = \" -- Log to console or to a file\"; extern bool LogToFile = false; extern string Comment_12 = \" -- On init delete all pending orders\"; extern bool InitResetOrders = true; extern string Comment_13 = \" -- Trading Time Management\"; extern int StartHour = 0; extern int EndHour = 24; extern bool CloseAllNow = false; extern int FridayCloseTime = 0; int Anchor, PendingBuy, PendingSell, Buys, Sells, i, StopLevel, Spread; int MaxOpenOrders; double BuyLots, SellLots, PendingBuyLots, PendingSellLots; double Amount, Profit, LastProfit, Up, Dw, SL, TP; double LotsValue, LotsHedgeValue; double MaxPrice,MinPrice,MaxOpenPrice,MinOpenPrice; bool isInGain=false, blockConditionHit, unlockOrdersPlaced=false; int LastOrderTicket, UnlockingOrderTicket, Result, Error; int Delta; //Order price shift (in points) from High/Low price int LastDay; double stopLoss, delta; double trailStart, trailAmount, takeProfit; double lastBarTime,lastpM5BarTime,lastpM15BarTime,lastpH1BarTime; string SymbolsArray[0], CurrentSymbol; bool canSell[0], canBuy[0], bullish[0], bearish[0]; bool Inited[0], DayStart[0], inited=false; bool tradingAllowed=false; double Pivot[0]; double Resist1[0]; double Resist2[0]; double Resist3[0]; double Support1[0]; double Support2[0]; double Support3[0]; double pPoint[0]; bool isCals[0]; double r1[0] , s1[0] ,s2[0], r2[0], r3[0], s3[0]; //+------------------------------------------------------------------+ //| Init function | //+------------------------------------------------------------------+ void init() { RefreshRates(); if(LogToFile){startFile();} Amount = 1.0; Anchor = 250; Delta = 5; LastDay = 1; PendingBuy = 0; PendingSell = 0; Buys = 0; Sells = 0; BuyLots = 0; SellLots = 0; PendingBuyLots = 0; PendingSellLots = 0; LastOrderTicket = -1; UnlockingOrderTicket = -1; string delim = \",\"; int size; if(StringLen(Symbols)==0) { size = 1; } else { size = 1+StringFindCount(Symbols,delim); } MaxOpenOrders = MaxAllowedOrders/size; ArrayResize(SymbolsArray,size); if(StringLen(Symbols)>0){StrToStringArray(Symbols,SymbolsArray,delim);} ArrayResize(canSell,size); ArrayResize(canBuy,size); ArrayResize(Inited,size); ArrayResize(DayStart,size); ArrayResize(blockConditionHit,size); ArrayResize(Pivot,size); ArrayResize(Resist1,size); ArrayResize(Resist2,size); ArrayResize(Support1,size); ArrayResize(Support2,size); ArrayResize(Support3,size); ArrayResize(Resist3,size); ArrayResize(pPoint,size); ArrayResize(isCals,size); ArrayResize(r1,size); ArrayResize(s1,size); ArrayResize(s2,size); ArrayResize(r2,size); ArrayResize(r3,size); ArrayResize(s3,size); ArrayResize(bullish,size); ArrayResize(bearish,size); for(i=0; i0) {for(i=Total-1; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == TRUE) { Pos=OrderType(); if((Pos==OP_BUYSTOP)||(Pos==OP_SELLSTOP)||(Pos==OP_BUYLIMIT)||(Pos==OP_SELLLIMIT)){Result=OrderDelete(OrderTicket(), CLR_NONE);} if(Result<=0){Error=GetLastError();} else Error=0; } } } } //+------------------------------------------------------------------+ //| Start function | //+------------------------------------------------------------------+ void start() { bool pM5=false,pM15=false,pH1=false; if((TimeCurrent()-lastpM5BarTime)/60>=PERIOD_M5) { pM5=true; lastpM5BarTime=TimeCurrent(); } if((TimeCurrent()-lastpM15BarTime)/60>=PERIOD_M15) { pM15=true; lastpM15BarTime=TimeCurrent(); } if((TimeCurrent()-lastpH1BarTime)/60>=PERIOD_H1) { pH1=true; lastpH1BarTime=TimeCurrent(); } int SystemPeriod=1; tradingAllowed=false; if((StartHour < EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour > EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if(DayOfWeek() != 5 || FridayCloseTime==0 || Hour()0 && Hour()>=FridayCloseTime) ) { ForceCloseAllOpenOrders(); DeleteAllPendingOrders(); } if( inited==false || (TimeCurrent() - lastBarTime)/60 >= SystemPeriod ) { if(inited==false) inited=true; int s; for(s=0; s0) { CurrentSymbol = StringTrim(SymbolsArray[s]); } else { CurrentSymbol = Symbol(); } if(Inited[s] == false) { if(InitResetOrders == true) { int Pos; int Total=OrdersTotal(); if(Total>0) { for(i=Total-1; i>=0; i--) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == TRUE) { if(OrderSymbol()!=CurrentSymbol) { continue; }//if if(AllOrders==false && OrderMagicNumber()!=MagicNumber) { continue; }//if Pos=OrderType(); if((Pos==OP_BUYSTOP)||(Pos==OP_SELLSTOP)||(Pos==OP_BUYLIMIT)||(Pos==OP_SELLLIMIT)){Result=OrderDelete(OrderTicket(), CLR_NONE);} //----------------------- if(Result<0){Error=GetLastError();Log(\"LastError = \"+Error);} else Error=0; //----------------------- }//if }//for }//if }//if Inited[s]=true; }//if Spread = MarketInfo(CurrentSymbol, MODE_SPREAD); StopLevel = MarketInfo(CurrentSymbol, MODE_STOPLEVEL) + Spread; if (MarketInfo(CurrentSymbol, MODE_DIGITS) == 3 || MarketInfo(CurrentSymbol, MODE_DIGITS) == 5) { stopLoss = NormalizeDouble(StopLoss* DECIMAL_CONVERSION * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); delta = NormalizeDouble(Delta * DECIMAL_CONVERSION * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); trailStart = NormalizeDouble(TrailStart * DECIMAL_CONVERSION * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); trailAmount = NormalizeDouble(TrailingAmount * DECIMAL_CONVERSION * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); takeProfit = NormalizeDouble(TakeProfit * DECIMAL_CONVERSION * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); } else { stopLoss = NormalizeDouble(StopLoss * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); delta = NormalizeDouble(Delta * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); trailStart = NormalizeDouble(TrailStart * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); trailAmount = NormalizeDouble(TrailingAmount * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); takeProfit = NormalizeDouble(TakeProfit * MarketInfo(CurrentSymbol, MODE_POINT),MarketInfo(CurrentSymbol, MODE_DIGITS)); } if( stopLoss>0 && stopLossMaxPrice) MaxOpenPrice = MarketInfo(CurrentSymbol,MODE_ASK)+StopLevel*MarketInfo(CurrentSymbol, MODE_POINT); if (MarketInfo(CurrentSymbol,MODE_BID)-StopLevel*MarketInfo(CurrentSymbol, MODE_POINT)=20) { //Alert(TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS) + \" -- \" + Volatility1 + \" / \" + Volatility2); if( iClose(CurrentSymbol,PERIOD_M15,1)>iOpen(CurrentSymbol,PERIOD_M15,1) ) { //SignalBufferSellLimit=iHigh(CurrentSymbol,PERIOD_M5,iHighest(CurrentSymbol,PERIOD_M5,MODE_HIGH,3,0)); SignalBufferSellStop=NormalizeDouble( iLow(CurrentSymbol,PERIOD_M15,1)-delta+((iHigh(CurrentSymbol,PERIOD_M15,1)-iLow(CurrentSymbol,PERIOD_M15,1))/2), MarketInfo(CurrentSymbol,MODE_DIGITS)); } else { //SignalBufferBuyLimit=iLow(CurrentSymbol,PERIOD_M5,iLowest(CurrentSymbol,PERIOD_M5,MODE_LOW,3,0)); SignalBufferBuyStop=NormalizeDouble( iLow(CurrentSymbol,PERIOD_M15,1)+delta-((iLow(CurrentSymbol,PERIOD_M15,1)-iHigh(CurrentSymbol,PERIOD_M15,1))/2), MarketInfo(CurrentSymbol,MODE_DIGITS)); } } if(SignalBufferSellStop>0 && (Sells+Buys)<=MaxOpenOrders) { OpenOrder(CurrentSymbol,LotsValue,OP_SELLSTOP,SignalBufferSellLimit); } if(SignalBufferBuyStop>0 && (Sells+Buys)<=MaxOpenOrders) { OpenOrder(CurrentSymbol,LotsValue,OP_BUYSTOP,SignalBufferBuyLimit); } if(SignalBufferSellLimit>0 && (Sells+Buys)<=MaxOpenOrders) { OpenOrder(CurrentSymbol,LotsValue,OP_SELLLIMIT,SignalBufferSellLimit); } if(SignalBufferBuyLimit>0 && (Sells+Buys)<=MaxOpenOrders) { OpenOrder(CurrentSymbol,LotsValue,OP_BUYLIMIT,SignalBufferBuyLimit); } } if(pM15==true) { // CHECK TREND CONDITION bullish[s]=((RSI>55&&RSIM1>55&&RSIL1>55)&&(RSIL2<50&&RSIM2<50&&RSI2<50)&&EMAS1>EMAF1); bearish[s]=((RSI<55&&RSIM1<55&&RSIL1<55)&&(RSIL2>50&&RSIM2>50&&RSI2>50)&&EMAS1 NormalizeDouble(MarketInfo(CurrentSymbol,MODE_BID)+delta+(Spread*MarketInfo(CurrentSymbol, MODE_POINT)),MarketInfo(CurrentSymbol, MODE_DIGITS))) { Up = Up1; } else if (Up4 > NormalizeDouble(MarketInfo(CurrentSymbol,MODE_BID)+delta+(Spread*MarketInfo(CurrentSymbol, MODE_POINT)),MarketInfo(CurrentSymbol, MODE_DIGITS))) { Up = Up4; } else { Up = UpA; } if((PendingSell==0 && PendingBuy==0) || (TimeStr(CurTime())==TimeSet)) { RefreshRates(); if(TimeStr(CurTime())==TimeSet && DayStart[s]==false) { Log(\"[DAY RESET: \"+TimeToStr(TimeCurrent())+\"]\"); DeleteAllPendingOrders(); Dw=MinOpenPrice; Up=MaxOpenPrice; DayStart[s]=true; } else if(TimeStr(CurTime())!=TimeSet && DayStart[s]==true) { DayStart[s]=false; } SL=0; TP=0; if(PendingSell == 0) { if(canSell[s]) { if(ECN == false && stopLoss > 0){SL=Dw+stopLoss;} if(tradingAllowed==true && AccountFreeMarginCheck(CurrentSymbol,OP_SELL,LotsHedgeValue)>=(AccountEquity()*MarginPercent/100) && GetLastError()!=134) { //MaloMax: la chiusura di molti ordini puo dare problemi per la lentezza di esecuzione. Tra una chiusura e l\'altra potresti inserire questo codice while (!IsTradeAllowed()) Sleep(100); RefreshRates(); Result=OrderSend(CurrentSymbol,OP_SELLSTOP,LotsHedgeValue,Dw,Slippage,SL,TP,\"Charles_\"+VER,MagicNumber,0,Red); //----------------------- if(Result<0){Error=GetLastError();Log(\"LastError [CORE;OP_SELLSTOP]= \"+Error+\" - Dw# \"+Dw+\" - Ask#\"+MarketInfo(CurrentSymbol,MODE_ASK));} else Error=0; //----------------------- } } } if(PendingBuy == 0 && Error==0) { if(canBuy[s]) { if(ECN == false && stopLoss > 0){SL=Up-stopLoss;} if(tradingAllowed==true && AccountFreeMarginCheck(CurrentSymbol,OP_BUY,LotsHedgeValue)>=(AccountEquity()*MarginPercent/100) && GetLastError()!=134) { //MaloMax: la chiusura di molti ordini puo dare problemi per la lentezza di esecuzione. Tra una chiusura e l\'altra potresti inserire questo codice while (!IsTradeAllowed()) Sleep(100); RefreshRates(); Result=OrderSend(CurrentSymbol,OP_BUYSTOP,LotsHedgeValue,Up,Slippage,SL,TP,\"Charles_\"+VER,MagicNumber,0,Blue); //----------------------- if(Result<0){Error=GetLastError();Log(\"LastError [CORE;OP_BUYSTOP] = \"+Error+\" - Dw# \"+Up+\" - Bid#\"+MarketInfo(CurrentSymbol,MODE_BID));} else Error=0; //----------------------- } } } } else { if((PendingSell == 0 && PendingBuy > 0) || (PendingSell > 0 && PendingBuy == 0)) { RefreshRates(); SL=0; TP=0; if(PendingSell == 0 && PendingBuy > 0) { if(canSell[s]) { if(ECN == false && stopLoss > 0){SL=Dw+stopLoss;} if(tradingAllowed==true && AccountFreeMarginCheck(CurrentSymbol,OP_SELL,LotsHedgeValue)>=(AccountEquity()*MarginPercent/100) && GetLastError()!=134) { //MaloMax: la chiusura di molti ordini puo dare problemi per la lentezza di esecuzione. Tra una chiusura e l\'altra potresti inserire questo codice while (!IsTradeAllowed()) Sleep(100); RefreshRates(); Result=OrderSend(CurrentSymbol,OP_SELLSTOP,LotsHedgeValue,Dw,Slippage,SL,TP,\"Charles_\"+VER,MagicNumber,0,Red); //----------------------- if(Result<0){Error=GetLastError();Log(\"LastError [CORE - HEDGE;OP_SELLSTOP]= \"+Error);} else if(Result!=0) { Error=0; } //----------------------- } } } if(PendingSell > 0 && PendingBuy == 0 && Error==0) { if(canBuy[s]) { if(ECN == false && stopLoss > 0){SL=Up-stopLoss;} if(tradingAllowed==true && AccountFreeMarginCheck(CurrentSymbol,OP_BUY,LotsHedgeValue)>=(AccountEquity()*MarginPercent/100) && GetLastError()!=134) { //MaloMax: la chiusura di molti ordini puo dare problemi per la lentezza di esecuzione. Tra una chiusura e l\'altra potresti inserire questo codice while (!IsTradeAllowed()) Sleep(100); RefreshRates(); Result=OrderSend(CurrentSymbol,OP_BUYSTOP,LotsHedgeValue,Up,Slippage,SL,TP,\"Charles_\"+VER,MagicNumber,0,Blue); //----------------------- if(Result<0){Error=GetLastError();Log(\"LastError [CORE - HEDGE;OP_BUYSTOP] = \"+Error);} else if(Result!=0) { Error=0; } //----------------------- } } } } } } [/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s][/s]
TK29帖子1楼右侧xm竖版广告90-240
个性签名

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

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
叶德运
注册时间2015-08-06
haoyioa
注册时间2015-09-02
发表于:2015-09-02 12:02只看该作者
3楼
因为比较贵,所以没舍得买
个性签名

韬客社区www.talkfx.co

身未动心已远
注册时间2015-05-13
发表于:2015-09-04 01:57只看该作者
4楼
这是EA还是指标呢?
个性签名

韬客社区www.talkfx.co

身未动心已远
注册时间2015-05-13
发表于:2015-09-04 01:57只看该作者
5楼
楼主能不能说明一下!
caigang
注册时间2015-08-29
发表于:2015-09-06 07:33只看该作者
7楼
好东西 !!!
个性签名

韬客社区www.talkfx.co

黄金分割法
注册时间2015-03-28
陣雨至
注册时间2015-10-12
发表于:2015-11-02 12:43只看该作者
9楼
謝謝分享。非常感謝樓主!
个性签名

韬客社区www.talkfx.co

wangteng
注册时间2015-10-23
发表于:2015-11-09 05:09只看该作者
10楼
能稍微解释一下子吗
hycen
注册时间2015-11-08
plm
注册时间2015-10-29
发表于:2015-11-10 10:36只看该作者
12楼
楼主能不能说明一下!
个性签名

韬客社区www.talkfx.co

laizz
注册时间2010-07-29
taokehuiyuan
注册时间2016-02-21
goodday
注册时间2016-12-06
发表于:2016-12-07 10:15只看该作者
15楼
谢楼主的分享

本站免责声明:

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

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

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

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

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

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