Cams_Daily_Break

Download script
Cams_Daily_Break

This script is designed to identify and visualize specific price levels on a trading chart based on the "Camarilla" pivot framework. It serves as a technical analysis tool that automatically calculates key support and resistance zones derived from a specific period of historical price movement.

Core Logic and Functionality

1. Period Definition and Tracking The script identifies a specific timeframe during the trading day (defined by start and end times) to calculate its values. It scans through historical data to locate these specific boundaries. Once it recognizes the transition from one period to the next, it gathers the necessary price information—specifically the highest high, the lowest low, and the closing price of that defined window.

2. Calculation Methodology Using the data gathered from the identified timeframe, the script calculates eight distinct price levels (known as Camarilla levels). These levels are mathematically derived based on the "range" (the distance between the highest high and lowest low) relative to the closing price:

  • High Side Levels (H4 through H7): These represent potential resistance points. They are calculated by adding various percentages of the range to the closing price.
  • Low Side Levels (L4 through L7): These represent potential support points. They are calculated by subtracting various percentages of the range from the closing price.

3. Visual Representation The primary purpose of the script is to project these calculated levels onto the current chart so traders can see them in real-time.

  • Dynamic Updates: As the price moves, the script ensures that the visual markers stay relevant to the most recent calculations.
  • Visual Markers: The script specifically highlights and places "arrows" or markers on the chart at the calculated H4 and L4 levels (the central Camarilla levels). These markers act as clear visual cues for traders to identify where price might encounter significant friction or reversal zones.
  • Automatic Cleanup: When the indicator is removed from the chart, it includes a cleanup routine that deletes all created visual objects, ensuring the trading screen remains clean and uncluttered.

Summary for the Trader

In simple terms, this script looks at a set block of time (like the previous day or a specific session), finds out how high and low the price went during that time, and then draws "boundary lines" on your current chart. These lines help you visualize where the market might face pressure or find support based on established Camarilla pivot theory.

Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Cams_Daily_Break
//+------------------------------------------------------------------+
//|                                             Cams_Daily_Break.mq4 |
//|            Original Pivot Framework sourced from Forex-TSD Forum |
//|                                adapted by kris.pivo[at]gmail.com |
//+------------------------------------------------------------------+
#property copyright "© Kris, 2008"                                 //|
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 C'000,100,000'
#property indicator_color2 C'000,150,000'
#property indicator_color3 C'000,200,000'
#property indicator_color4 C'000,255,000'
#property indicator_color5 C'255,000,000'
#property indicator_color6 C'200,000,000'
#property indicator_color7 C'150,000,000'
#property indicator_color8 C'100,000,000'

//Input Params
extern string PivotStart = "00:00";
extern string PivotEnd   = "00:00";

double Buffer0[]; // Cam H7
double Buffer1[]; // Cam H6
double Buffer2[]; // Cam H5
double Buffer3[]; // Cam H4
double Buffer4[]; // Cam L4
double Buffer5[]; // Cam L5
double Buffer6[]; // Cam L6
double Buffer7[]; // Cam L7

double LastHigh,LastLow,LastClose;
double CamH4, CamH5, CamH6, CamH7;
double CamL4, CamL5, CamL6, CamL7;

int OpenBar;
    
int init()
{  SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,160);
   SetIndexBuffer(0,Buffer0);
   SetIndexLabel(0,"Camarilla H7");

   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,160);
   SetIndexBuffer(1,Buffer1);
   SetIndexLabel(1,"Camarilla H6");

   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,160);
   SetIndexBuffer(2,Buffer2);
   SetIndexLabel(2,"Camarilla H5");
   
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,167);
   SetIndexBuffer(3,Buffer3);
   SetIndexLabel(3,"Camarilla H4");
   
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexArrow(4,167);
   SetIndexBuffer(4,Buffer4);
   SetIndexLabel(4,"Camarilla L4");
   
   SetIndexStyle(5,DRAW_ARROW);
   SetIndexArrow(5,160);
   SetIndexBuffer(5,Buffer5);
   SetIndexLabel(5,"Camarilla L5");
   
   SetIndexStyle(6,DRAW_ARROW);
   SetIndexArrow(6,160);
   SetIndexBuffer(6,Buffer6);
   SetIndexLabel(6,"Camarilla L6");
   
   SetIndexStyle(7,DRAW_ARROW);
   SetIndexArrow(7,160);
   SetIndexBuffer(7,Buffer7);
   SetIndexLabel(7,"Camarilla L7");
   
   return(0); }

int deinit() {
	ObjectDelete("H7");
	ObjectDelete("H6");
	ObjectDelete("H5");
	ObjectDelete("H4"); ObjectDelete("CH4");
   ObjectDelete("L4"); ObjectDelete("CL4");
   ObjectDelete("L5");
	ObjectDelete("L6");
	ObjectDelete("L7");
	Comment("");
	return(0);
}

int start()
{  string BarTime="", LastBarTime="";         
   string BarDay="", LastBarDay="";
   int CloseBar;
          
   for(int i=Bars; i>=0; i--)
   {  BarTime = TimeToStr(Time[i], TIME_MINUTES);
      LastBarTime = TimeToStr(Time[i+1], TIME_MINUTES);
      BarDay = TimeToStr(Time[i],TIME_DATE);
      LastBarDay = TimeToStr(Time[i+1],TIME_DATE); 
      
      //need to handle if pivotrangestart/end is 00:00
      if ((PivotEnd == "00:00" && BarTime>=PivotEnd && BarDay>LastBarDay) || (BarTime>=PivotEnd && LastBarTime<PivotEnd))
      {  CloseBar = i + 1;
         
         if (OpenBar>0)
         {  calculatePivotRangeValues(OpenBar, CloseBar);  }  }
      
      if ((PivotStart == "00:00" && BarTime>=PivotStart && BarDay>LastBarDay) || (BarTime>=PivotStart && LastBarTime<PivotStart))
      { OpenBar = i; }
      
      if (OpenBar>0)
      { drawIndicators(i);  } }
   return(0);}
void calculatePivotRangeValues(int openBar, int closeBar)
   {
   LastHigh = High[Highest(NULL, 0, MODE_HIGH, (openBar - closeBar + 1), closeBar)];
   LastLow = Low[Lowest(NULL, 0, MODE_LOW, (openBar - closeBar + 1), closeBar)];
   LastClose = Close[closeBar];
   
 	CamH7 = LastClose + (LastHigh - LastLow) * 1.25;
	CamH6 = LastClose + (LastHigh - LastLow);
	CamH5 = LastClose + (LastHigh - LastLow) * 0.75;
	CamH4 = LastClose + (LastHigh - LastLow) * 0.50;
	CamL4 = LastClose - (LastHigh - LastLow) * 0.50;
	CamL5 = LastClose - (LastHigh - LastLow) * 0.75;
	CamL6 = LastClose - (LastHigh - LastLow);
	CamL7 = LastClose - (LastHigh - LastLow) * 1.25;
   }

void drawIndicators(int curBar)
{
   Buffer0[curBar]=CamH7;
   Buffer1[curBar]=CamH6;
   Buffer2[curBar]=CamH5;
   Buffer3[curBar]=CamH4;
   Buffer4[curBar]=CamL4;
   Buffer5[curBar]=CamL5;
   Buffer6[curBar]=CamL6;
   Buffer7[curBar]=CamL7;

// DoLabel( "CH7", Buffer0[0], indicator_color1 ) ;
// DoLabel( "CH6", Buffer1[0], indicator_color2 ) ;
// DoLabel( "CH5", Buffer2[0], indicator_color3 ) ;
   DoLabel( "CH4", Buffer3[0], indicator_color4 ) ;	
   DoLabel( "CL4", Buffer4[0], indicator_color5 ) ;
// DoLabel( "CL5", Buffer5[0], indicator_color6 ) ;
// DoLabel( "CL6", Buffer6[0], indicator_color7 ) ;
// DoLabel( "CL7", Buffer7[0], indicator_color8 ) ;

	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