Author: Coders' Guru
Fiboossss
0 Views
0 Downloads
0 Favorites
Fiboossss
//+------------------------------------------------------------------+
//|                                                        Fibos.mq4 |
//|                                        Developed by Coders' Guru |
//|                                            http://www.xpworx.com |
//+------------------------------------------------------------------+

#property copyright "Coders' Guru"
#property link      "http://www.xpworx.com"
string   ver  = "Last Modified: 2008.02.22 19:20";

#property indicator_chart_window
#property  indicator_buffers 7

extern bool  Higher_To_Lower  = true;    //else Lower_To_Higher
extern bool  DrawVerticalLines = true;
extern int   StartBar = 0;
extern int   BarsBack = 20;
extern color FiboColor=Yellow ;
extern int   FiboStyle=STYLE_DOT ;
extern int   LineStyle=0 ;
extern int   LineWidth=1;
extern color LineColor=Red ;

double f_1[];
double f_2[];


void DeleteAllObjects()
{
   int objs = ObjectsTotal();
   string name;
   for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)
   {
      name=ObjectName(cnt);
      if (StringFind(name,"V_",0)>-1) ObjectDelete(name);
      if (StringFind(name,"H_",0)>-1) ObjectDelete(name);
      if (StringFind(name,"f_",0)>-1) ObjectDelete(name);
      if (StringFind(name,"fib",0)>-1) ObjectDelete(name);
      if (StringFind(name,"trend",0)>-1) ObjectDelete(name);
      WindowRedraw();
   }
}


void CalcFibo()
{
  
  DeleteAllObjects();
  
  int lowest_bar = iLowest(NULL,0,MODE_LOW,BarsBack,StartBar);
  int highest_bar = iHighest(NULL,0,MODE_HIGH,BarsBack,StartBar);
  
  double higher_point = 0;
  double lower_point = 0;
  higher_point=High[highest_bar];
  lower_point=Low[lowest_bar];
  
  if(DrawVerticalLines) DrawVerticalLine("V_UPPER",highest_bar,LineColor);
  if(DrawVerticalLines) DrawVerticalLine("V_LOWER",lowest_bar,LineColor);
  
  int i = 0;
  
  if(Higher_To_Lower)
  {
      for(i = 0; i < 500; i++)
      {
         f_1[i] = higher_point;
         f_2[i] = lower_point;
      }
      ObjectCreate("fib",OBJ_FIBO,0,0,higher_point,0,lower_point);
      ObjectSet("fib",OBJPROP_STYLE,STYLE_DOT);
      ObjectSet("fib",OBJPROP_LEVELCOLOR,FiboColor);
      ObjectSet("fib",OBJPROP_LEVELSTYLE,FiboStyle);
      ObjectCreate("trend",OBJ_TREND,0,Time[highest_bar],higher_point,Time[lowest_bar],lower_point);
      ObjectSet("trend",OBJPROP_STYLE,STYLE_DOT);
      ObjectSet("trend",OBJPROP_RAY,false);
  }
  else
  {
      for(i = 0; i < 500; i++)
      {
         f_1[i] = higher_point;
         f_2[i] = lower_point;
      }
      DeleteAllObjects();
      ObjectCreate("fib",OBJ_FIBO,0,0,higher_point,0,lower_point);
      ObjectSet("fib",OBJPROP_STYLE,STYLE_DOT);
      ObjectSet("fib",OBJPROP_LEVELCOLOR,FiboColor);
      ObjectSet("fib",OBJPROP_LEVELSTYLE,FiboStyle);
      ObjectCreate("trend",OBJ_TREND,0,Time[lowest_bar],lower_point,Time[highest_bar],higher_point);
      ObjectSet("trend",OBJPROP_STYLE,STYLE_DOT);
      ObjectSet("trend",OBJPROP_RAY,false);
  }
  
  
}

void DrawVerticalLine(string name , int bar , color clr)
{
   if(ObjectFind(name)==false)
   {
      ObjectCreate(name,OBJ_VLINE,0,Time[bar],0);
      ObjectSet(name,OBJPROP_COLOR,clr);
      ObjectSet(name,OBJPROP_WIDTH,LineWidth);
      ObjectSet(name,OBJPROP_STYLE,LineStyle);
      WindowRedraw();
   }
   else
   {
      ObjectDelete(name);
      ObjectCreate(name,OBJ_VLINE,0,Time[bar],0);
      ObjectSet(name,OBJPROP_COLOR,clr);
      ObjectSet(name,OBJPROP_WIDTH,LineWidth);
      ObjectSet(name,OBJPROP_STYLE,LineStyle);
      WindowRedraw();
   }

}



int deinit()
{
   DeleteAllObjects();
   return (0);
}

int init()
{
  DeleteAllObjects();
  SetIndexBuffer(0,f_1);
  SetIndexBuffer(1,f_2);

  return(0);
}


int start()
{
  CalcFibo();
  return(0);
}







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 ---