Indicators Used
Miscellaneous
1
Views
1
Downloads
0
Favorites
RSI_Coloured_Final_v1
#property copyright "TheXpert"
#property link "theforexpert@gmail.com"
#property indicator_separate_window
#property indicator_maximum 100
#property indicator_minimum 0
#property indicator_buffers 3
#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red
#property indicator_color3 Khaki
//---- input parameters
extern string RSIPeriod_Desc = "Ïåðèîä RSI";
extern int RSIPeriod = 14;
extern string RSIPrice_Desc = "Öåíà RSI: 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted";
extern int RSIPrice = 0;
extern string HighLevel_Desc = "Âåðõíèé óðîâåíü RSI";
extern int HighLevel = 70;
extern string LowLevel_Desc = "Íèæíèé óðîâåíü RSI";
extern int LowLevel = 30;
extern string MarkFalse_Desc = "Ìàðêèðîâàòü èëè íåò áàðû, êîòîðûå ïðè ôîðìèðîâàíèè çàëàçèëè çà óðîâíè";
extern bool MarkFalse = false;
extern string Transparent_Desc = "Ðèñîâàòü RSI ïîâåðõ öâåòíûõ óðîâíåé";
extern bool Transparent = true;
extern string Width_Desc = "Øèðèíà ñèãíàëüíûõ ëèíèé";
extern int Width = 3;
//---- buffers
double RSI[];
double Inner[];
double Higher[];
double Lower[];
/// \brief Equal to ternar operator
/// needed = Condition ? IfTrue : IfFalse;
/// \param IfTrue
/// \param IfFalse
/// \return matching value from parameters
double DoubleIf(bool Condition, double IfTrue, double IfFalse)
{
if (Condition) return (IfTrue);
else return (IfFalse);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
SetIndexBuffer(0, Higher);
SetIndexBuffer(1, Lower);
SetIndexBuffer(2, Inner);
SetIndexBuffer(3, RSI);
SetLevelValue(0, HighLevel);
SetLevelValue(1, LowLevel);
SetIndexLabel(0, "RSI");
SetIndexLabel(1, "Âûøå óðîâíÿ");
SetIndexLabel(2, "Íèæå óðîâíÿ");
SetIndexStyle(0, DRAW_LINE, EMPTY, Width);
SetIndexStyle(1, DRAW_LINE, EMPTY, Width);
SetIndexDrawBegin(0, RSIPeriod + 1);
SetIndexDrawBegin(1, RSIPeriod + 1);
SetIndexDrawBegin(2, RSIPeriod + 1);
IndicatorShortName("Öâåòíîé RSI");
IndicatorDigits(2);
return(0);
}
int start()
{
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
int ToCount = Bars - counted_bars;
if(counted_bars==0) ToCount-=2;
for (int cnt = ToCount - 1; cnt >= 0; cnt--)
{
RSI[cnt] = iRSI(NULL, 0, RSIPeriod, RSIPrice, cnt);
int depth = 2;
if (MarkFalse)
{
depth = 1;
}
for (int i = cnt + depth - 1; i >= cnt; i--)
{
Higher[i] = EMPTY_VALUE;
Lower[i] = EMPTY_VALUE;
Inner[i] = RSI[i];
if (!Transparent)
{
if (RSI[i] <= LowLevel)
{
Inner[i] = DoubleIf(RSI[i + 1] > LowLevel, LowLevel, EMPTY_VALUE);
}
else
{
Inner[i] = DoubleIf(RSI[i + 1] <= LowLevel, LowLevel, RSI[i]);
}
if (RSI[i] >= HighLevel)
{
Inner[i] = DoubleIf(RSI[i + 1] < HighLevel, HighLevel, EMPTY_VALUE);
}
else
{
Inner[i] = DoubleIf(RSI[i + 1] >= HighLevel, HighLevel, Inner[i]);
}
}
if(RSI[i] >= HighLevel)
{
Higher[i] = RSI[i];
Higher[i + 1] = DoubleIf(RSI[i + 1] >= HighLevel, RSI[i + 1], HighLevel);
}
else if(RSI[i + 1] >= HighLevel)
{
Higher[i] = HighLevel;
Higher[i + 1] = RSI[i + 1];
}
if(RSI[i] <= LowLevel)
{
Lower[i] = RSI[i];
Lower[i + 1] = DoubleIf(RSI[i + 1] <= LowLevel, RSI[i + 1], LowLevel);
}
else if(RSI[i + 1] <= LowLevel)
{
Lower[i] = LowLevel;
Lower[i + 1] = RSI[i + 1];
}
}
}
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
---