Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Delta MA
//+------------------------------------------------------------------+
//| Delta MA.mq4 |
//| Me |
//| |
//+------------------------------------------------------------------+
#property copyright "Me"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Yellow
#property indicator_color4 Violet
//---- input parameters
extern int period=18;
//---- buffers
double UPPER[];
double LOWER[];
double MID[];
double MA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,UPPER);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,LOWER);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,MID);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,MA);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int i,limit;
if (counted_bars<1)
limit = Bars - period;
else
limit = Bars - counted_bars + 1;
for (i=limit;i>=0;i--)
{
MA[i] = iMA(0,0,period,0,MODE_SMA,PRICE_CLOSE,i);
// if MA is sloping up, we'll need a trigger below
if (MA[i]>=MA[i+1])
{
LOWER[i] = Close[i+period];
}
if (MA[i]<=MA[i+1])
{
UPPER[i] = Close[i+period];
}
// put some yellow paint to fill the gaps, and make a smooth line
if ((MA[i]>=MA[i+1] && MA[i+1]<=MA[i+2]) ||
(MA[i]<=MA[i+1] && MA[i+1]>=MA[i+2]))
{
MID[i]=Close[i+period];
MID[i+1] = Close[i+1+period];
}
}
//----
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
---