Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Rainbow
//+------------------------------------------------------------------+
//| Rainbow |
//| Copyright 2016, Il Anokhin |
//| http://www.mql5.com/en/users/ilanokhin |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Il Anokhin"
#property link "http://www.mql5.com/en/users/ilanokhin"
#property description ""
#property strict
//-------------------------------------------------------------------------
// Indicator settings
//-------------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Gold
#property indicator_color4 LimeGreen
#property indicator_color5 DodgerBlue
#property indicator_color6 Blue
#property indicator_color7 DarkViolet
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_width6 2
#property indicator_width7 2
//-------------------------------------------------------------------------
// Inputs
//-------------------------------------------------------------------------
input bool MA1 = true; //Show Moving Average 1
input int MAP1 = 10; //Moving Average 1 Period
input ENUM_MA_METHOD MAM1 = MODE_EMA; //Moving Average 1 Method
input ENUM_APPLIED_PRICE PR1 = PRICE_CLOSE; //Moving Average 1 Applied Price
input bool MA2 = true; //Show Moving Average 2
input int MAP2 = 20; //Moving Average 2 Period
input ENUM_MA_METHOD MAM2 = MODE_EMA; //Moving Average 2 Method
input ENUM_APPLIED_PRICE PR2 = PRICE_CLOSE; //Moving Average 2 Applied Price
input bool MA3 = true; //Show Moving Average 3
input int MAP3 = 30; //Moving Average 3 Period
input ENUM_MA_METHOD MAM3 = MODE_EMA; //Moving Average 3 Method
input ENUM_APPLIED_PRICE PR3 = PRICE_CLOSE; //Moving Average 3 Applied Price
input bool MA4 = true; //Show Moving Average 4
input int MAP4 = 40; //Moving Average 4 Period
input ENUM_MA_METHOD MAM4 = MODE_EMA; //Moving Average 4 Method
input ENUM_APPLIED_PRICE PR4 = PRICE_CLOSE; //Moving Average 4 Applied Price
input bool MA5 = true; //Show Moving Average 5
input int MAP5 = 50; //Moving Average 5 Period
input ENUM_MA_METHOD MAM5 = MODE_EMA; //Moving Average 5 Method
input ENUM_APPLIED_PRICE PR5 = PRICE_CLOSE; //Moving Average 5 Applied Price
input bool MA6 = true; //Show Moving Average 6
input int MAP6 = 60; //Moving Average 6 Period
input ENUM_MA_METHOD MAM6 = MODE_EMA; //Moving Average 6 Method
input ENUM_APPLIED_PRICE PR6 = PRICE_CLOSE; //Moving Average 6 Applied Price
input bool MA7 = true; //Show Moving Average 7
input int MAP7 = 70; //Moving Average 7 Period
input ENUM_MA_METHOD MAM7 = MODE_EMA; //Moving Average 7 Method
input ENUM_APPLIED_PRICE PR7 = PRICE_CLOSE; //Moving Average 7 Applied Price
//-------------------------------------------------------------------------
// Variables
//-------------------------------------------------------------------------
double m1[],m2[],m3[],m4[],m5[],m6[],m7[];
//-------------------------------------------------------------------------
// 1. Initialization
//-------------------------------------------------------------------------
int OnInit(void)
{
IndicatorBuffers(7);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexStyle(4,DRAW_LINE);
SetIndexStyle(5,DRAW_LINE);
SetIndexStyle(6,DRAW_LINE);
SetIndexBuffer(0,m1);
SetIndexBuffer(1,m2);
SetIndexBuffer(2,m3);
SetIndexBuffer(3,m4);
SetIndexBuffer(4,m5);
SetIndexBuffer(5,m6);
SetIndexBuffer(6,m7);
Comment("Copyright © 2016, Il Anokhin");
return(INIT_SUCCEEDED);
}
//-------------------------------------------------------------------------
// 2. Deinitialization
//-------------------------------------------------------------------------
int deinit() {return(0);}
//-------------------------------------------------------------------------
// 3. Main function
//-------------------------------------------------------------------------
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int i,lim,cb;
if(Bars<10) return(0);
cb=IndicatorCounted();
lim=Bars-cb;
if(cb==0) lim=lim-11;
if(cb>0) lim++;
//--- 3.1. Main loop ------------------------------------------------------
for(i=0;i<lim;i++)
{
if(MA1==true) m1[i]=iMA(NULL,0,MAP1,0,MAM1,PR1,i);
if(MA2==true) m2[i]=iMA(NULL,0,MAP2,0,MAM2,PR2,i);
if(MA3==true) m3[i]=iMA(NULL,0,MAP3,0,MAM3,PR3,i);
if(MA4==true) m4[i]=iMA(NULL,0,MAP4,0,MAM4,PR4,i);
if(MA5==true) m5[i]=iMA(NULL,0,MAP5,0,MAM5,PR5,i);
if(MA6==true) m6[i]=iMA(NULL,0,MAP6,0,MAM6,PR6,i);
if(MA7==true) m7[i]=iMA(NULL,0,MAP7,0,MAM7,PR7,i);
}
//--- 3.2. End of main function -------------------------------------------
return(rates_total);
}
//-------------------------------------------------------------------------
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
---