//+------------------------------------------------------------------+ //| ttm-trend.mq4 | //| Copyright © 2005, Nick Bilak, beluck[AT]gmail.com | //| | //| MODIFIED_VERSION_ttm-trend-3 | //| MODIFIED BY AVERY T. HORTON, JR. AKA THERUMPLEDONE@GMAIL.COM | //| I am NOT the ORIGINAL author // and I am not claiming authorship of this indicator. // All I did was modify it. I hope you find my modifications useful.| //| | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, Nick Bilak" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color2 Red #property indicator_color1 Blue //---- input parameters extern int win = 0; extern int price.x.offset= 0 ; extern int price.y.offset= 400 ; extern int myFontSize = 120; extern string Buy_Message = "BUY!" ; extern string Long_Message = "LONG" ; extern string SellShort_Message = "SHORT!" ; extern string Short_Message = "SHORT" ; extern color Buy_color = Lime; extern color Long_color = Green; extern color SellShort_color = Red; extern color Short_color = Crimson; extern int CompBars=6; //---- buffers double buf1[]; double buf2[]; double haOpen[]; double haClose[]; double icolor[]; string cTrade, pTrade ; color TradeColor ; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(5); SetIndexStyle(0,DRAW_HISTOGRAM); // blue SetIndexBuffer(0,buf1); SetIndexStyle(1,DRAW_HISTOGRAM); // red SetIndexBuffer(1,buf2); SetIndexBuffer(2,haOpen); SetIndexBuffer(3,haClose); SetIndexBuffer(4,icolor); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { ObjectsDeleteAll(win ); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int shift,limit,i; int counted_bars=IndicatorCounted(); if (counted_bars<0) return(-1); if (counted_bars>0) counted_bars--; limit=Bars-4; if(counted_bars>=1) limit=Bars-counted_bars-4; double dip,dim,stm,sts,macdm,macds; if (haOpen[limit+3]==0.0) haOpen[limit+3]=Open[limit+3]; haClose[limit+3] = (Open[limit+3]+High[limit+3]+Low[limit+3]+Close[limit+3])/4.0; for(shift = limit+2; shift >= 0; shift--) { haOpen[shift] = (haOpen[shift+1]+haClose[shift+1])/2.0; haClose[shift] = (Open[shift]+High[shift]+Low[shift]+Close[shift])/4.0; if (haClose[shift] > haOpen[shift]) icolor[shift] = 1; else icolor[shift] = -1; for (i=1; i<=CompBars; i++) { if ( haOpen[shift] <= MathMax(haOpen[shift+i],haClose[shift+i]) && haOpen[shift] >= MathMin(haOpen[shift+i],haClose[shift+i]) && haClose[shift] <= MathMax(haOpen[shift+i],haClose[shift+i]) && haClose[shift] >= MathMin(haOpen[shift+i],haClose[shift+i]) ) icolor[shift] = icolor[shift+i]; } if (icolor[shift]>0) { buf1[shift]=High[shift]; buf2[shift]=Low[shift]; } else { buf2[shift]=High[shift]; buf1[shift]=Low[shift]; } } while(true) { if (icolor[0]>0 && icolor[0] != icolor[1] ) {cTrade = Buy_Message ; TradeColor = Buy_color ; break ;} if (icolor[0]<0 && icolor[0] != icolor[1] ) {cTrade = SellShort_Message ; TradeColor = SellShort_color ; break ;} if (icolor[0]>0) {cTrade = Long_Message ;TradeColor = Long_color ;} else {cTrade = Short_Message ;TradeColor = Short_color ;} break ; } Comment( "cTrade ", cTrade, "\n", "pTrade ", pTrade, "\n", "icolor[0] ", icolor[0], "\n", "icolor[1] ", icolor[1], "\n", "" ); pTrade = cTrade ; DoMessage(); return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void DoMessage() { ObjectCreate("tmm01", OBJ_LABEL, win, 0, 0);//HiLow LABEL ObjectSetText("tmm01",cTrade, myFontSize , "Arial Bold", TradeColor ); ObjectSet("tmm01", OBJPROP_CORNER, 0); ObjectSet("tmm01", OBJPROP_XDISTANCE, price.x.offset); ObjectSet("tmm01", OBJPROP_YDISTANCE, price.y.offset); WindowRedraw(); return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open prices of each bar
Series array that contains close prices for each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: