Skip to content

Instantly share code, notes, and snippets.

@georgekarapi
Last active June 26, 2020 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgekarapi/46b67e95ae7790180730d4c4d206c7f1 to your computer and use it in GitHub Desktop.
Save georgekarapi/46b67e95ae7790180730d4c4d206c7f1 to your computer and use it in GitHub Desktop.
//+------------------------------------------------------------------+
//| 4EMA.mq4 |
//| Giorgos Karapiperidis |
//| https://georgekarapi.com |
//+------------------------------------------------------------------+
#property copyright "Giorgos Karapiperidis"
#property link "https://georgekarapi.com"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots 4
//--- plot Line1
#property indicator_label1 "Line1"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrMediumBlue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot Line2
#property indicator_label2 "Line2"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrLime
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//--- plot Line3
#property indicator_label3 "Line3"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrYellow
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
//--- plot Line4
#property indicator_label4 "Line4"
#property indicator_type4 DRAW_LINE
#property indicator_color4 clrRed
#property indicator_style4 STYLE_SOLID
#property indicator_width4 1
//--- input parameters
input int Line1=8;
input int Line2=13;
input int Line3=21;
input int Line4=55;
//--- indicator buffers
double Line1Buffer[];
double Line2Buffer[];
double Line3Buffer[];
double Line4Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,Line1Buffer);
SetIndexBuffer(1,Line2Buffer);
SetIndexBuffer(2,Line3Buffer);
SetIndexBuffer(3,Line4Buffer);
IndicatorBuffers(4);
return(0);
}
double ema(int value, int i) {
return iMA(Symbol(), PERIOD_CURRENT, value,0,MODE_EMA,PRICE_CLOSE,i);
}
int start()
{
int limit = Bars-IndicatorCounted();
for(int i=limit-1; i>=0; i--)
{
Line1Buffer[i] = ema(Line1, i);
Line2Buffer[i] = ema(Line2, i );
Line3Buffer[i] = ema(Line3, i);
Line4Buffer[i] = ema(Line4, i);
}
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment