Waddah_Attar_Weekly_CAMARILLA

Download script
Author: Copyright � 2007, www.metaforex.net
Waddah_Attar_Weekly_CAMARILLA

This script is designed to automatically calculate and display specific price levels on your trading chart based on the Weekly Camarrilla range. These levels are used by traders to identify potential areas of support and resistance, specifically focusing on weekly price movements.

How the Logic Works

The script operates by analyzing historical data from the previous week to project four key "High" and four key "Low" levels for the current period. Here is the step-by-step breakdown of the logic:

1. Data Collection The tool first looks back at the previous completed weekly candle. It identifies two main pieces of information from that specific week:

  • The highest price reached (High).
  • The lowest price reached (Low).

2. Range Calculation Using those two points, the script calculates the total "Range" (the difference between the high and the low) of the previous week. This range serves as the baseline for all subsequent calculations.

3. Projection of Levels Once the weekly range is established, the script applies specific mathematical multipliers to the closing price of the previous week. This creates four distinct levels of significance:

  • H1 & L1: Calculated at 9% of the range. These represent the immediate inner boundaries.
  • H2 & L2: Calculated at 18% of the range.
  • H3 & L3: Calculated at 27% of the range.
  • H4 & L4: Calculated at 55% of the range. These represent the outer boundaries of the weekly movement.

4. Visual Representation Instead of just showing you raw numbers in a list, the script automatically draws these levels directly onto your chart:

  • Lines: It plots eight distinct lines across the chart so you can see the boundaries visually as the price moves.
  • Labels: It places clear text markers (H1, L1, etc.) next to each line so you can instantly identify which level is which.
  • Color Coding: To make the chart easier to read, it alternates colors between the "High" levels (LightSeaGreen) and the "Low" levels (DeepPink), allowing for a quick visual distinction between upward resistance and downward support.

Summary for the User

Essentially, this script automates the math required to see where the market is likely to react based on the previous week's volatility. It takes the work out of manually calculating percentages and draws a "map" on your chart, highlighting the key price zones where the market might slow down, reverse, or break through.

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
18 Views
0 Downloads
0 Favorites
Waddah_Attar_Weekly_CAMARILLA
//+------------------------------------------------------------------+
//|                                   Waddah Attar Weekly CAMARRILLA |
//|                               Copyright © 2007, ww.metaforex.net |
//|                                   Waddah Attar www.metaforex.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, www.metaforex.net"
#property link      "www.metaforex.net"
//----
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 LightSeaGreen
#property indicator_color2 DeepPink
#property indicator_color3 LightSeaGreen
#property indicator_color4 DeepPink
#property indicator_color5 LightSeaGreen
#property indicator_color6 DeepPink
#property indicator_color7 LightSeaGreen
#property indicator_color8 DeepPink

//---- buffers
double P1Buffer[];
double P2Buffer[];
double P3Buffer[];
double P4Buffer[];
double P5Buffer[];
double P6Buffer[];
double P7Buffer[];
double P8Buffer[];
//----
int myPeriod = PERIOD_W1;
//----
double H1, L1, H2, L2, H3, L3, H4, L4, Q;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0, P1Buffer);
   SetIndexBuffer(1, P2Buffer);
   SetIndexBuffer(2, P3Buffer);
   SetIndexBuffer(3, P4Buffer);
   SetIndexBuffer(4, P5Buffer);
   SetIndexBuffer(5, P6Buffer);
   SetIndexBuffer(6, P7Buffer);
   SetIndexBuffer(7, P8Buffer);
//----
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(7, DRAW_LINE, STYLE_SOLID, 2);
//----
   Comment("Weekly CAMARRILLA By eng.Waddah Attar  www.metaforex.net");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("WeekH1");
   ObjectDelete("WeekH2");
   ObjectDelete("WeekH3");
   ObjectDelete("WeekH4");

   ObjectDelete("WeekL1");
   ObjectDelete("WeekL2");
   ObjectDelete("WeekL3");
   ObjectDelete("WeekL4");

   ObjectDelete("txtWeekH1");
   ObjectDelete("txtWeekH2");
   ObjectDelete("txtWeekH3");
   ObjectDelete("txtWeekH4");

   ObjectDelete("txtWeekL1");
   ObjectDelete("txtWeekL2");
   ObjectDelete("txtWeekL3");
   ObjectDelete("txtWeekL4");
   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i, dayi, counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;  
   int limit = Bars - counted_bars;
//----   
   for(i = limit - 1; i >= 0; i--)
     {
       dayi = iBarShift(Symbol(), myPeriod, Time[i], false);
       Q = (iHigh(Symbol(), myPeriod,dayi+1) - iLow(Symbol(), myPeriod, 
            dayi + 1));
       //----
       H1 = iClose(Symbol(), myPeriod,dayi+1) + (Q * 0.09);
       L1 = iClose(Symbol(), myPeriod,dayi+1) - (Q * 0.09);
       //----
       H2 = iClose(Symbol(), myPeriod,dayi+1) + (Q * 0.18);
       L2 = iClose(Symbol(), myPeriod,dayi+1) - (Q * 0.18);
       //----
       H3 = iClose(Symbol(), myPeriod,dayi+1) + (Q * 0.27);
       L3 = iClose(Symbol(), myPeriod,dayi+1) - (Q * 0.27);
       //----
       H4 = iClose(Symbol(), myPeriod,dayi+1) + (Q * 0.55);
       L4 = iClose(Symbol(), myPeriod,dayi+1) - (Q * 0.55);
       //----
       P1Buffer[i] = H1;
       SetPrice("WeekH1", Time[i], H1, LightSeaGreen);
       SetText("txtWeekH1", "H1", Time[i], H1, LightSeaGreen);
       //----
       P2Buffer[i] = L1;
       SetPrice("WeekL1", Time[i], L1, DeepPink);
       SetText("txtWeekL1", "L1", Time[i], L1, DeepPink);
       //----
       P3Buffer[i] = H2;
       SetPrice("WeekH2", Time[i], H2, LightSeaGreen);
       SetText("txtWeekH2", "H2", Time[i], H2, LightSeaGreen);
       //----
       P4Buffer[i] = L2;
       SetPrice("WeekL2",Time[i],L2,DeepPink);
       SetText("txtWeekL2","L2",Time[i],L2,DeepPink);
       //----
       P5Buffer[i] = H3;
       SetPrice("WeekH3", Time[i], H3, LightSeaGreen);
       SetText("txtWeekH3", "H3", Time[i], H3, LightSeaGreen);
       //----
       P6Buffer[i] = L3;
       SetPrice("WeekL3", Time[i], L3, DeepPink);
       SetText("txtWeekL3", "L3", Time[i], L3, DeepPink);
       //----
       P7Buffer[i] = H4;
       SetPrice("WeekH4", Time[i], H4, LightSeaGreen);
       SetText("txtWeekH4", "H4", Time[i], H4, LightSeaGreen);
       //----
       P8Buffer[i] = L4;
       SetPrice("WeekL4", Time[i], L4, DeepPink);
       SetText("txtWeekL4", "L4", Time[i], L4, DeepPink);

    }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetPrice(string name, datetime Tm, double Prc, color clr)
  {
   if(ObjectFind(name) == -1)
     {
       ObjectCreate(name, OBJ_ARROW, 0, Tm, Prc);
       ObjectSet(name, OBJPROP_COLOR, clr);
       ObjectSet(name, OBJPROP_WIDTH, 2);
       ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
     }
   else
     {
       ObjectSet(name, OBJPROP_TIME1, Tm);
       ObjectSet(name, OBJPROP_PRICE1, Prc);
       ObjectSet(name, OBJPROP_COLOR, clr);
       ObjectSet(name, OBJPROP_WIDTH, 2);
       ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
     } 
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SetText(string name, string txt, datetime Tm, double Prc, color clr)
  {
   if(ObjectFind(name) == -1)
     {
       ObjectCreate(name, OBJ_TEXT, 0, Tm, Prc);
       ObjectSetText(name, txt, 9, "Times New Roman", clr);
     }
   else
     {
       ObjectSet(name, OBJPROP_TIME1, Tm);
       ObjectSet(name, OBJPROP_PRICE1, Prc);
       ObjectSetText(name, txt, 9, "Times New Roman", clr);
     } 
  }
//+------------------------------------------------------------------+

Comments