Author: 2018 Rice
Indicators Used
Moving average indicator
1 Views
0 Downloads
0 Favorites
EMA Levels
ÿþ//+------------------------------------------------------------------+

//|                                                   EMA Levels.mq4 |

//|                                             Copyright 2018, Rice |

//|                                              http://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright   "2018 Rice"

#property link        "http://www.mql5.com"

#property description "3@><=0O 1;03>40@=>ABL Vitalii Ananev 70 B5@?5=85 8 ?><>IL!"

#property strict



//indicator settings

#property indicator_chart_window

input color color1=clrGreen; //H1 level

input color color2=clrBlue;  //H4 level

input color color3=clrRed;   //D1 level



//Custom indicator initialization function

void OnInit(void)

  {

//   return(0);

  }

//Deleting of MA lines of chart

void OnDeinit(const int reason)

  {

   ObjectDelete(0,"H1");

   ObjectDelete(0,"H4");

   ObjectDelete(0,"D1");

  }

//Drawing horizontal lines function

void HLine(string name,double price,color col)

  {

   if(ObjectFind(0,name)==-1)

     {

      ObjectCreate(0,name,OBJ_HLINE,0,0,price);

      ObjectSetInteger(0,name,OBJPROP_COLOR,col);

     }

   else

     {

      ObjectMove(0,name,0,0,price);

      ObjectSetInteger(0,name,OBJPROP_COLOR,col);

     }

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

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[])

  {

//Drawing lines on EMA 200 levels on H1, H4, D1 timeframes

   HLine("H1",iMA(NULL,PERIOD_H1,200,0,MODE_EMA,PRICE_CLOSE,0),color1);

   HLine("H4",iMA(NULL,PERIOD_H4,200,0,MODE_EMA,PRICE_CLOSE,0),color2);

   HLine("D1",iMA(NULL,PERIOD_D1,200,0,MODE_EMA,PRICE_CLOSE,0),color3);

   return(rates_total);

  }

//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---