Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
MMA_color
//+------------------------------------------------------------------+
//| MMA color.mq4 |
//| Copyright © 2006, Rustem Bigeev. |
//| http://www.parch.ru |
//+------------------------------------------------------------------+
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_color2 Blue
#property indicator_color3 Red
//---- indicator buffers
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
extern int PeriodMA=120;
extern int TypeMA=1;
extern string Mode1_ = "0 - MODE_SMA Ïðîñòîå ñêîëüçÿùåå ñðåäíåå ";
extern string Mode2_ = "1 - MODE_EMA Ýêñïîíåíöèàëüíîå ñêîëüçÿùåå ñðåäíåå ";
extern string Mode3_ = "2 - MODE_SMMA Ñãëàæåííîå ñêîëüçÿùåå ñðåäíåå ";
extern string Mode4_ = "3 - MODE_LWMA Ëèíåéíî-âçâåøåííîå ñêîëüçÿùåå ñðåäíåå ";
extern int PriceMA=4;
extern string Price1_ = "0 - PRICE_CLOSE Öåíà çàêðûòèÿ";
extern string Price2_ = "1 - PRICE_OPEN Öåíà îòêðûòèÿ";
extern string Price3_ = "2 - PRICE_HIGH Öåíà ìàêñèìóìà";
extern string Price4_ = "3 - PRICE_LOW Öåíà ìèíèìóìà" ;
extern string Price5_ = "4 - PRICE_MEDIAN Öåíà ñåðåäèíû" ;
extern string Price6_ = "5 - PRICE_TYPICAL Öåíà òèïè÷åñêàÿ";
extern string Price7_ = "6 - PRICE_WEIGHTED Öåíà âçâåøåííàÿ" ;
extern int Shift=6;
extern double Sensit=0.0001;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
IndicatorDigits(Digits+1);
SetIndexDrawBegin(0,34);
SetIndexDrawBegin(1,34);
SetIndexDrawBegin(2,34);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,ExtBuffer0);
SetIndexBuffer(1,ExtBuffer1);
SetIndexBuffer(2,ExtBuffer2);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("MMA color("+PeriodMA+", "+Shift+", "+TypeMA+", "+PriceMA+", "+Sensit+")");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
int start()
{
double prev,current;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
int limit = Bars - counted_bars;
if(counted_bars==0) limit--;
//---- macd
for(int i=0; i<limit; i++)
ExtBuffer0[i]=iMA(NULL,0,PeriodMA,1,TypeMA,PriceMA,i)-iMA(NULL,0,PeriodMA,1,TypeMA,PriceMA,i+Shift);
//---- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
current=ExtBuffer0[i];
prev=ExtBuffer0[i+1];
if(current>prev+Sensit) up=true;
if(current<prev-Sensit) up=false;
if(!up)
{
ExtBuffer2[i]=current;
ExtBuffer1[i]=0.0;
}
else
{
ExtBuffer1[i]=current;
ExtBuffer2[i]=0.0;
}
}
//---- done
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
---