vittoriacacace1111:
Hi ,
I have created this simple indicator in mql4 which must return a green upward arrow when the ADX is greater than 30 and the bullish candle , and a red downward when the ADX is greater than 30 and the bearish candle ;
I am recently approaching this language and I cannot understand and I cannot understand why it does not work .
Could you help me ?
//if ( iADX ( Symbol ( ) , PERIOD_CURRENT , InpADXPeriod , PRICE_CLOSE , MODE_MAIN , 0 ) in the snippet you replace 0 with i it will work.
Legacy Code
if ( iADX ( Symbol() , PERIOD_CURRENT , InpADXPeriod , PRICE_CLOSE, MODE_MAIN , 0 )
New Code
if ( iADX ( Symbol() , PERIOD_CURRENT , InpADXPeriod , PRICE_CLOSE, MODE_MAIN , i )
//---------------------------------------------------------- //------------------------------------------------------------------+ //| DiamondApp.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 Freccia #property indicator_label1 "freccia 1 " #property indicator_type1 DRAW_ARROW #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot Freccia #property indicator_label2 "Freccia 2" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrChartreuse #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); SetIndexBuffer(1, Buffer2); //--- setting a code from the Wingdings charset as the property of PLOT_ARROW PlotIndexSetInteger(0,PLOT_ARROW,159); PlotIndexSetInteger(1,PLOT_ARROW,159); //--- SetIndexStyle(0,DRAW_LINE); SetIndexShift(0,0); SetIndexLabel(0,"Freccia Verde "); SetIndexStyle(1,DRAW_LINE); SetIndexShift(1,0); SetIndexLabel(1,"Freccia Rossa "); //-------------- IndicatorSetInteger ( INDICATOR_DIGITS , 0); IndicatorSetDouble ( INDICATOR_MAXIMUM , 200); IndicatorSetDouble ( INDICATOR_MINIMUM , 0); SetIndexLabel ( 0, NULL); SetIndexLabel ( 1 , NULL) ; SetLevelValue ( 0 , 100 ); SetIndexStyle ( STYLE_DASH , 0) ; //--- SetIndexDrawBegin(0,InpADXPeriod+0); SetIndexDrawBegin(1,InpADXPeriod+0); //--- 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 , i ) > 30 || open [i] < close [i] ){ Buffer1 [i] = 100 ; } if (iADX (Symbol() , PERIOD_CURRENT , InpADXPeriod , PRICE_CLOSE , MODE_MAIN , i) > 30 || open [i] > close [i] ) { Buffer2 [i] = 100 ; } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi ,
I have created this simple indicator in mql4 which must return a green upward arrow when the ADX is greater than 30 and the bullish candle , and a red downward when the ADX is greater than 30 and the bearish candle ;
I am recently approaching this language and I cannot understand and I cannot understand why it does not work .
Could you help me ?