Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
GMACD_v1
//+------------------------------------------------------------------+
//| GMACD.mq4 |
//| Copyright 2012, Guriev Invest |
//| http://www.gurievinvest.org.ua |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, Guriev Invest"
#property link "http://www.gurievinvest.org.ua"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_style2 STYLE_DOT
#property indicator_width3 3
#property indicator_width4 3
//=====Ïàðàìåòðû èíäèêàòîðà=====
extern int FastMA = 12;
extern int SlowMA = 26;
extern int SignalMA = 9;
//=====Áóôåðû èíäèêàòîðà=====
double MacdBufferRed[];
double MacdBufferGreen[];
double SignalBuffer[];
double LineBuffer[];
//+------------------------------------------------------------------+
//| Èíèöèàëèçàöèÿ |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_HISTOGRAM);
SetIndexDrawBegin(0,SlowMA);
SetIndexDrawBegin(1,SlowMA+SignalMA);
SetIndexDrawBegin(2,SlowMA+SignalMA);
SetIndexDrawBegin(3,SlowMA+SignalMA);
IndicatorDigits(Digits+1);
SetIndexBuffer(0,LineBuffer);
SetIndexBuffer(1,SignalBuffer);
SetIndexBuffer(2,MacdBufferRed);
SetIndexBuffer(3,MacdBufferGreen);
IndicatorShortName("MACD("+FastMA+","+SlowMA+","+SignalMA+")");
SetIndexLabel(0,"Line");
SetIndexLabel(1,"Signal");
SetIndexLabel(2,"MACD");
SetIndexLabel(3,"MACD");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
double volFirst = 0;
double volSecond = 0;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+1;
//=====Ïîäñ÷åò ïåðâîé ñðåäíåé
for(int i=0; i<limit; i++)
LineBuffer[i]=iMA(NULL,0,FastMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowMA,0,MODE_EMA,PRICE_CLOSE,i);
for(i=0; i<limit; i++)
{
MacdBufferRed[i] = 0.0;
MacdBufferGreen[i]= 0.0;
SignalBuffer[i] = iMAOnArray(LineBuffer,Bars,SignalMA,0,MODE_SMA,i);
volFirst = LineBuffer[i]-SignalBuffer[i];
volSecond = LineBuffer[i+1]-SignalBuffer[i];
if(volFirst>volSecond) MacdBufferRed[i]=volFirst;
else MacdBufferGreen[i]=volFirst;
}
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
---