Reputation: 7273
I have tried the following:
adx_output = iADX(_Symbol,TimePeriod,Candles_for_adx);
Print(ChartGetDouble(0,CHART_PRICE_MAX,2));
Print(ChartGetDouble(0,CHART_PRICE_MIN,2));
Print(ChartGetDouble(0,CHART_POINTS_PER_BAR,2));
But the above code gives me the mid value for the current or tick based time series. I want to access the range for the previous candles. But could not find anything that can be helpful.
Please let me know the suggestion for this issue.
Upvotes: 0
Views: 1024
Reputation: 1
Well,
using MetaTrader's GUI Graph's attributes { CHART_PRICE_MIN,
CHART_PRICE_MAX }
is possible, yet the Graph's layout is controlled by aPriceDOMAIN events ( QUOTE-s ) and some configurable options, yet not by the ADX Technical Indicator values per-se, so such retrieved numbers, received from GUI-state, have almost nothing to do with the actually sought for { min, MAX }
-ADX values.
a smart yet complicated approach would be to create a CustomIndicator or a class, doing this exact service.
a naive but functional approach would be to check and re-check the desired iADX()-{ MAIN, +DI, -DI }
values:
/* -----------------------------------------------//
int iADX( // MQL5-call-inteface:
string symbol, // symbol name
ENUM_TIMEFRAMES period, // period
int adx_period // averaging period
);
*/
#define currentChartID 0
#define currentChartMainWINDOW 0
int nBARsVISIBLE = ChartGetInteger( currentChartID, CHART_VISIBLE_BARS,
currentChartMainWINDOW
);
double iADX_VISIBLE[nBARsVISIBLE];
double iADX_VISIBLE_min,
iADX_VISIBLE_MAX;
int iADX_IndicatorHANDLE = iADX( _Symbol,
TimePeriod,
Candles_for_adx
);
/* -----------------------------------------------//
int CopyBuffer( // MQL5-call-inteface:
int indicator_handle, // indicator handle
int buffer_num, // indicator buffer number
int start_pos, // start position
int count, // amount to copy
double buffer[] // target array to copy
);
*/
int RetCODE = CopyBuffer( iADX_IndicatorHANDLE,
MODE_MAIN, // { 0: MODE_MAIN | 1: MODE_PLUSDI | 2: MODE_MINUSDI }
0,
nBARsVISIBLE,
iADX_VISIBLE
);
if ( RetCODE == -1 ) {...}
else {
iADX_VISIBLE_min = iADX_VISIBLE[ ArrayMinimum( iADX_VISIBLE ) ];
iADX_VISIBLE_MAX = iADX_VISIBLE[ ArrayMaximum( iADX_VISIBLE ) ];
...
}
Given the last comment:
Well, this might be the answer to my question but sir, I want the graph limits not the ADX min max. I can calculate it later, but currently want to have the graph limits. I am trying some experiments with the ADX graph. – Jaffer Wilson 1 hour ago
#define currentChartID 0 // adapt to fit your current setup
#define currentChartSubWinID 0 // adapt to fit your current setup
double priceMin = ChartGetDouble( currentChartID,
CHART_PRICE_MIN,
currentChartSubWinID
);
double priceMax = ChartGetDouble( currentChartID,
CHART_PRICE_MAX,
currentChartSubWinID
);
Print( "INF:: Chart(", currentChartID, ":", currentChartSubWinID, ").CHART_PRICE_MAX = ", priceMin );
Print( "INF:: Chart(", currentChartID, ":", currentChartSubWinID, ").CHART_PRICE_MAX = ", priceMax );
Upvotes: 1