Navigation:Home > Content >

trendchaser_pivot_custom.mq4

Time: 2014-08-14 | Download file:trendchaser_pivot_custom.mq4

//+------------------------------------------------------------------+
//| #BobokusFibo.mq4 modified from
//| #SpudFibo.mq4
//| http://www.forexfactory.com/showthread.php?t=50767
//+------------------------------------------------------------------+
#property  indicator_chart_window

#property indicator_buffers 3
#property indicator_color1 CLR_NONE 
#property indicator_color2 Gray
#property indicator_color3 CLR_NONE 

extern int period= 43200;
extern double line1= 0.50;
extern double line2= 0.50;
extern double line3= 0.50;
extern double line4= 0.50;
extern double line5= 0.50;
extern double line6= 0.50;
extern double line7= 0.50;
double HiPrice, LoPrice, Range;
datetime StartTime;

int init()
{

   return(0);
}

int deinit()
{
   ObjectDelete("LongFibomcu");
   ObjectDelete("ShortFibomcu");
   ObjectDelete("dailyFibomcu");
   return(0);
}

//+------------------------------------------------------------------+
//| Draw Fibo
//+------------------------------------------------------------------+

int DrawFibo()
{
	if(ObjectFind("LongFibomcu") == -1)
		ObjectCreate("LongFibomcu",OBJ_FIBO,0,StartTime,HiPrice+Range,StartTime,HiPrice);
	else
	{
		ObjectSet("LongFibomcu",OBJPROP_TIME2, StartTime);
		ObjectSet("LongFibomcu",OBJPROP_TIME1, StartTime);
		ObjectSet("LongFibomcu",OBJPROP_PRICE1,HiPrice+Range);
		ObjectSet("LongFibomcu",OBJPROP_PRICE2,HiPrice);
	}
   ObjectSet("LongFibomcu",OBJPROP_LEVELCOLOR,indicator_color1);
   ObjectSet("LongFibomcu",OBJPROP_FIBOLEVELS,2);
   ObjectSet("LongFibomcu",OBJPROP_FIRSTLEVEL+0,0.34);	ObjectSetFiboDescription("LongFibomcu",0,"Daily Long Target 1 -  %$"); 
   ObjectSet("LongFibomcu",OBJPROP_FIRSTLEVEL+1,0.55);	ObjectSetFiboDescription("LongFibomcu",1,"Daily Long Target 2 -  %$"); 

   ObjectSet("LongFibomcu",OBJPROP_RAY,true);
   ObjectSet("LongFibomcu",OBJPROP_BACK,true);

	if(ObjectFind("ShortFibomcu") == -1)
		ObjectCreate("ShortFibomcu",OBJ_FIBO,0,StartTime,LoPrice-Range,StartTime,LoPrice);
	else
	{
		ObjectSet("ShortFibomcu",OBJPROP_TIME2, StartTime);
		ObjectSet("ShortFibomcu",OBJPROP_TIME1, StartTime);
		ObjectSet("ShortFibomcu",OBJPROP_PRICE1,LoPrice-Range);
		ObjectSet("ShortFibomcu",OBJPROP_PRICE2,LoPrice);
	}
   ObjectSet("ShortFibomcu",OBJPROP_LEVELCOLOR,indicator_color3); 
   ObjectSet("ShortFibomcu",OBJPROP_FIBOLEVELS,2);
   ObjectSet("ShortFibomcu",OBJPROP_FIRSTLEVEL+0,0.34);	ObjectSetFiboDescription("ShortFibomcu",0,"Daily Short Target 1 -  %$"); 
   ObjectSet("ShortFibomcu",OBJPROP_FIRSTLEVEL+1,0.55);	ObjectSetFiboDescription("ShortFibomcu",1,"Daily Short Target 2 -  %$"); 

   ObjectSet("ShortFibomcu",OBJPROP_RAY,true);
   ObjectSet("ShortFibomcu",OBJPROP_BACK,true);

		if(ObjectFind("dailyFibomcu") == -1)
			ObjectCreate("dailyFibomcu",OBJ_FIBO,0,StartTime,HiPrice,StartTime+period*60,LoPrice);
		else
		{
			ObjectSet("dailyFibomcu",OBJPROP_TIME2, StartTime);
			ObjectSet("dailyFibomcu",OBJPROP_TIME1, StartTime+period*60);
			ObjectSet("dailyFibomcu",OBJPROP_PRICE1,HiPrice);
			ObjectSet("dailyFibomcu",OBJPROP_PRICE2,LoPrice);
		}
   	ObjectSet("dailyFibomcu",OBJPROP_LEVELCOLOR,indicator_color2); 
   	ObjectSet("dailyFibomcu",OBJPROP_FIBOLEVELS,7);
   	ObjectSet("dailyFibomcu",OBJPROP_FIRSTLEVEL+0,line1);	ObjectSetFiboDescription("monthly",0,"monthly -  %$"); 
   	ObjectSet("dailyFibomcu",OBJPROP_FIRSTLEVEL+1,line2);	ObjectSetFiboDescription("monthly",1,"monthly -  %$"); 
   	ObjectSet("dailyFibomcu",OBJPROP_FIRSTLEVEL+2,line3);	ObjectSetFiboDescription("monthly",2,"monthly -  %$"); 
   	ObjectSet("dailyFibomcu",OBJPROP_FIRSTLEVEL+3,line4);	ObjectSetFiboDescription("monthly",3,"monthly -  %$"); 
   	ObjectSet("dailyFibomcu",OBJPROP_FIRSTLEVEL+4,line5);	ObjectSetFiboDescription("monthly",4,"monthly -  %$"); 
   	ObjectSet("dailyFibomcu",OBJPROP_FIRSTLEVEL+5,line6);	ObjectSetFiboDescription("monthly",5,"monthly -  %$"); 
   	ObjectSet("dailyFibomcu",OBJPROP_FIRSTLEVEL+6,line7);	ObjectSetFiboDescription("monthly",6,"monthly -  %$"); 
   	ObjectSet("dailyFibomcu",OBJPROP_RAY,true);
   	ObjectSet("dailyFibomcu",OBJPROP_BACK,true);
   }

//+------------------------------------------------------------------+
//| Indicator start function
//+------------------------------------------------------------------+

int start()
{

	int shift	= iBarShift(NULL,period,Time[0]) + 1;	// yesterday
	HiPrice		= iHigh(NULL,period,shift);
	LoPrice		= iLow (NULL,period,shift);
	StartTime	= iTime(NULL,period,shift);

	if(TimeDayOfWeek(StartTime)==0/*Sunday*/)
	{//Add fridays high and low
		HiPrice = MathMax(HiPrice,iHigh(NULL,period,shift+1));
		LoPrice = MathMin(LoPrice,iLow(NULL,period,shift+1));
	}

	Range = HiPrice-LoPrice;

	DrawFibo();

	return(0);
}
//+------------------------------------------------------------------+

Recommend