Miscellaneous
0
Views
0
Downloads
0
Favorites
VSA_Candle
//+------------------------------------------------------------------+
//| VSA_Candel.mq4 |
//+------------------------------------------------------------------+
//| This is a simple code |
//| Everyone wants change, modify or put better fix can do, it's FREE|
//| You see 3 Histogram bar, Silver is the spread of candle high/low |
//| and the middle is at 0. |
//| Red/Green Histogram is the close of candle comparate to the |
//| middle of the spread. |
//| |
//| Defcon |
//+------------------------------------------------------------------+
#property copyright "Free"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Silver
#property indicator_color2 Silver
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 2
#property indicator_width4 2
//----
extern color color1 = Silver;
extern color color2 = Silver;
extern color color3 = Red;
extern color color4 = Green;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM, 0, 3, color1);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM, 0, 3, color2);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM, 0, 2, color3);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM, 0, 2, color4);
SetIndexBuffer(3, ExtMapBuffer4);
//----
SetIndexDrawBegin(0,0);
SetIndexDrawBegin(1,0);
SetIndexDrawBegin(2,0);
SetIndexDrawBegin(3,0);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double haClose,haSpread;
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
if(Close[pos]<(High[pos]+Low[pos]/2))
{
haClose=Close[pos]-((High[pos]+Low[pos])/2);
if(haClose<=0){
ExtMapBuffer3[pos]=haClose;
ExtMapBuffer4[pos]=0;
}
if(haClose>=0){
ExtMapBuffer3[pos]=0;
ExtMapBuffer4[pos]=haClose;
}
}
if(Close[pos]>(High[pos]+Low[pos]/2))
{
haClose=Close[pos]-((High[pos]+Low[pos])/2);
ExtMapBuffer3[pos]=0;
ExtMapBuffer4[pos]=haClose;
}
haSpread=(High[pos]-Low[pos]);
ExtMapBuffer1[pos]=haSpread/2;
ExtMapBuffer2[pos]=-haSpread/2;
pos--;
}
//----
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
---