//+------------------------------------------------------------------+
//| SSL.mq5 |
//| Copyright 2022, AM2 |
//| https://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, AM2"
#property link "https://www.forexsystems.biz"
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots 1
#property indicator_type1 DRAW_COLOR_ARROW
#property indicator_color1 clrBlue,clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 2
input int MAPer=33;
input ENUM_TIMEFRAMES TF=0;
int h=0;
double ma[],ind[],clr[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
h=iMA(NULL,TF,MAPer,0,0,0);
SetIndexBuffer(0,ind,INDICATOR_DATA);
SetIndexBuffer(1,clr,INDICATOR_COLOR_INDEX);
SetIndexBuffer(2,ma,INDICATOR_CALCULATIONS);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration 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[])
{
//---
CopyBuffer(h,0,0,rates_total,ma);
for(int i=0; i<rates_total; i++)
{
if(close[i]>ma[i])
{
clr[i]=0;
ind[i]=1;
}
if(close[i]<ma[i])
{
clr[i]=1;
ind[i]=1;
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2