Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
sumMA
//+------------------------------------------------------------------+
//| OtherChart.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "jax1000"
#property link "jax1000@list.ru"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
extern int period1=20;//íà÷àëüíûé ïåðèîä èíòåðâàëà
extern int period2=100;//êîíå÷íûé ïåðèîä èíòåðâàëà
extern int MA_Method=0;//ìåòîä ñãëàæèâàíèÿ ñêîëüçÿùåé
extern int Price=0;
extern int shift=0;//ñäâèã ñêîëüçÿùèõ, îòíîñèòåëüíî íîìåðà áàðà
extern int width=1;//òîëùèíà ëèíèè èíäèêàòîðà
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
double Buffer[];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,0,0,width);
SetIndexBuffer(0,Buffer);
SetIndexLabel(0,"SUM/MA");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- ïîñëåäíèé ïîñ÷èòàííûé áàð áóäåò ïåðåñ÷èòàí
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- îñíîâíîé öèêë
for(int i=0; i<limit; i++)
{string symbol=Symbol();
Buffer[i]=MA(symbol,0,period1,period2,shift,MA_Method,Price,i);
}
return(0);
}
//+------------------------------------------------------------------+
double MA(string symbol, int frame, int period1, int period2, int shift, int MA_Method, int Price, int z)
{double s=period1;
double res=0;
double y=0;
double d=0;
while(s<(period2+1))
{
y=iMA(symbol,frame,s,shift,MA_Method,Price,z);
d+=y;
s++;
}
res=d/(period2+1-period1);
return(res);
}
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
---