//+------------------------------------------------------------------+
//| XO |
//| mladen |
//+------------------------------------------------------------------+
#property link "www.forex-station.com"
#property copyright "www.forex-station.com"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 clrDeepSkyBlue
#property indicator_color2 clrPaleVioletRed
#property indicator_width1 2
#property indicator_width2 2
#property indicator_minimum 0
#property indicator_maximum 1
//
//
//
//
//
enum enTimeFrames
{
tf_cu = PERIOD_CURRENT, // Current time frame
tf_m1 = PERIOD_M1, // 1 minute
tf_m5 = PERIOD_M5, // 5 minutes
tf_m15 = PERIOD_M15, // 15 minutes
tf_m30 = PERIOD_M30, // 30 minutes
tf_h1 = PERIOD_H1, // 1 hour
tf_h4 = PERIOD_H4, // 4 hours
tf_d1 = PERIOD_D1, // Daily
tf_w1 = PERIOD_W1, // Weekly
tf_mn1 = PERIOD_MN1, // Monthly
tf_n1 = -1, // First higher time frame
tf_n2 = -2, // Second higher time frame
tf_n3 = -3 // Third higher time frame
};
extern enTimeFrames TimeFrame = tf_cu;
extern double BoxSize = 6.5;//300;//34
extern bool alertsOn = true; // Turn alerts on?
extern bool alertsOnCurrent = true; // Alerts on current (still opened) bar?
extern bool alertsMessage = true; // Alerts should show pop-up message?
extern bool alertsPushNotif = false; // Alerts should send push notification?
extern bool alertsSound = false; // Alerts should play a sound?
extern bool alertsEmail = false; // Alerts should send email?
extern bool arrowsVisible = true; // Arrows visible?
extern bool arrowsOnNewest = true;//false; // Arrows drawn on newest bar of higher time frame bar?
extern string arrowsIdentifier = "xo Arrows1"; // Unique ID for arrows
extern double arrowsUpperGap = 0.1; // Upper arrow gap
extern double arrowsLowerGap = 0.1; // Lower arrow gap
extern color arrowsUpColor = Blue; // Up arrow color
extern color arrowsDnColor = Crimson; // Down arrow color
extern int arrowsUpCode = 116; // Up arrow code
extern int arrowsDnCode = 116; // Down arrow code
extern bool showHigherTimeFrameCurrentBarLine = true;
extern string lineID = "XO vertline";
extern color lineColor = clrDimGray;
extern ENUM_LINE_STYLE lineStyle = STYLE_DOT;
extern int lineWidth = 0;
extern bool ShowBars = true;
extern color ColorUp = clrDeepSkyBlue;
extern color ColorDown = clrPaleVioletRed;
extern string ColorUniqueID = "XO color bars";
extern int ColorWidth = 2;
extern int ColorBars = 500;
extern int widthWick = 0;
extern int widthBody = 2;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit = MathMin(Bars-counted_bars,Bars-1); count[0] = limit;
//
//
//
//
//
if (TimeFrame == _Period)
{
int cb = ColorBars; if (ColorBars==0) cb = Bars-1; cb = MathMin(Bars-1,cb);
double pipModifier = 1; if (Digits==3 || Digits==5) pipModifier=10;
for(int i=limit; i>=0; i--)
{
if (i>=(Bars-2)) { Hi[i+1]=Close[i]; Lo[i+1]=Close[i]; continue; }
//
//
//
//
//
double cur = Close[i];
Hi[i] = Hi[i+1];
Lo[i] = Lo[i+1];
no[i] = no[i+1];
kr[i] = kr[i+1];
trend[i] = trend[i+1];
if (cur > (Hi[i]+BoxSize*pipModifier*Point)) { Hi[i] = cur; Lo[i] = cur-BoxSize*pipModifier*Point; kr[i] = 1; no[i] = 0; trend[i]= 1;}
if (cur < (Lo[i]-BoxSize*pipModifier*Point)) { Lo[i] = cur; Hi[i] = cur+BoxSize*pipModifier*Point; no[i] = 1; kr[i] = 0; trend[i]=-1;}
//
//
//
//
//
if (arrowsVisible)
{
string lookFor = arrowsIdentifier+":"+(string)Time[i]; ObjectDelete(lookFor);
if (trend[i] != trend[i+1])
{
if (trend[i] == 1) drawArrow(i,arrowsUpColor,arrowsUpCode,false);
if (trend[i] ==-1) drawArrow(i,arrowsDnColor,arrowsDnCode, true);
}
}
//
//
//
//
//
if (ShowBars && cb>=i)
{
if (trend[i]==-1)
drawBar(Time[i],High[i],Low[i],Open[i],Close[i],ColorDown,ColorDown);
else drawBar(Time[i],High[i],Low[i],Open[i],Close[i],ColorUp,ColorUp);
}
}
//
//
//
//
//
if (alertsOn)
{
if (alertsOnCurrent)
int whichBar = 0;
else whichBar = 1;
if (trend[whichBar] != trend[whichBar+1])
{
if (trend[whichBar] == 1) doAlert(whichBar,"up");
if (trend[whichBar] ==-1) doAlert(whichBar,"down");
}
}
return(0);
}
//
//
//
//
//
limit = MathMax(limit,MathMin(Bars,_mtfCall(5,0)*TimeFrame/_Period));
cb = ColorBars; if (ColorBars==0) cb = Bars-1; cb = MathMin(Bars-1,cb*TimeFrame/Period());
for (i=limit;i>=0;i--)
{
int y = iBarShift(NULL,TimeFrame,Time[i]);
kr[i] = _mtfCall(0,y);
no[i] = _mtfCall(1,y);
trend[i] = _mtfCall(4,y);
if (trend[i]==-1)
drawBar(Time[i],High[i],Low[i],Open[i],Close[i],ColorDown,ColorDown);
else drawBar(Time[i],High[i],Low[i],Open[i],Close[i],ColorUp,ColorUp);
}
if (showHigherTimeFrameCurrentBarLine)
{
ObjectCreate(lineID,OBJ_VLINE,0,0,0);
ObjectSet(lineID,OBJPROP_TIME1,iTime(NULL,TimeFrame,0));
ObjectSet(lineID,OBJPROP_COLOR,lineColor);
ObjectSet(lineID,OBJPROP_STYLE,lineStyle);
ObjectSet(lineID,OBJPROP_WIDTH,lineWidth);
}
return(0);
}
}