/*+------------------------------------------------------------------+ | 1DayFibo | | Copyright © 2011 | | basisforex@gmail.com | +-------------------------------------------------------------------*/ #property copyright "Copyright © 2011, basisforex@gmail.com" #property link "basisforex@gmail.com" //---------------------------------------- #property indicator_chart_window //--- extern color UpperFiboColor = Aqua; extern color LowerFiboColor = Aqua; //--- double HiPrice, LoPrice, CloPrice, Range; datetime StartTime; //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ int deinit() { ObjectDelete("FiboUp"); ObjectDelete("FiboDn"); return(0); } //+------------------------------------------------------------------+ int DrawFibo() { if(ObjectFind("FiboUp") == -1) ObjectCreate("FiboUp",OBJ_FIBO,0,StartTime,CloPrice+Range,StartTime,CloPrice); else { ObjectSet("FiboUp",OBJPROP_TIME2, StartTime); ObjectSet("FiboUp",OBJPROP_TIME1, StartTime); ObjectSet("FiboUp",OBJPROP_PRICE1,CloPrice + Range); ObjectSet("FiboUp",OBJPROP_PRICE2,CloPrice); } ObjectSet("FiboUp",OBJPROP_LEVELCOLOR,UpperFiboColor); ObjectSet("FiboUp",OBJPROP_FIBOLEVELS,12); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+0, 0.000); ObjectSetFiboDescription("FiboUp",0, "(0.0%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+1, 0.236); ObjectSetFiboDescription("FiboUp",1, "(23.6%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+2, 0.382); ObjectSetFiboDescription("FiboUp",2, "(38.2%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+3, 0.500); ObjectSetFiboDescription("FiboUp",3, "(50.0%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+4, 0.618); ObjectSetFiboDescription("FiboUp",4, "(61.8%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+5, 0.820); ObjectSetFiboDescription("FiboUp",5, "(82.0%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+6, 1.000); ObjectSetFiboDescription("FiboUp",6, "(100.0%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+7, 1.382); ObjectSetFiboDescription("FiboUp",7, "(138.2%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+8, 1.618); ObjectSetFiboDescription("FiboUp",8, "(161.8%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+9, 2.236); ObjectSetFiboDescription("FiboUp",9, "(223.6%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+10,3.000); ObjectSetFiboDescription("FiboUp",10,"(300.0%) - %$"); ObjectSet("FiboUp",OBJPROP_FIRSTLEVEL+11,5.000); ObjectSetFiboDescription("FiboUp",11,"(500.0%) - %$"); ObjectSet("FiboUp",OBJPROP_RAY,true); ObjectSet("FiboUp",OBJPROP_BACK,true); if(ObjectFind("FiboDn") == -1) ObjectCreate("FiboDn",OBJ_FIBO,0,StartTime,CloPrice-Range,StartTime,CloPrice); else { ObjectSet("FiboDn",OBJPROP_TIME2, StartTime); ObjectSet("FiboDn",OBJPROP_TIME1, StartTime); ObjectSet("FiboDn",OBJPROP_PRICE1,CloPrice - Range); ObjectSet("FiboDn",OBJPROP_PRICE2,CloPrice); } ObjectSet("FiboDn",OBJPROP_LEVELCOLOR,LowerFiboColor); ObjectSet("FiboDn",OBJPROP_FIBOLEVELS,12); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+0, 0.000); ObjectSetFiboDescription("FiboDn",0, "(0.0%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+1, 0.236); ObjectSetFiboDescription("FiboDn",1, "(-23.6%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+2, 0.382); ObjectSetFiboDescription("FiboDn",2, "(-38.2%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+3, 0.500); ObjectSetFiboDescription("FiboDn",3, "(-50.0%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+4, 0.618); ObjectSetFiboDescription("FiboDn",4, "(-61.8%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+5, 0.820); ObjectSetFiboDescription("FiboDn",5, "(-82.0%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+6, 1.000); ObjectSetFiboDescription("FiboDn",6, "(-100.0%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+7, 1.382); ObjectSetFiboDescription("FiboDn",7, "(-138.2%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+8, 1.618); ObjectSetFiboDescription("FiboDn",8, "(-161.8%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+9, 2.236); ObjectSetFiboDescription("FiboDn",9, "(-223.6%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+10,3.000); ObjectSetFiboDescription("FiboDn",10,"(-300.0%) - %$"); ObjectSet("FiboDn",OBJPROP_FIRSTLEVEL+11,5.000); ObjectSetFiboDescription("FiboDn",11,"(-500.0%) - %$"); ObjectSet("FiboDn",OBJPROP_RAY,true); ObjectSet("FiboDn",OBJPROP_BACK,true); } //+------------------------------------------------------------------+ int start() { int shift = iBarShift(NULL,PERIOD_D1,Time[0]) + 1; // yesterday HiPrice = iHigh(NULL,PERIOD_D1,shift); LoPrice = iLow(NULL,PERIOD_D1,shift); CloPrice = iClose(NULL,PERIOD_D1,shift); StartTime = iTime(NULL,PERIOD_D1,shift - 1); if(TimeDayOfWeek(StartTime)==0/*Sunday*/) {//Add fridays high and low HiPrice = MathMax(HiPrice,iHigh(NULL,PERIOD_D1,shift+1)); LoPrice = MathMin(LoPrice,iLow(NULL,PERIOD_D1,shift+1)); CloPrice = iClose(NULL,PERIOD_D1,shift+1); } Range = HiPrice-LoPrice; DrawFibo(); return(0); } //+------------------------------------------------------------------+