Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
KRI
//+------------------------------------------------------------------+
//| KRI.mq4 |
//| Copyright © 2009, LeMan. |
//| b-market@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, LeMan"
#property link "b-market@mail.ru"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- Âõîäíûå ïàðàìåòðû
extern int KRIPeriod = 13;
//---- Áóôåðû
double KRIBuffer[];
//+------------------------------------------------------------------+
//| Ôóíêöèÿ èíèöèàëèçàöèè |
//+------------------------------------------------------------------+
int init() {
string short_name;
//---- Ëèíèè èíäèêàòîðà
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, KRIBuffer);
//---- Íàäïèñè â îêíå
short_name = "KRI ("+KRIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0, short_name);
//----
SetIndexDrawBegin(0, KRIPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Ìåòîä Êàèðè |
//+------------------------------------------------------------------+
int start() {
int i, counted_bars=IndicatorCounted();
//----
if (Bars <= KRIPeriod) return(0);
//---- initial zero
if (counted_bars < 1)
for (i = 1; i <= KRIPeriod; i++) KRIBuffer[Bars-i] = 0.0;
//----
i = Bars-KRIPeriod-1;
if (counted_bars >= KRIPeriod) i = Bars-counted_bars-1;
while(i >= 0) {
double ma = iMA(NULL,0,KRIPeriod,0,MODE_SMA,PRICE_CLOSE,i);
KRIBuffer[i] = ((Close[i]-ma)/ma)*100;
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
---