Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
3Color_RVI_Hist
//+------------------------------------------------------------------+
//| 3Color_RVI_Hist.mq4 |
//| Copyright © 2005, Nikolay Kositsin. |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Nikolay Kositsin ."
#property link ""
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_level2 0.0
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Purple
//---- input parameters
extern int RVIPeriod = 10;
extern int SignPeriod= 4;
extern int CountBars = 300;
//---- buffers
double ind_buffer1 [];
double ind_buffer2 [];
double ind_buffer3 [];
double RVIBuffer [];
double SignalBuffer[];
double TempBuffer [];
double RVI,UpRVI, DownRVI;
//-----------------------------
double value, Oldvalue, minuse;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
double Color1 = C'128,0,255';
SetIndexStyle(0,DRAW_HISTOGRAM, STYLE_SOLID, 3, Color1);
SetIndexStyle(1,DRAW_HISTOGRAM, STYLE_SOLID, 3);
SetIndexStyle(2,DRAW_HISTOGRAM, STYLE_SOLID, 3);
SetIndexDrawBegin(0,Bars-CountBars);
SetIndexDrawBegin(1,Bars-CountBars);
SetIndexDrawBegin(2,Bars-CountBars);
//---- 6 additional buffers are used for counting.
IndicatorBuffers(6);
SetIndexBuffer(0, ind_buffer1 );
SetIndexBuffer(1, ind_buffer2 );
SetIndexBuffer(2, ind_buffer3 );
SetIndexBuffer(3, TempBuffer );
SetIndexBuffer(4, RVIBuffer );
SetIndexBuffer(5, SignalBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="RVI("+RVIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,"RVI_UP");
SetIndexLabel(1,"RVI_DOWN");
SetIndexLabel(2,"RVI_Stright");
//----
SetIndexEmptyValue(0,0);
SetIndexEmptyValue(1,0);
SetIndexEmptyValue(2,0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Relative Vigor Index |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
if(Bars<=RVIPeriod) return(0);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//--------RVI_Hist-----------------------------------------------------------------------------------------------------=
for(int i=0; i<limit; i++) { UpRVI=Close[i]-Open[i]; DownRVI=High[i]-Low[i]; RVI=UpRVI/DownRVI; TempBuffer[i]= RVI; }
for(int k=0; k<limit; k++) RVIBuffer [k]=iMAOnArray(TempBuffer, Bars, RVIPeriod, 0,MODE_SMA, k);
for( k=0; k<limit; k++) SignalBuffer[k]=iMAOnArray(RVIBuffer , Bars,SignPeriod, 0,MODE_LWMA, k);
//---- 3 Color---------------------------------------------------------------------------------------------------------+
for( k=0; k<limit; k++)
{
ind_buffer1[k]=0.0; ind_buffer2[k]=0.0; ind_buffer3[k]= 0.0;
Oldvalue=SignalBuffer[k+1]; value= SignalBuffer[k]; minuse = value - Oldvalue;
if(minuse>0.0)ind_buffer1[k]= value; else {if(minuse<0.0) ind_buffer2[k]= value; else ind_buffer3[k]= value;}
}
//--------------------------------------------------------------------------------------------------------------------+
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
---