Price Data Components
Miscellaneous
0
Views
0
Downloads
0
Favorites
Linear_Price_Bar_mtf
//+------------------------------------------------------------------+
//| Linear Price Bar.mq4 |
//| Copyright © 2006, Keris2112 |
//| 2008txtsd ki none |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Keris2112"
#property link "none"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 4
#property indicator_width4 4
#property indicator_levelcolor SlateBlue
//---- buffers
extern int TimeFrame = 0;
extern int MaxBarsToCount = 1500;
extern string note_timeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM);
SetIndexBuffer(3,ExtMapBuffer4);
switch(TimeFrame)
{
case 1 : string TimeFrameStr= "M1"; break;
case 5 : TimeFrameStr= "M5"; break;
case 15 : TimeFrameStr= "M15"; break;
case 30 : TimeFrameStr= "M30"; break;
case 60 : TimeFrameStr= "H1"; break;
case 240 : TimeFrameStr= "H4"; break;
case 1440 : TimeFrameStr= "D1"; break;
case 10080 : TimeFrameStr= "W1"; break;
case 43200 : TimeFrameStr= "MN1"; break;
default : TimeFrameStr= "CurrTF";
}
IndicatorShortName("LPB ["+TimeFrameStr+"]");
if (TimeFrame<Period()) TimeFrame=Period();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int UpDays, DownDays, NeutralDays;
double BarH, BarL, BarC;
double open, close, high, low;
datetime TimeArray[];
int i,limit,y=0,counted_bars=IndicatorCounted();
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
limit= Bars-counted_bars;
limit= MathMax(limit,TimeFrame/Period());
limit= MathMin(limit,MaxBarsToCount);
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
open = iOpen (NULL,TimeFrame,y);
close = iClose(NULL,TimeFrame,y);
high = iHigh (NULL,TimeFrame,y);
low = iLow (NULL,TimeFrame,y);
BarH = high-open;
BarL = low-open;
BarC = close-open;
if(BarC>0) UpDays += 1;
else if(BarC<0) DownDays +=1;
else if(BarC==0) NeutralDays +=1;
ExtMapBuffer1[i] = BarH;
ExtMapBuffer2[i] = BarL;
// SortBuffer1[i] = BarH;
// SortBuffer2[i] = BarL;
if(close>open)
{
ExtMapBuffer3[i] = BarC;
ExtMapBuffer4[i] = 0;
}
else
{
ExtMapBuffer3[i] = 0;
ExtMapBuffer4[i] = BarC;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
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
---