Miscellaneous
0
Views
0
Downloads
0
Favorites
Fibonacci_Daily
//+------------------------------------------------------------------+
//| Fibonacci_Daily.mq4 |
//| Copyright © 2008, Kris |
//| Time optimised for Forex.com |
//+------------------------------------------------------------------+
#property copyright " © 2008, Kris "
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 C'000,100,000' // DarkGreen // 1.618
#property indicator_color2 C'000,150,000' // Green // 1.272
#property indicator_color3 C'000,255,000' // Lime // 1.000
#property indicator_color4 C'100,100,100' // Gray // 0.618
#property indicator_color5 C'100,100,100' // Gray // 0.382
#property indicator_color6 C'255,000,000' // Red // 0.000
#property indicator_color7 C'150,000,000' // Crimson //-1.272
#property indicator_color8 C'100,000,000' // Maroon //-1.618
//Input Params
extern string PivotStart = "22:00";
extern string PivotEnd = "22:00";
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
double Buffer7[];
double Buffer8[];
double LastHigh,LastLow,LastClose;
double Fib1000,Fib0618,Fib0382,Fib0000;
double FibP1272,FibP1618,FibN1272,FibN1618;
int OpenBar;
int init()
{ SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,160);
SetIndexBuffer(0,Buffer1);
SetIndexLabel(0,"Fibonacci +1.618");
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,160);
SetIndexBuffer(1,Buffer2);
SetIndexLabel(1,"Fibonacci +1.272");
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,167);
SetIndexBuffer(2,Buffer3);
SetIndexLabel(2,"Fibonacci 1.000");
SetIndexStyle(3,DRAW_ARROW);
SetIndexArrow(3,160);
SetIndexBuffer(3,Buffer4);
SetIndexLabel(3,"Fibonacci 0.618");
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,160);
SetIndexBuffer(4,Buffer5);
SetIndexLabel(4,"Fibonacci 0.382");
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,167);
SetIndexBuffer(5,Buffer6);
SetIndexLabel(5,"Fibonacci 0.000");
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,160);
SetIndexBuffer(6,Buffer7);
SetIndexLabel(6,"Fibonacci -1.272");
SetIndexStyle(7,DRAW_ARROW);
SetIndexArrow(7,160);
SetIndexBuffer(7,Buffer8);
SetIndexLabel(7,"Fibonacci -1.618");
return(0); }
int deinit() {
ObjectDelete("Fib161");
ObjectDelete("Fib127");
ObjectDelete("Fib100");
ObjectDelete("Fib618");
ObjectDelete("Fib382");
ObjectDelete("Fib000");
ObjectDelete("Fib128");
ObjectDelete("Fib162");
Comment("");
return(0); }
int start()
{ string BarTime="", LastBarTime="";
string BarDay="", LastBarDay="";
int CloseBar;
for(int i=Bars; i>=0; i--)
{ if (Period() > 240) return(0); //Chart cannot be higher than H4
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);
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];
double R = (LastHigh - LastLow);
FibP1618 = LastHigh + R * 0.618;
FibP1272 = LastHigh + R * 0.272;
Fib1000 = LastHigh;
Fib0618 = LastLow + R * 0.618;
Fib0382 = LastLow + R * 0.382;
Fib0000 = LastLow;
FibN1272 = LastLow - R * 0.272;
FibN1618 = LastLow - R * 0.618;
}
void drawIndicators(int curBar)
{
Buffer1[curBar]=FibP1618;
Buffer2[curBar]=FibP1272;
Buffer3[curBar]=Fib1000;
Buffer4[curBar]=Fib0618;
Buffer5[curBar]=Fib0382;
Buffer6[curBar]=Fib0000;
Buffer7[curBar]=FibN1272;
Buffer8[curBar]=FibN1618;
DoLabel( "Fib161", Buffer1[0], indicator_color1 );
DoLabel( "Fib127", Buffer2[0], indicator_color2 );
DoLabel( "Fib100", Buffer3[0], indicator_color3 );
DoLabel( "Fib618", Buffer4[0], indicator_color4 );
DoLabel( "Fib382", Buffer5[0], indicator_color5 );
DoLabel( "Fib000", Buffer6[0], indicator_color6 );
DoLabel( "Fib128", Buffer7[0], indicator_color7 );
DoLabel( "Fib162", Buffer8[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
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---