Cams_Daily_Break

Cams_Daily_Break
Miscellaneous
Implements a curve of type %1
0 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