论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:3929回复:14
草龙
注册时间2004-12-17
[MT4-EA]箱体突破指标
楼主发表于:2014-02-11 09:24只看该作者倒序浏览
1楼 电梯直达
电梯直达
箱体突破指标 主图指标 mt4指标类型:震荡指标 是否能用在mt4手机版上:否 是否含有未来函数:无 基于如下TIME1_modified.mq4代码| / / |张贴到外汇厂ㄠ杵氀攀渀渀5t | / / |按Markj分线箱形的概念| / / | | / / |修改,使矩形不重叠| / / |这使得色彩选择更加灵活| / / |代码合并,以方便修改| / / |改变B期间的矩形,并添加偏移值| / / |在酒吧选择代码纠正错误| / / |穿越00:00(nextDayA,nextDayB)补充能力| / / |添加唯一ID,以允许多个指标| / / |删除特定的指标矩形添加能力| / / |添加打开/关闭框和每共生线| / / |添加提示 - 可与特斯拉的警报器使用的EA //+------------------------------------------------------------------+ //| BreakOut_BOX_5.mq4 | //| hapalkos | //| 2007.02.16 | //| Code based on TIME1_modified.mq4 shown below | //| posted to Forex Factory by glenn5t | //| Concept of the break-out box form by Markj | //| | //| ++ modified so that rectangles do not overlay | //| ++ this makes color selection more versatile | //| +++ code consolidated to facilitate changes | //| +++ changed Period B rectangle and added offset value | //| +++ corrected error in bar selection code | //| ++++ added ability to cross 00:00(nextDayA, nextDayB) | //| ++++ added Unique ID to allow for multiple indicators | //| ++++ added ability to delete rectangles specific to an indicator | //|+++++ added Open/Close boxes and lines per Accrete | //|+++++ added Alerts - can be used with Tesla's Alerter EA | //+------------------------------------------------------------------+ #property copyright "hapalkos" #property link "" #property indicator_chart_window // Configuration for daily candle bodies extern string UniqueID = "DailyCandles"; // --- Server Time --- GMT+2 --- extern int NumberOfDays = 50; extern string periodA_begin = "00:00"; // Day0 extern string periodA_end = "00:00"; // Day1 extern int nextDayA = 1; // Set to zero if periodA_begin and periodA_end are on the same day. // Set to one if periodA_end is on the next day. extern string periodB_end = "00:00"; // Day1 extern int nextDayB = 1; // Set to zero if periodA_begin and periodB_end are on the same day. // Set to one if periodB_end is on the next day. extern color rectAB_color1 = PowderBlue; extern color rectAB_color2 = LightCoral; // second rectangle color to indicate relative position of Open/Close extern bool rectAB_background = true; // true - filled solid; false - outline extern color rectA_color = Red; extern bool rectA_background = false; // true - filled solid; false - outline extern color rectB1_color = DarkOrchid; extern bool rectB1_background = false; // true - filled solid; false - outline extern int rectB1_band = 0; // Box Break-Out Band for the Period B rectangle extern color rectsB2_color = SkyBlue; extern bool rectsB2_background = true; // true - filled solid, false - outline extern int rectsB2_band = 5; // Box Break-Out Band for the two upper and lower rectangles extern bool OpenClose = true; // false - High/Low boxes; true - Open/Close boxes extern bool rectA_close_begin = true; // false - period A close indication line begins at end of period A; true - period A close line is drawn from beginning of period A extern bool periodB_ALERTS = false; // Alerts are set on the upper and lower sides of the upper and lower rectangles - rectsB2 // rectsB2_band determines the location of the Alerts // Alert_xx added to the decription so that Alerts can be activated by Tesla's Alerter EA //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void init() { DeleteObjects(); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ void deinit() { DeleteObjects(); return(0); } //+------------------------------------------------------------------+ //| Remove all indicator Rectangles | //+------------------------------------------------------------------+ void DeleteObjects() { datetime dtTradeDate=TimeCurrent(); if(OpenClose) string sRectABname = " BoxOC "; else sRectABname = " BoxHL "; for (int i=0; i 5 || TimeDayOfWeek(dtTradeDate) < 1 ) dtTradeDate = decrementTradeDate(dtTradeDate); // Removed Sundays from plots } return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ void start() { datetime dtTradeDate=TimeCurrent(); if(OpenClose) string sRectABname = " BoxOC "; else sRectABname = " BoxHL "; for (int i=0; i 5 || TimeDayOfWeek(dtTradeDate) < 1 ) dtTradeDate = decrementTradeDate(dtTradeDate); // Removed Sundays from plots } } //+------------------------------------------------------------------+ //| Create Objects - Rectangles and Trend lines | //+------------------------------------------------------------------+ void DrawObjects(datetime dtTradeDate, string sObjName, string sTimeBegin, string sTimeEnd, string sTimeObjEnd, color cObjColor1, color cObjColor2, int iOffSet, int iForm, bool background, int nextDayA, int nextDayB, bool OpenClose, bool rectA_close_begin) { datetime dtTimeBegin, dtTimeEnd, dtTimeObjEnd; double dPriceHigh, dPriceLow, dPriceOpen, dPriceClose; int iBarBegin, iBarEnd; string sObjDesc; dtTimeBegin = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeBegin); dtTimeEnd = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeEnd); dtTimeObjEnd = StrToTime(TimeToStr(dtTradeDate, TIME_DATE) + " " + sTimeObjEnd); if(nextDayA == 1) dtTimeEnd = dtTimeEnd + 86400; if(nextDayB == 1) dtTimeObjEnd = dtTimeObjEnd + 86400; if(nextDayA == 1 && TimeDayOfWeek(dtTradeDate) == 5) dtTimeEnd = dtTimeEnd + (2 * 86400); if(nextDayB == 1 && TimeDayOfWeek(dtTradeDate) == 5) dtTimeObjEnd = dtTimeObjEnd + (2 * 86400); iBarBegin = iBarShift(NULL, 0, dtTimeBegin)+1; // added 1 to bar count to correct calculation for highest price for the period iBarEnd = iBarShift(NULL, 0, dtTimeEnd)+1; // added 1 to bar count to correct calculation for lowest price for the period dPriceHigh = High[Highest(NULL, 0, MODE_HIGH, (iBarBegin)-iBarEnd, iBarEnd)]; dPriceLow = Low [Lowest (NULL, 0, MODE_LOW , (iBarBegin)-iBarEnd, iBarEnd)]; dPriceOpen = Open[iBarBegin-1]; // Open/Close added to enable Open/Close rectangles dPriceClose = Close[iBarEnd]; if(OpenClose){ // Selection of extremes of Open/Close values dPriceHigh = MathMax(dPriceOpen, dPriceClose); dPriceLow = MathMin(dPriceOpen, dPriceClose); } //---- High-Low Rectangle - Period A and B combined if(iForm==1){ ObjectCreate(sObjName, OBJ_RECTANGLE, 0, 0, 0, 0, 0); ObjectSet(sObjName, OBJPROP_TIME1 , dtTimeBegin); ObjectSet(sObjName, OBJPROP_TIME2 , dtTimeObjEnd); ObjectSet(sObjName, OBJPROP_PRICE1, dPriceHigh); ObjectSet(sObjName, OBJPROP_PRICE2, dPriceLow); ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID); if(dPriceClose= (dPriceHigh + iOffSet*Point)) Alert(sObjName," - ",dPriceHigh + iOffSet*Point); } //---- Period B LOW Alert if(iForm==9){ ObjectCreate(sObjName,OBJ_TREND,0,0,0,0); ObjectSet(sObjName, OBJPROP_TIME1 , dtTimeEnd); ObjectSet(sObjName, OBJPROP_TIME2 , dtTimeObjEnd); ObjectSet(sObjName, OBJPROP_PRICE1, dPriceLow - iOffSet*Point); ObjectSet(sObjName, OBJPROP_PRICE2, dPriceLow - iOffSet*Point); ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(sObjName, OBJPROP_COLOR, cObjColor1); ObjectSet(sObjName, OBJPROP_WIDTH, 1); ObjectSet(sObjName, OBJPROP_BACK, background); ObjectSet(sObjName, OBJPROP_RAY,false); sObjDesc = StringConcatenate("Period B - LOW Alert_01 - ",dPriceLow - iOffSet*Point); ObjectSetText(sObjName, sObjDesc,10,"Times New Roman",Black); // if(Bid <= (dPriceLow - iOffSet*Point)) Alert(sObjName," - ",dPriceLow - iOffSet*Point); } } //+------------------------------------------------------------------+ //| Decrement Date to draw objects in the past | //+------------------------------------------------------------------+ datetime decrementTradeDate (datetime dtTimeDate) { int iTimeYear=TimeYear(dtTimeDate); int iTimeMonth=TimeMonth(dtTimeDate); int iTimeDay=TimeDay(dtTimeDate); int iTimeHour=TimeHour(dtTimeDate); int iTimeMinute=TimeMinute(dtTimeDate); iTimeDay--; if (iTimeDay==0) { iTimeMonth--; if (iTimeMonth==0) { iTimeYear--; iTimeMonth=12; } // Thirty days hath September... if (iTimeMonth==4 || iTimeMonth==6 || iTimeMonth==9 || iTimeMonth==11) iTimeDay=30; // ...all the rest have thirty-one... if (iTimeMonth==1 || iTimeMonth==3 || iTimeMonth==5 || iTimeMonth==7 || iTimeMonth==8 || iTimeMonth==10 || iTimeMonth==12) iTimeDay=31; // ...except... if (iTimeMonth==2) if (MathMod(iTimeYear, 4)==0) iTimeDay=29; else iTimeDay=28; } return(StrToTime(iTimeYear + "." + iTimeMonth + "." + iTimeDay + " " + iTimeHour + ":" + iTimeMinute)); } //+------------------------------------------------------------------+ // // // /* //+------------------------------------------------------------------+ //| times.mq4 | //| | //| Made/Modified by sh _j . | //+------------------------------------------------------------------+ #property copyright "Morning Star" #property link "http://Grand Forex.ir" #property indicator_chart_window extern int NumberOfDays = 50; extern string AsiaBegin = "01:00"; extern string AsiaEnd = "09:00"; extern color AsiaColor = Red; extern string EurBegin = "09:00"; extern string EurEnd = "16:00"; extern color EurColor = Blue; extern string USABegin = "16:00"; extern string USAEnd = "23:00"; extern color USAColor = Tan; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void init() { DeleteObjects(); for (int i=0; i5) dt=decDateTradeDay(dt); } } void DrawObjects(datetime dt, string no, string tb, string te) { datetime t1, t2; double p1, p2; int b1, b2; t1=StrToTime(TimeToStr(dt, TIME_DATE)+" "+tb); t2=StrToTime(TimeToStr(dt, TIME_DATE)+" "+te); b1=iBarShift(NULL, 0, t1); b2=iBarShift(NULL, 0, t2); p1=High[Highest(NULL, 0, MODE_HIGH, b1-b2, b2)]; p2=Low [Lowest (NULL, 0, MODE_LOW , b1-b2, b2)]; ObjectSet(no, OBJPROP_TIME1 , t1); ObjectSet(no, OBJPROP_PRICE1, p1); ObjectSet(no, OBJPROP_TIME2 , t2); ObjectSet(no, OBJPROP_PRICE2, p2); } datetime decDateTradeDay (datetime dt) { int ty=TimeYear(dt); int tm=TimeMonth(dt); int td=TimeDay(dt); int th=TimeHour(dt); int ti=TimeMinute(dt); td--; if (td==0) { tm--; if (tm==0) { ty--; tm=12; } if (tm==1 || tm==3 || tm==5 || tm==7 || tm==8 || tm==10 || tm==12) td=31; if (tm==2) if (MathMod(ty, 4)==0) td=29; else td=28; if (tm==4 || tm==6 || tm==9 || tm==11) td=30; } return(StrToTime(ty+"."+tm+"."+td+" "+th+":"+ti)); } //+------------------------------------------------------------------+ */ BreakOut_BOX_5_DailyCandles_OCbox_indicator.jpgBreakOut_BOX_5_DailyCandles_OCbox_indicator.jpg
TK29帖子1楼右侧xm竖版广告90-240
个性签名

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

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
microscale
注册时间2014-02-08
yonger
注册时间2015-06-09
发表于:2016-04-05 17:12只看该作者
3楼
谢谢楼主分享
linxiaohua
注册时间2016-04-04
发表于:2016-04-16 05:19只看该作者
4楼
灌水赚通宝,谢谢分享!!
xinma
注册时间2016-03-19
honlin
注册时间2016-04-10
发表于:2016-04-17 08:44只看该作者
6楼
灌水赚通宝,谢谢分享!!
qi123
注册时间2014-09-26
ccs
注册时间2016-04-15
发表于:2016-07-18 12:35只看该作者
8楼
多谢分享
个性签名

韬客社区www.talkfx.co

wowin
注册时间2010-09-13
lionvox
注册时间2016-07-25
sstt
注册时间2016-05-01
JSTZ
注册时间2016-09-03
lzcygw
注册时间2016-09-04
发表于:2016-09-25 07:54只看该作者
14楼
楼主是个好人,都有源码
个性签名

韬客社区www.talkfx.co

广告
论坛谏言--外汇交易不应是你投资的全部,交易外汇也不应是你生活的全部
blackrain
注册时间2019-06-19

本站免责声明:

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

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

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

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

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

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