BatFink Daily High-Low

BatFink Daily High-Low
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
BatFink Daily High-Low
/*------------------------------------------------------------------+
//| dayHL_Average.mq4 |
//+------------------------------------------------------------------+
/*

*/

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color3 Blue

//---- input parameters5
extern int show_comment=0; // comments on the chart (0 - no, 1 - yes)
extern int how_long=10000; // bars to be counted (-1 - all the bars)

//---- indicator buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(0, DRAW_LINE, STYLE_DOT);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexStyle(1, DRAW_LINE, STYLE_DOT);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexStyle(2, DRAW_LINE, STYLE_DOT);
return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
Comment("");
return(0);
}

int start()
{
int cnt=0;
int begin_bar=0; 
int prev_day, cur_day; 
double day_high=0; 
double day_low=0; 
double yesterday_high=0; 
double yesterday_low=0; 
double yesterday_close=0; 
double P, S, R;

if (Period() >= PERIOD_D1) {
Comment("WARNING: Invalid timeframe! Valid value < D1.");
return(0);
}

if (how_long == -1) {
begin_bar = Bars;
} else {
begin_bar = how_long;
}

for (cnt = begin_bar; cnt >= 0; cnt--) {
cur_day = TimeDay(Time[cnt]);
if (prev_day != cur_day) {
yesterday_close = Close[cnt+1];
yesterday_high = day_high;
yesterday_low = day_low;
P = (yesterday_high + yesterday_low ) / 2;
R = yesterday_high;
S = yesterday_low;

//
day_high = High[cnt];
day_low = Low[cnt];

//
prev_day = cur_day;
}

// ïðîäîëæàåì íàêàïëèâàòü äàííûå
day_high = MathMax(day_high, High[cnt]);
day_low = MathMin(day_low, Low[cnt]);

// 
//ExtMapBuffer2[cnt] = P;

ExtMapBuffer1[cnt] = R; 
ExtMapBuffer3[cnt] = S;
}

if (show_comment == 1) {
P = (yesterday_high + yesterday_low ) / 2;
R = yesterday_high;
S = yesterday_low;

Comment("Current H=", R, ", L=", S, ", HL/2=", P, ", H-L=", (R-S)/Point );
}
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 ---