Cams_Weekly_Break
Download scriptThis script is designed to provide traders with a clear visual map of potential price levels based on the previous week's market activity. By analyzing where the price moved during the prior week, it automatically projects several key "target zones" onto the current week's chart.
Core Logic and Functionality
Weekly Data Analysis The script constantly monitors the market to identify the transition from one week to the next. Specifically, when a new Monday begins, the tool captures three vital pieces of information from the preceding week:
- The highest price reached (High)
- The lowest price reached (Low)
- The final closing price (Close)
Calculating the Trading Range Once these values are captured, the script calculates the total "Range"—the distance between the previous week's high and low. This range serves as the foundation for all subsequent projections.
Projection of Key Levels Using the previous week’s closing price as a pivot point, the script projects six distinct levels (labeled H4 through H6 and L4 through L6). These levels are calculated using specific ratios of the weekly range:
- H4 & L4: Represent the 50% mark (the midpoint) above and below the previous week's close.
- H5 & L5: Represent the 75% marks above and below the previous week's close.
- H6 & L6: Represent the 100% marks (full range) above and below the previous week's close.
Visual Representation
To make this data actionable for the user, the script performs the following visual tasks:
- Dynamic Labeling: It places text labels on the chart to identify each specific zone clearly (e.g., "Cam H4," "Cam L5").
- Real-Time Tracking: As new price data comes in throughout the current week, the script constantly updates the highest and lowest points reached.
- Visual Markers: It utilizes colored arrows on the right side of the chart to show exactly where these calculated levels sit in relation to the live price.
Summary for the Trader
In essence, this tool helps you visualize "extended" targets. By showing you where the price might go based on the magnitude of the previous week's movement, it allows you to anticipate potential resistance and support zones more effectively during the current trading week.
//+------------------------------------------------------------------+
//| 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