Gann High-Low activator histogram

//+------------------------------------------------------------------+
//|
Gann high-low activator |
//|
|
//+------------------------------------------------------------------+
#property copyright "www.forex-tsd.com"
#property link
"www.forex-tsd.com"
#property
#property
#property
#property
#property
#property
#property
#property
//
//
//
//
//
extern
extern
extern
extern
extern
extern
extern

indicator_separate_window
indicator_buffers 2
indicator_color1 DeepSkyBlue
indicator_color2 OrangeRed
indicator_minimum 0
indicator_maximum 1
indicator_width1 2
indicator_width2 2

string
int
bool
bool
bool
bool
bool

TimeFrame
Lb
alertsOn
alertsOnCurrent
alertsMessage
alertsSound
alertsEmail

=
=
=
=
=
=
=

"Current time frame";
3;
false;
true;
true;
false;
false;

//
//
//
//
//
double gup[];
double gdn[];
double trend[];
//
//
//
//
//
int
timeFrame;
string indicatorFileName;
bool
returnBars;
Page 1

gdn). SetIndexDrawBegin(0. SetIndexArrow(1. returnBars return(0).Lb+1). //SetIndexBuffer(1. //SetIndexBuffer(0.Lb+1).gdn).DRAW_ARROW). if (returnBars) = stringToTimeFrame(TimeFrame).DRAW_ARROW).gup). SetIndexDrawBegin(1. SetIndexStyle(1. } Page 2 . SetIndexDrawBegin(1. // // // // // indicatorFileName calculateValue return(0).Lb+1). if (calculateValue) = (TimeFrame=="returnBars"). SetIndexBuffer(0.trend). SetIndexDrawBegin(0.Lb+1).Gann High-Low activator histogram bool calculateValue."SSLup "+Lb+" ["+TimeFrame+"]").// SetIndexLabel(0. SetIndexBuffer(1. SetIndexStyle(0.DRAW_HISTOGRAM). return(0).110). SetIndexStyle(0. SetIndexBuffer(2. //+-----------------------------------------------------------------//| //+-----------------------------------------------------------------// // // // // int init() { IndicatorBuffers(3)."SSLdn "+Lb+" ["+TimeFrame+"]"). SetIndexStyle(1. // // // // // IndicatorShortName(timeFrameToString(timeFrame)+" Gann high/low activator ("+Lb+")").gup).DRAW_HISTOGRAM).110). SetIndexArrow(0. = (TimeFrame=="calculateValue").// SetIndexLabel(1. timeFrame = WindowExpertName().

else gup[i] = 1. if(Close[i]<iMA(Symbol().Gann High-Low activator histogram //+-----------------------------------------------------------------//| //+-----------------------------------------------------------------// // // // // int start() { int counted_bars=IndicatorCounted(). if(counted_bars>0) counted_bars--.0.i>=0.i+1)) trend[i] = -1.Lb. } manageAlerts().MODE_SMA.0. if(trend[i] == -1) gdn[i] = 1.limit.i--) { gup[i] = EMPTY_VALUE. int i.PRICE_LOW.Lb.Bars-1).PRICE_HIGH. trend[i] = trend[i+1]. limit=MathMin(Bars-counted_bars. return(0).MODE_SMA. if(Close[i]>iMA(Symbol().i+1)) trend[i] = 1. gdn[i] = EMPTY_VALUE. if (returnBars) { gup[0] = limit+1. } // // // // // if (calculateValue || timeFrame == Period()) { for(i=limit. return(0). if(counted_bars<0) return(-1).0. } // // // // // Page 3 .0.

Lb."down").2. gup[i] = EMPTY_VALUE.timeFrame.0)*timeFrame/Period())).indicatorFileName. whichBar = iBarShift(NULL. i--) { int y = iBarShift(NULL.timeFrame.indicatorFileName.0 . else gup[i] = 1.Time[i]). i>=0.0. trend[i] = iCustom(NULL. for(i=limit."up").iCustom(NULL."returnBars".y).whichBar)). gdn[i] = EMPTY_VALUE. if(trend[i] == -1) gdn[i] = 1. Page 4 .Gann High-Low activator histogram limit = MathMax(limit. if (trend[whichBar] != trend[whichBar+1]) { if (trend[whichBar] == 1) doAlert(whichBar."calculateValue". } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // void manageAlerts() { if (!calculateValue && alertsOn) { if (alertsOnCurrent) int whichBar = 0. } // // // // // manageAlerts(). if (trend[whichBar] ==-1) doAlert(whichBar.timeFrame.iTime(NULL. return(0). else whichBar = 1.timeFrame.MathMin(Bars-1.

// // // // // message = StringConcatenate(Symbol()."Gann HL ")."W1"."M5".10080.Gann High-Low activator histogram } } } // // // // // void doAlert(int forBar. Page 5 .60. } } //+------------------------------------------------------------------//| //+------------------------------------------------------------------// // // // // string sTfTable[] = {"M1".TIME_SECONDS). previousTime = Time[forBar]."M30".wav")."M15".5.TimeToStr(TimeLocal()."MN"}.43200}. if (alertsEmail) SendMail(StringConcatenate(Symbol(). if (alertsMessage) Alert(message)." at ".240.30."H1".doWhat).message). int iTfTable[] = {1. if (alertsSound) PlaySound("alert2. string doWhat) { static string previousAlert="nothing". if (previousAlert != doWhat || previousTime != Time[forBar]) { previousAlert = doWhat."H4"." Gann HL activator trend changed to ".15."D1". static datetime previousTime.1440. string message.

if((char > 96 && char < 123) || (char > 223 && char < 256)) s = StringSetChar(s. } return(s).Gann High-Low activator histogram // // // // // int stringToTimeFrame(string tfs) { tfs = stringUpperCase(tfs). length. length). char + 224). length. i>=0. length>=0. } // // // // // string stringUpperCase(string str) { string s = str. else if(char > -33 && char < 0) s = StringSetChar(s. for (int i=ArraySize(iTfTable)-1.Period())). length--) { int char = StringGetChar(s. for (int length=StringLen(str)-1. } string timeFrameToString(int tf) { for (int i=ArraySize(iTfTable)-1. } Page 6 . i>=0. i--) if (tfs==sTfTable[i] || tfs==""+iTfTable[i]) return(MathMax(iTfTable[i].32). i--) if (tf==iTfTable[i]) return(sTfTable[i]). return(Period()). char . return("").