-
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
How to call indicators in MQL5 - MQL5 Articles 12 March 2010 -
if ( lastBarTime2 < iTime( _Symbol, _Period, 0 ) ) {
Use not equal. There was a post around 2002, where a server clock was mis-set and then corrected — stopped the EA for days! - fx nijuceri: Could you please help me with the code.
Help you with what? You haven't stated a problem, you stated a want.
-
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
How to call indicators in MQL5 - MQL5 Articles 12 March 2010 - Use not equal. There was a post around 2002, where a server clock was mis-set and then corrected — stopped the EA for days!
-
Help you with what? You haven't stated a problem, you stated a want.
I am trying to get the ADX value using the below code. But it is giving me error code 4806
//+------------------------------------------------------------------+ //| CBP-W.mq5 | //| NijuCeri | //| | //+------------------------------------------------------------------+ #property copyright "NijuCeri" #property link "" #property version "1.00" #property indicator_chart_window enum Creation { Call_iADX, // use iADX Call_IndicatorCreate // use IndicatorCreate }; input int adx_period=14; // period of calculation input ENUM_TIMEFRAMES period=PERIOD_W1; // timeframe //--- indicator buffers double ADXBuffer[]; datetime lastBarTime2; //--- variable for storing the handle of the iADX indicator int WADX14; //--- variable for storing //string name=symbol; //--- name of the indicator on a chart string short_name; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ADXBuffer,INDICATOR_DATA); ArraySetAsSeries(ADXBuffer,true); //--- 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[]) { if(IsNewBar()) { //+------------------------------------------------------------------+ //| Check Symbols in Market Watch | //+------------------------------------------------------------------+ int HowManySymbols=SymbolsTotal(true); string ListSymbol; for(int n=0;n<HowManySymbols;n++) { ListSymbol =SymbolName(n,true); //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ //Create Handle WADX14=iADX(ListSymbol,period,adx_period); if(WADX14==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iADX indicator for the symbol %s/%s, error code %d", ListSymbol, EnumToString(period), GetLastError()); continue; } int amount = 10; //Number of data-points to collect if(CopyBuffer(WADX14,0,0,amount,ADXBuffer)<0) { //--- if the copying fails, tell the error code PrintFormat("Failed to copy data from the iADX indicator, error code %d",GetLastError()); //--- quit with zero result - it means that the indicator is considered as not calculated continue; } double WADX14Main =NormalizeDouble(ADXBuffer[0],2); //+------------------------------------------------------------------+ //| Print date in experts tab | //+------------------------------------------------------------------+ Print("Symbol: " + ListSymbol + " W2ADX14Main: " , WADX14Main ); } } return(rates_total);; } //+------------------------------------------------------------------+ //| New Bar Check | //+------------------------------------------------------------------+ bool IsNewBar() { bool newBar = false; if ( lastBarTime2 < iTime( _Symbol, _Period, 0 ) ) { lastBarTime2 = iTime( _Symbol, _Period, 0 ) + 1; newBar = true; } return(newBar); }//IsNewBar() //+------------------------------------------------------------------+

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to get the weekly ADX14 value for all the symbols in the market watch. Could you please help me with the code.