Simple indicator in mql4 doesn't work

 

Hii,

Recently I am approaching the programming language MQL4, and I have builf this indicator whitch must return a green rrow upwards when the ADX is greater than 30 and the bullish candle and a red one downwards when the ADX is greater . 

But it doesn't work and I can't understand why . Could you tell me whereI went wrong ?


//+------------------------------------------------------------------+
//|                                                  DIAMOND_APP.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 200
#property indicator_buffers 2
#property indicator_plots   2
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Label2
#property indicator_label2  "Label2"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrLawnGreen
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- indicator buffers
double         Buffer1[];
double         Buffer2[];


//--- input parameter
input int InpADXPeriod= 14 ; // ATR Period
input int GrandeFreccia = 6 ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Buffer1);
   SetIndexStyle ( 0, DRAW_ARROW , GrandeFreccia , clrGreen );
   SetIndexArrow ( 0, 233) ;
   SetIndexBuffer(1,Buffer2);
   SetIndexStyle ( 1 , DRAW_ARROW , GrandeFreccia , clrRed );
   SetIndexBuffer ( 1, 234) ;
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger(0,PLOT_ARROW,233);
   PlotIndexSetInteger(1,PLOT_ARROW , 234);
   
   //--------------
  IndicatorSetInteger ( INDICATOR_DIGITS , 0);
     SetIndexLabel ( 0, NULL);
     SetIndexLabel ( 1 , NULL) ;
     SetLevelValue ( 0 , 100 ); 
//---
   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[])
  {
//---
   for ( int i= Bars - 1 ; i>=0; i--) { 
       if ( iADX ( Symbol () , PERIOD_CURRENT , InpADXPeriod , PRICE_CLOSE, MODE_MAIN  , 0 ) > 30 {
           open [i] < close[i])
           {
           Buffer1 [i] = 100 ;
           }
           {
            else 
           Buffer2 [i] = 100 ; 
           } 
          }
         }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
  1. Once, not three times
    #property indicator_label1  "Label1"#property indicator_color1  clrRed#property indicator_label2  "Label2"#property indicator_color2  clrLawnGreen
       SetIndexStyle ( 0, DRAW_ARROW , GrandeFreccia , clrGreen );
       SetIndexArrow ( 0, 233) ;
       ⋮
       SetIndexStyle ( 1 , DRAW_ARROW , GrandeFreccia , clrRed );
       SetIndexBuffer ( 1, 234) ;
       PlotIndexSetInteger(0,PLOT_ARROW,233);
       PlotIndexSetInteger(1,PLOT_ARROW , 234);
         SetIndexLabel ( 0, NULL);
         SetIndexLabel ( 1 , NULL) ;
  2. MT4 does not have a PlotIndexSetInteger.

  3.        if ( iADX ( Symbol () , PERIOD_CURRENT , InpADXPeriod , PRICE_CLOSE, MODE_MAIN  , 0 ) > 30 {
               open [i] < close[i])
    Do not post code that will not even compile.
  4. Why are you looking at ADX[0] only?