InvestorsHub Logo
Post# of 102
Next 10
Followers 38
Posts 9736
Boards Moderated 2
Alias Born 06/03/2007

Re: SherriT post# 40

Monday, 05/18/2009 11:03:43 PM

Monday, May 18, 2009 11:03:43 PM

Post# of 102
Hey Sherri, check out this indie I made. Not finished yet, but it shows the 1 hour support and 1 hour resistance regardless of the timeframe of the chart you're looking at with the red horizontal lines plus it adds the e64, the e144, and the e169. It's my first attempt at using Objects instead of buffers and I'm pretty tickled. Gonna add the 4 hour for sure later and play around with the colors and line widths.

Kind of even been thinking about showing it as a histogram of the difference between the current price and the support or resistance levels.

Here's the code so far.

//+------------------------------------------------------------------+
//| GitsTunnelResistance.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 PowderBlue //Recent 1 Hour resistance
#property indicator_color2 Khaki//Recent 1 Hour support
#property indicator_color3 Chartreuse//Recent 4 Hour resistance
#property indicator_color4 Red//Recent 4 Hour support
#property indicator_color5 Red//Current62ema
#property indicator_color6 Yellow//Current144ema
#property indicator_color7 Chartreuse//Current169ema



//---- buffers
double H1R,H1S,H4R,H4S;
double E62[];
double E144[];
double E169[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(7);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,STYLE_DASHDOT,3);//1 Hour Resistance
SetIndexStyle(1,DRAW_LINE,STYLE_DASHDOT,3);//1 Hour Support
SetIndexStyle(2,DRAW_LINE,2);//4 Hr Resistance
SetIndexStyle(3,DRAW_LINE,2);//4 Hr Support
SetIndexStyle(4,DRAW_LINE);//E62
SetIndexStyle(5,DRAW_LINE);//E144
SetIndexStyle(6,DRAW_LINE);//E169

//---- indicator mapping
SetIndexBuffer(0,H1R);
SetIndexBuffer(1,H1S);
SetIndexBuffer(2,H4R);
SetIndexBuffer(3,H4S);
SetIndexBuffer(4,E62);
SetIndexBuffer(5,E144);
SetIndexBuffer(6,E169);

//---- indicator labeling
IndicatorShortName("Gits Tunnel Resistance");
SetIndexLabel(0,"1 Hour Resistance");
SetIndexLabel(1,"1 Hour Support");
SetIndexLabel(2,"4 Hour Resistance");
SetIndexLabel(3,"4 Hour Support");
SetIndexLabel(4,"Current E62");
SetIndexLabel(5,"Current E144");
SetIndexLabel(6,"Current E169");
return(0);
}


int deinit()
{
//----
ObjectsDeleteAll();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+

int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- Current EMAs
for(int i=0; i<limit; i++)
E62=iMA(NULL,0,62,0,MODE_EMA,PRICE_CLOSE,i);
for(i=0; i<limit; i++)
E144=iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,i);
for(i=0; i<limit; i++)
E169=iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,i);
// 1 Hour resistance
for(i=1; i<limit; i++)
{
if(iHigh(NULL,60,i+1) > iHigh(NULL,60,i)) H1R=iHigh(NULL,60,i+1); else H1R=iHigh(NULL,60,i);
ObjectCreate("H1Resistance",OBJ_HLINE,0,0,H1R);
break;
}
// 1 Hour support
for(i=0; i<limit; i++)
{
if(iLow(NULL,60,i+1) < iLow(NULL,60,i)) H1S=iLow(NULL,60,i+1); else H1S=iLow(NULL,60,i);
ObjectCreate("H1Support",OBJ_HLINE,0,0,H1S);
break;
}
// 4 Hour resistance
for(i=0; i<limit; i++)
{
if(iHigh(NULL,240,i+1) < iHigh(NULL,240,i)) H4R=High; break;
}
// 4 Hour support
for(i=0; i<limit; i++)
{
if(iLow(NULL,240,i+1) > iLow(NULL,240,i)) H4S=Low; break;
}


Comment("H1R = ",H1R, " || H1S = ",H1S," || H4R = ",H4R," || H4S = ",H4S);
//---- done
return(0);
}


//+------------------------------------------------------------------+




"remember the mayonaise jar...keep cool but don't freeze"

Join InvestorsHub

Join the InvestorsHub Community

Register for free to join our community of investors and share your ideas. You will also get access to streaming quotes, interactive charts, trades, portfolio, live options flow and more tools.