//+------------------------------------------------------------------+
//| Cams_Weekly_Break.mq4 |
//| Copyright © 2009, kris.pivo[at]gmail.com |
//+------------------------------------------------------------------+
#property copyright "© Kris, 2009" //|
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Maroon
#property indicator_color3 DarkGreen
#property indicator_color4 Green
#property indicator_color5 Red
#property indicator_color6 Maroon
#property indicator_color7 DarkGreen
#property indicator_color8 Green
//---- input parameters
int fontsize=8;
//---- buffers
double BufferH6[];
double BufferH5[];
double BufferH4[];
double BufferL4[];
double BufferL5[];
double BufferL6[];
double WH,WL,WC,Range;
double H1,H2,H3,H4,H5,H6,L1,L2,L3,L4,L5,L6;
double last_week_high, last_week_low, last_week_close, this_week_open;
//+------------------------------------------------------------------+
int deinit() {
ObjectDelete("LineH6");
ObjectDelete("LineH5");
ObjectDelete("LineH4");
ObjectDelete("LineL4");
ObjectDelete("LineL5");
ObjectDelete("LineL6");
ObjectDelete("LabH6");
ObjectDelete("LabH5");
ObjectDelete("LabH4");
ObjectDelete("LabL4");
ObjectDelete("LabL5");
ObjectDelete("LabL6");
Comment("");
return(0); }
//+------------------------------------------------------------------+
int init()
{
string short_name;
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,160);
SetIndexBuffer(1,BufferH6);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,160);
SetIndexBuffer(2,BufferH5);
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,167);
SetIndexBuffer(3,BufferH4);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,167);
SetIndexBuffer(4,BufferL4);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,160);
SetIndexBuffer(5,BufferL5);
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,160);
SetIndexBuffer(6,BufferL6);
//---- name for DataWindow and indicator subwindow label
short_name="Fibonacci Weekly";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,1);
//----
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
int limit, i;
//---- indicator calculation
if (counted_bars==0)
{
ObjectCreate("LineH6", OBJ_TEXT, 0,0,0);
ObjectSetText("LineH6", " Cam H6",fontsize,"Arial",indicator_color2);
ObjectCreate("LineH5", OBJ_TEXT, 0,0,0);
ObjectSetText("LineH5", " Cam H5",fontsize,"Arial",indicator_color3);
ObjectCreate("LineH4", OBJ_TEXT, 0,0,0);
ObjectSetText("LineH4", " Cam H4",fontsize,"Arial",indicator_color4);
ObjectCreate("LineL4", OBJ_TEXT, 0,0,0);
ObjectSetText("LineL4", " Cam L4",fontsize,"Arial",indicator_color5);
ObjectCreate("LineL5", OBJ_TEXT, 0,0,0);
ObjectSetText("LineL5", " Cam L5",fontsize,"Arial",indicator_color6);
ObjectCreate("LineL6", OBJ_TEXT, 0,0,0);
ObjectSetText("LineL6", " Cam L6",fontsize,"Arial",indicator_color7);
}
if(counted_bars<0) return(-1);
//----
limit=(Bars-counted_bars)-1;
//----
for(i=limit; i>=0;i--)
{
// Monday
if(1==TimeDayOfWeek(Time[i]) && 1!=TimeDayOfWeek(Time[i+1]) ) // 0=Sunday, 1=Monday, ...
{
last_week_close=Close[i+1];
this_week_open=Open[i];
WH=last_week_high;
WL=last_week_low;
WC = last_week_close;
double Range = (WH - WL);
H6 = WC + (Range * 1.00);
H5 = WC + (Range * 0.75);
H4 = WC + (Range * 0.50);
L4 = WC - (Range * 0.50);
L5 = WC - (Range * 0.75);
L6 = WC - (Range * 1.00);
last_week_low = Low[i];
last_week_high = High[i];
//----
ObjectMove("LineH6", 0, Time[i],H6);
ObjectMove("LineH5", 0, Time[i],H5);
ObjectMove("LineH4", 0, Time[i],H4);
ObjectMove("LineL4", 0, Time[i],L4);
ObjectMove("LineL5", 0, Time[i],L5);
ObjectMove("LineL6", 0, Time[i],L6);
}
last_week_high=MathMax(last_week_high, High[i]);
last_week_low=MathMin(last_week_low, Low[i]);
BufferH6[i]=H6;
BufferH5[i]=H5;
BufferH4[i]=H4;
BufferL4[i]=L4;
BufferL5[i]=L5;
BufferL6[i]=L6;
DoLabel( "LabH6", BufferH6[0], indicator_color2 );
DoLabel( "LabH5", BufferH5[0], indicator_color3 );
DoLabel( "LabH4", BufferH4[0], indicator_color4 );
DoLabel( "LabL4", BufferL4[0], indicator_color5 );
DoLabel( "LabL5", BufferL5[0], indicator_color6 );
DoLabel( "LabL6", BufferL6[0], indicator_color7 );
}
return(0); }
void DoLabel( string dName, double dValue, color dColor )
{
if (ObjectFind(dName) != 0)
{
ObjectCreate(dName,OBJ_ARROW,0,Time[0],dValue);
ObjectSet(dName,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
ObjectSet(dName,OBJPROP_COLOR,dColor);
}
else
{
ObjectMove(dName,0,Time[0],dValue);
}
}
//+-----------------------------------------------------------------------------------------+
//| THE END |
//+-----------------------------------------------------------------------------------------+
Comments