Fibo MultiColor

0 Views
0 Downloads
0 Favorites
Fibo MultiColor

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DarkSlateGray
//---- indicator parameters
extern int HighBarsBack     =50;
extern int LowBarsBack      =100;

extern color Fibo_0_Color   = Gold;
extern color Fibo_236_Color = Aqua;
extern color Fibo_382_Color = Lime;
extern color Fibo_500_Color = Orange;
extern color Fibo_618_Color = Blue;
extern color Fibo_764_Color = Magenta;
extern color Fibo_100_Color = Gray;
//---- indicator buffers

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
//---- indicator short name
   IndicatorShortName("Fibo MultiColor");
   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("FIB100 Label");
   ObjectDelete("FIB100 Line");
   ObjectDelete("FIB0 Label");
   ObjectDelete("FIB0 Line");
   ObjectDelete("FIB236 Label");
   ObjectDelete("FIB236 Line");
   ObjectDelete("FIB382 Label");
   ObjectDelete("FIB382 Line");
   ObjectDelete("FIB50 Label");
   ObjectDelete("FIB50 Line");
   ObjectDelete("FIB618 Label");
   ObjectDelete("FIB618 Line");
   ObjectDelete("FIB764 Label");
   ObjectDelete("FIB764 Line");
   ObjectDelete("Start");
   ObjectDelete("End");

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
    
  
//+---------------------+
//| Fibo lines function |
//+---------------------+
  double FIBO100,FIBO0,Q,FIBO236,FIBO382,FIBO50,FIBO618,FIBO764;
  double WaveStart,WaveEnd;

  
  if(HighBarsBack>LowBarsBack)
  {
  FIBO0=High[iHighest(NULL,0,MODE_HIGH,HighBarsBack,0)];
  FIBO100=Low[iLowest(NULL,0,MODE_LOW,LowBarsBack,0)];
  Q=MathAbs(FIBO100-FIBO0);
  FIBO236=FIBO0-(Q*0.236);
  FIBO382=FIBO0-(Q*0.382);
  FIBO50=FIBO0-(Q*0.5);
  FIBO618=FIBO0-(Q*0.618);
  FIBO764=FIBO0-(Q*0.764);
  }
  else
  {
  FIBO100=High[iHighest(NULL,0,MODE_HIGH,HighBarsBack,0)];
  FIBO0=Low[iLowest(NULL,0,MODE_LOW,LowBarsBack,0)];
  Q=FIBO100-FIBO0;
  FIBO236=FIBO0+(Q*0.236);
  FIBO382=FIBO0+(Q*0.382);
  FIBO50=FIBO0+(Q*0.5);
  FIBO618=FIBO0+(Q*0.618);
  FIBO764=FIBO0+(Q*0.764);
  }
  
  
//+---------------------------------------------------------+
//| Set line labels and arrows on chart window              |
//+---------------------------------------------------------+
//---- Arrows ----//
       if(ObjectFind("Start") != 0)
         { ObjectCreate("Start", OBJ_ARROW, 0, Time[HighBarsBack],FIBO0);
           ObjectSet("Start", OBJPROP_ARROWCODE, 2);
         } else {
           ObjectMove("WaveStart", 0, Time[HighBarsBack],FIBO0);
         }
       //----
       if(ObjectFind("End") != 0)
         { ObjectCreate("End", OBJ_ARROW, 0, Time[LowBarsBack],FIBO100);
           ObjectSet("End", OBJPROP_ARROWCODE, 3);
         } else {
           ObjectMove("End", 0, Time[LowBarsBack],FIBO100);
         }
         
//---- Fibo Lines ----//
       string gap = "                               ";
       
    if(HighBarsBack>LowBarsBack){int length = HighBarsBack;}else{length = LowBarsBack;} 
        
    Text("FIB100 label",0,gap+ "100.0%  "+DoubleToStr(FIBO100,Digits),8,"Arial",Fibo_100_Color,Time[length],FIBO100,true);            
       
    Text("FIB0 label",0,gap+ "0.0%  "+DoubleToStr(FIBO0,Digits),8,"Arial",Fibo_0_Color,Time[length],FIBO0,true);        
        
    Text("FIB236 label",0,gap+ "23.6%  "+DoubleToStr(FIBO236,Digits),8,"Arial",Fibo_236_Color,Time[length],FIBO236,true);             

    Text("FIB382 label",0,gap+ "38.2%  "+DoubleToStr(FIBO382,Digits),8,"Arial",Fibo_382_Color,Time[length],FIBO382,true);             
        
    Text("FIB50 label",0,gap+ "38.2%  "+DoubleToStr(FIBO50,Digits),8,"Arial",Fibo_500_Color,Time[length],FIBO50,true);             

    Text("FIB618 label",0,gap+ "61.8%  "+DoubleToStr(FIBO618,Digits),8,"Arial",Fibo_618_Color,Time[length],FIBO618,true);             

    Text("FIB764 label",0,gap+ "76.4%  "+DoubleToStr(FIBO764,Digits),8,"Arial",Fibo_764_Color,Time[length],FIBO764,true);             

       //------------------------------------------------------------
   if(HighBarsBack>LowBarsBack)
  {         
   Level("FIB100 line",0,FIBO100,FIBO100,Time[length],0,4,Fibo_100_Color,true);      
       
   Level("FIB0 line",0,FIBO0,FIBO0,Time[length],0,4, Fibo_0_Color,true);
      
   Level("FIB236 line",0,FIBO236,FIBO236,Time[length],0,4, Fibo_236_Color,true);      
       
   Level("FIB382 line",0,FIBO382,FIBO382,Time[length],0,2, Fibo_382_Color,true);
   
   Level("FIB50 line",0,FIBO50,FIBO50,Time[length],0,4, Fibo_500_Color,true); 
    
   Level("FIB618 line",0,FIBO618,FIBO618,Time[length],0,2,Fibo_618_Color,true); 
      
   Level("FIB764 line",0,FIBO764,FIBO764,Time[length],0,4,Fibo_764_Color,true); 
   
   }else{ 
   
   Level("FIB100 line",0,FIBO100,FIBO100,Time[length],0,4,Fibo_100_Color,true);      
       
   Level("FIB0 line",0,FIBO0,FIBO0,Time[length],0,4, Fibo_0_Color,true);
      
   Level("FIB236 line",0,FIBO236,FIBO236,Time[length],0,4, Fibo_236_Color,true);      
       
   Level("FIB382 line",0,FIBO382,FIBO382,Time[length],0,2, Fibo_382_Color,true);
   
   Level("FIB50 line",0,FIBO50,FIBO50,Time[length],0,4, Fibo_500_Color,true); 
    
   Level("FIB618 line",0,FIBO618,FIBO618,Time[length],0,2,Fibo_618_Color,true); 
      
   Level("FIB764 line",0,FIBO764,FIBO764,Time[length],0,4,Fibo_764_Color,true); 
   }             
      
     return(0);
}
  
void Level(string Levels, int Window,double start, double end,double time,double w, double s,color clr, bool delete)
  {
   if (delete) ObjectDelete(Levels);
   if(ObjectFind(Levels)!=0)
     { 
   ObjectCreate(Levels, OBJ_TREND, 0, 0, start, Time[0],end);
   ObjectSet(Levels, OBJPROP_COLOR, clr);
   ObjectSet(Levels,OBJPROP_RAY,false);
   ObjectSet(Levels,OBJPROP_BACK,true);
   ObjectSet(Levels,OBJPROP_WIDTH,w);
   ObjectSet(Levels,OBJPROP_STYLE,s);
   ObjectSet(Levels,OBJPROP_TIME1,time);
     }
   else
   ObjectMove(Levels, 0, 0, Time[0]);
  } 
  
    
void Text(string TextName, int Window, string LabelText, int FontSize, string FontName, color TextColor, datetime Time1, double Price1, bool delete)
  {
   if (delete) ObjectDelete(TextName);
   if(ObjectFind(TextName)!=0)
     {
    ObjectCreate(TextName, OBJ_TEXT, Window, Time1,Price1);
    ObjectSetText(TextName, LabelText, FontSize, FontName, TextColor);
    ObjectSet(TextName,OBJPROP_BACK,true);
     }
   else
   ObjectMove(TextName, 0, Time1, Price1);
  } 


   
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---