Disliked{quote} Thank you, i am going through your candle body size indicator to see if i can teach my self something new, there are problems; for me iATR has only 3 parameters it would be very helpful if i knew which platform you were using and which version, gave a screen short of what i get when i go through your program. {image}Ignored
I didn't realize this was MT5.
They have changed how it handle iATR.
Not familiar yet with MT5 but in simple term, you have to copy data to Buffer first.
iATR - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Basically, you will get handle of iATR, and using handle and function CopyBuffer(), you copy to Buffer that will hold iATR values you would expect from MT4 call.
Then, you access Buffer to access ATR value... a lot of steps.
if you just want to make it work, you could just include like "mql4compat.mqh" and MT5 iATR call should work like MT4 iATR call.
Based on mql4compat.mqh, iATR call look like .
double iATRMQL4(string symbol, int tf, int period, int shift)
{
ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
int handle=iATR(symbol,timeframe,period);
if(handle<0)
{
Print("The iATR object is not created: Error",GetLastError());
return(-1);
}
else
return(CopyBufferMQL4(handle,0,shift));
}
//Technical Indicators
double CopyBufferMQL4(int handle,int index,int shift)
{
double buf[];
switch(index)
{
case 0: if(CopyBuffer(handle,0,shift,1,buf)>0)
return(buf[0]); break;
case 1: if(CopyBuffer(handle,1,shift,1,buf)>0)
return(buf[0]); break;
case 2: if(CopyBuffer(handle,2,shift,1,buf)>0)
return(buf[0]); break;
case 3: if(CopyBuffer(handle,3,shift,1,buf)>0)
return(buf[0]); break;
case 4: if(CopyBuffer(handle,4,shift,1,buf)>0)
return(buf[0]); break;
default: break;
}
return(EMPTY_VALUE);
}
I don't use MT5 much yet - but did a couple of indicators.
this was a MT5 function that I converted from MT4 to MT5 which would return ADR5.
If you prefer to handle iATR in MT5 style, you can refer to this.
//+------------------------------------------------------------------+
double GetADR5Days()
{
//double adr= iATR(NULL, ATRTimeFrame, ATRPeriod, 1);
// "ADR " + DoubleToString(MathRound((adr/_Point)),0) +
// " Today " + DoubleToString(MathRound(((today_high-today_low)/_Point)),0) ;
//Should I show (today range)/(ADR) ?
string symbolname = Symbol();
MqlRates rt;
rt.high = iHigh(symbolname,PERIOD_D1,0);
rt.low = iLow(symbolname,PERIOD_D1,0);
double adr=0;
double lpoint=getPoint(symbolname);
double modifier=getModifier(symbolname);
int atr_handle;
if(lpoint>0){
double ATR[];
ArrayResize(ATR,50);
atr_handle = iATR(_Symbol,_Period,15);
ArraySetAsSeries(ATR,true);
CopyBuffer(atr_handle,0,0,40,ATR);
adr= ATR[0];
}
if(adr==0) adr=1;
double adrdaily = MathRound(((rt.high-rt.low)/lpoint*.1));
double adr5days = MathRound(adr/lpoint)*.1;
//return StringConcatenate(DoubleToString(adrdaily,0), "/",DoubleToString(adr5days,0));
return adr5days;
}
Again, sorry about confusion.
1