Zbigniew Tomczak
Zbigniew Tomczak
  • Informações
2 anos
experiência
0
produtos
0
versão demo
0
trabalhos
3
sinais
0
assinantes
Zbigniew Tomczak Publicado sinal MetaTrader 5
Long Term Investments
Preço: 30 USD, Crescimento: -57.00%
Zbigniew Tomczak Publicado sinal MetaTrader 5
SG
Preço: 30 USD, Crescimento: -100.00%
Zbigniew Tomczak Publicado sinal MetaTrader 5
Giva
Preço: 30 USD, Crescimento: -98.30%
Zbigniew Tomczak
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);
}
Zbigniew Tomczak
Registrado no site MQL5.community