Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
variation
//+------------------------------------------------------------------+
//| variation.mq4 |
//| Copyright © 2010, LeMan. |
//| b-market@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, LeMan."
#property link "b-market@mail.ru"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int N=20;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorDigits(Digits+2);
IndicatorBuffers(2);
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
//----
if (N <= 0) N = 20;
//----
SetIndexDrawBegin(0, N*2);
//----
short_name = "Variation (" + N + ")";
IndicatorShortName(short_name);
SetIndexLabel(0, short_name);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
int limit = Bars-N-1;
for (int i = limit; i >= 0; i--) {
double ma = iMA(NULL,0,N,0,MODE_SMA,PRICE_CLOSE,i);
ExtMapBuffer2[i] = Close[i]-ma;
}
//----
i = Bars-N*2-1;
while (i >= 0) {
double vr = iMAOnArray(ExtMapBuffer2,Bars,N,0,MODE_SMA,i);
double mov = iMA(NULL,0,N,0,MODE_SMA,PRICE_CLOSE,i);
ExtMapBuffer1[i] = Close[i] - (mov + vr);
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
---