//+------------------------------------------------------------------+
//| OpenDay.mq4 |
//| Copyright 2019, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int days=7;
input color up=Red;
input color dn=Blue;
string pre="OpenDay";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
Comment("");
DelObject(pre);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DelObject(string name)
{
for(int i=ObjectsTotal()-1; i>=0; i--)
{
string s=ObjectName(0,i);
if(StringFind(s,name)>=0)
ObjectDelete(0,ObjectName(0,i));
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutRect(string name,datetime t1,double p1,datetime t2,double p2,color clr)
{
ObjectDelete(0,name);
//--- создадим прямоугольник по заданным координатам
ObjectCreate(0,name,OBJ_RECTANGLE,0,t1,p1,t2,p2);
//--- установим цвет прямоугольника
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//--- установим стиль линий прямоугольника
ObjectSetInteger(0,name,OBJPROP_STYLE,0);
//--- установим толщину линий прямоугольника
ObjectSetInteger(0,name,OBJPROP_WIDTH,3);
//--- включим (true) или отключим (false) режим заливки прямоугольника
ObjectSetInteger(0,name,OBJPROP_FILL,false);
//--- отобразим на переднем (false) или заднем (true) плане
ObjectSetInteger(0,name,OBJPROP_BACK,false);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
for(int i=1; i<=days; i++)
{
double op=iOpen(NULL,PERIOD_D1,i);
double op2=iOpen(NULL,PERIOD_D1,i+1);
double cl=iClose(NULL,PERIOD_D1,i);
if(cl>op)
PutRect(pre+(string)i,iTime(NULL,PERIOD_D1,i),op,iTime(NULL,PERIOD_D1,i-1),cl,Blue);
if(cl<op)
PutRect(pre+(string)i,iTime(NULL,PERIOD_D1,i),op,iTime(NULL,PERIOD_D1,i-1),cl,Red);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| LowPass.mq4 |
//| Copyright 2021, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
extern string IndName = "low-pass-bands-sync-filters-mtf";
extern string TimeFrame = "current time frame";
extern int gFilterPeriod = 30;
extern int FilterPrice = PRICE_CLOSE;
extern int FilterType = 0;
extern double FrequencyCutoff = 0.01;
extern bool Causal = false;
extern int rangePeriod = 5;
extern int MaMethod = 8;
double up[];
double dn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_ARROW,0,1,Blue);
SetIndexArrow(0,108);
SetIndexBuffer(0,up);
SetIndexStyle(1,DRAW_ARROW,0,1,Red);
SetIndexArrow(1,108);
SetIndexBuffer(1,dn);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Aq()
{
double pr=0;
for(int i=0; i<111; i++)
{
double aq = iCustom(NULL,0,IndName,3,i);
if(aq<1111)
{
pr=aq;
break;
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double Mag()
{
double pr=0;
for(int i=0; i<111; i++)
{
double mg = iCustom(NULL,0,IndName,4,i);
if(mg<1111)
{
pr=mg;
break;
}
}
return(pr);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
for(int i=0; i<111; i++)
{
up[i]=Aq();
dn[i]=Mag();
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
AM2