Zbigniew Tomczak / Профиль
- Информация
2 года
опыт работы
|
0
продуктов
|
0
демо-версий
|
0
работ
|
2
сигналов
|
0
подписчиков
|
Друзья
6
Заявки
Исходящие
![Zbigniew Tomczak](https://c.mql5.com/avatar/avatar_na2.png)
Zbigniew Tomczak
//+------------------------------------------------------------------+
//| ADX and DI |
//| Inspired by indicator published by BeikabuOyaji on Trading View |
//| |
//+------------------------------------------------------------------+
#include
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_plots 3
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrMediumBlue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrYellowGreen
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrWheat
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
#property indicator_label1 "ADXv4"
#property indicator_label2 "+DI"
#property indicator_label3 "-DI"
input int InpPeriodADX=14;
double SmoothedTrueRange[];
double SmoothedDirectionalMovementPlus[];
double SmoothedDirectionalMovementMinus[];
double DIPlus[];
double DIMinus[];
double DX[];
double ADX[];
int len;
void OnInit()
{
if(InpPeriodADX>=100 || InpPeriodADX<=0)
{
len=14;
PrintFormat("Incorrect value for input variable Period_ADX=%d. Indicator will use value=%d for calculations.",InpPeriodADX,len);
}
else
{
len=InpPeriodADX;
}
SetIndexBuffer(0,ADX);
SetIndexBuffer(1,DIPlus);
SetIndexBuffer(2,DIMinus);
SetIndexBuffer(3,DX,INDICATOR_CALCULATIONS);
SetIndexBuffer(4,SmoothedDirectionalMovementPlus,INDICATOR_CALCULATIONS);
SetIndexBuffer(5,SmoothedDirectionalMovementMinus,INDICATOR_CALCULATIONS);
SetIndexBuffer(6,SmoothedTrueRange,INDICATOR_CALCULATIONS);
IndicatorSetInteger(INDICATOR_DIGITS,2);
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,len< PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,len);
PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,len);
string short_name="ADXv4("+string(len)+")";
IndicatorSetString(INDICATOR_SHORTNAME,short_name);
PlotIndexSetString(0,PLOT_LABEL,short_name);
}
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[])
{
if(rates_total return(0);
int start = 1;
if(prev_calculated>1)
start=prev_calculated-1;
for(int i = start; i < rates_total && !IsStopped(); i++)
{
double TrueRange = MathMax(MathMax(MathAbs(high[i]-low[i]),MathAbs(high[i]-close[i-1])),MathAbs(low[i]-close[i-1]));
double DirectionalMovementPlus = high[i]-high[i-1] > low[i-1]-low[i] ? MathMax(high[i]-high[i-1], 0): 0;
double DirectionalMovementMinus = low[i-1]-low[i] > high[i]-high[i-1] ? MathMax(low[i-1]-low[i], 0): 0;
double tr=MathMax(MathMax(MathAbs(high[i]-low[i]),MathAbs(high[i]-close[i-1])),MathAbs(low[i]-close[i-1]));
SmoothedTrueRange[i] = 0.0;
SmoothedTrueRange[i] = SmoothedTrueRange[i-1] - SmoothedTrueRange[i-1]/len + TrueRange;
SmoothedDirectionalMovementPlus[i] = 0.0;
SmoothedDirectionalMovementPlus[i] = SmoothedDirectionalMovementPlus[i-1] - SmoothedDirectionalMovementPlus[i-1]/len + DirectionalMovementPlus;
SmoothedDirectionalMovementMinus[i] = 0.0;
SmoothedDirectionalMovementMinus[i] = SmoothedDirectionalMovementMinus[i-1] - SmoothedDirectionalMovementMinus[i-1]/len + DirectionalMovementMinus;
DIPlus[i] = SmoothedDirectionalMovementPlus[i] / SmoothedTrueRange[i] * 100.0;
DIMinus[i] = SmoothedDirectionalMovementMinus[i] / SmoothedTrueRange[i] * 100.0;
DX[i] = MathAbs(DIPlus[i]-DIMinus[i]) / (DIPlus[i]+DIMinus[i])*100.0;
ADX[i] = SimpleMA(i, len, DX);
}
return(rates_total);
}
//| ADX and DI |
//| Inspired by indicator published by BeikabuOyaji on Trading View |
//| |
//+------------------------------------------------------------------+
#include
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_plots 3
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrMediumBlue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrYellowGreen
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrWheat
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
#property indicator_label1 "ADXv4"
#property indicator_label2 "+DI"
#property indicator_label3 "-DI"
input int InpPeriodADX=14;
double SmoothedTrueRange[];
double SmoothedDirectionalMovementPlus[];
double SmoothedDirectionalMovementMinus[];
double DIPlus[];
double DIMinus[];
double DX[];
double ADX[];
int len;
void OnInit()
{
if(InpPeriodADX>=100 || InpPeriodADX<=0)
{
len=14;
PrintFormat("Incorrect value for input variable Period_ADX=%d. Indicator will use value=%d for calculations.",InpPeriodADX,len);
}
else
{
len=InpPeriodADX;
}
SetIndexBuffer(0,ADX);
SetIndexBuffer(1,DIPlus);
SetIndexBuffer(2,DIMinus);
SetIndexBuffer(3,DX,INDICATOR_CALCULATIONS);
SetIndexBuffer(4,SmoothedDirectionalMovementPlus,INDICATOR_CALCULATIONS);
SetIndexBuffer(5,SmoothedDirectionalMovementMinus,INDICATOR_CALCULATIONS);
SetIndexBuffer(6,SmoothedTrueRange,INDICATOR_CALCULATIONS);
IndicatorSetInteger(INDICATOR_DIGITS,2);
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,len< PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,len);
PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,len);
string short_name="ADXv4("+string(len)+")";
IndicatorSetString(INDICATOR_SHORTNAME,short_name);
PlotIndexSetString(0,PLOT_LABEL,short_name);
}
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[])
{
if(rates_total return(0);
int start = 1;
if(prev_calculated>1)
start=prev_calculated-1;
for(int i = start; i < rates_total && !IsStopped(); i++)
{
double TrueRange = MathMax(MathMax(MathAbs(high[i]-low[i]),MathAbs(high[i]-close[i-1])),MathAbs(low[i]-close[i-1]));
double DirectionalMovementPlus = high[i]-high[i-1] > low[i-1]-low[i] ? MathMax(high[i]-high[i-1], 0): 0;
double DirectionalMovementMinus = low[i-1]-low[i] > high[i]-high[i-1] ? MathMax(low[i-1]-low[i], 0): 0;
double tr=MathMax(MathMax(MathAbs(high[i]-low[i]),MathAbs(high[i]-close[i-1])),MathAbs(low[i]-close[i-1]));
SmoothedTrueRange[i] = 0.0;
SmoothedTrueRange[i] = SmoothedTrueRange[i-1] - SmoothedTrueRange[i-1]/len + TrueRange;
SmoothedDirectionalMovementPlus[i] = 0.0;
SmoothedDirectionalMovementPlus[i] = SmoothedDirectionalMovementPlus[i-1] - SmoothedDirectionalMovementPlus[i-1]/len + DirectionalMovementPlus;
SmoothedDirectionalMovementMinus[i] = 0.0;
SmoothedDirectionalMovementMinus[i] = SmoothedDirectionalMovementMinus[i-1] - SmoothedDirectionalMovementMinus[i-1]/len + DirectionalMovementMinus;
DIPlus[i] = SmoothedDirectionalMovementPlus[i] / SmoothedTrueRange[i] * 100.0;
DIMinus[i] = SmoothedDirectionalMovementMinus[i] / SmoothedTrueRange[i] * 100.0;
DX[i] = MathAbs(DIPlus[i]-DIMinus[i]) / (DIPlus[i]+DIMinus[i])*100.0;
ADX[i] = SimpleMA(i, len, DX);
}
return(rates_total);
}
: