Miscellaneous
0
Views
0
Downloads
0
Favorites
ExVol
//+------------------------------------------------------------------+
//| ExVol.mq4 |
//| Copyright © 2006, Alex Sidd (Executer) |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Alex Sidd (Executer)"
#property link "mailto:work_st@mail.ru"
//----
#property indicator_separate_window
#property indicator_minimum -100
#property indicator_maximum 100
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_color2 Blue
#property indicator_color3 Red
//---- input parameters
extern int ExPeriod = 15;
//---- buffers
double VolBuffer[];
double PosBuffer[];
double NegBuffer[];
//+------------------------------------------------------------------+
//| initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(3);
SetIndexStyle(0, DRAW_NONE);
SetIndexBuffer(0, VolBuffer);
SetIndexStyle(1, DRAW_HISTOGRAM);
SetIndexBuffer(1, PosBuffer);
SetIndexStyle(2, DRAW_HISTOGRAM);
SetIndexBuffer(2, NegBuffer);
SetIndexDrawBegin(0, ExPeriod);
SetIndexDrawBegin(1, ExPeriod);
SetIndexDrawBegin(2, ExPeriod);
//----
SetIndexLabel(1, NULL);
SetIndexLabel(2, NULL);
//----
short_name = "ExVol(" + ExPeriod + ")";
IndicatorShortName(short_name);
SetIndexLabel(0, short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Executer Vol Indicator |
//+------------------------------------------------------------------+
int start()
{
int i, counted_bars = IndicatorCounted();
double negative = 0, positive = 0;
//----
if(Bars <= ExPeriod)
return(0);
if(counted_bars < 1)
for(i = 1; i <= ExPeriod; i++)
VolBuffer[Bars-i] = 0.0;
//----
i = Bars - ExPeriod - 1;
if(counted_bars >= ExPeriod)
i = Bars - counted_bars - 1;
while(i >= 0)
{
negative = 0;
positive = 0;
if(i < Bars - ExPeriod - 1)
{
int k = i + ExPeriod;
while(k >= i)
{
if(Open[k] < Close[k])
positive += (Close[k] - Open[k]);
if(Open[k] > Close[k])
negative += (Open[k] - Close[k]);
if(Open[k] == Close[k])
{
negative += 0;
positive += 0;
}
k--;
}
}
if((positive - negative) > 0)
PosBuffer[i] = (positive - negative)*3000;
if((positive - negative) < 0)
NegBuffer[i] = (positive - negative)*3000;
VolBuffer[i] = (positive - negative)*3000;
i--;
}
//----
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
---