Hello I am new to mql5 and I realize that I am having a hard time converting my indicators written in mql4 to mql5 because I lack a point of reference.
My indicators are similiar to the one Rosh wrote here: https://www.mql5.com/en/code/7072
Can someone show me what this sample code would look like in mql5.
What happens to the 'shift': i?
does it go away and is it handled by some other variable, and if so how?
double adxMain[];
double adxPlus[];
double adxMinus[];
hIADX = iADX( symbol, timeframe, adx_period );
ArraySetAsSeries( adxMain, true );
ArraySetAsSeries( adxPlus, true );
ArraySetAsSeries( adxMinus, true );
CopyBuffer( hIADX, 0, shift, 1, adxMain );
CopyBuffer( hIADX, 1, shift, 1, adxPlus );
CopyBuffer( hIADX, 2, shift, 1, adxMinus );
Print( "iAdx values at ", shift, " are ", adxMain[0], ",", adxPlus[0], ",", AdxMinus[0] );
double adxMain[];
double adxPlus[];
double adxMinus[];
hIADX = iADX( symbol, timeframe, adx_period );
ArraySetAsSeries( adxMain, true );
ArraySetAsSeries( adxPlus, true );
ArraySetAsSeries( adxMinus, true );
CopyBuffer( hIADX, 0, shift, 1, adxMain );
CopyBuffer( hIADX, 1, shift, 1, adxPlus );
CopyBuffer( hIADX, 2, shift, 1, adxMinus );
Print( "iAdx values at ", shift, " are ", adxMain[0], ",", adxPlus[0], ",", AdxMinus[0] );
for(i = limit; i >= 0; i--) { DIPlus = iADX(NULL, 0, per, PriceType, MODE_PLUSDI, i); DIMinus = iADX(NULL, 0, per, PriceType, MODE_MINUSDI, i); ADX = iADX(NULL, 0, per, PriceType, MODE_MAIN, i); DIPlus1 = iADX(NULL, 0, per, PriceType, MODE_PLUSDI, i + 1); DIMinus1 = iADX(NULL, 0, per, PriceType, MODE_MINUSDI, i + 1); ADX1 = iADX(NULL, 0, per, PriceType, MODE_MAIN, i + 1); //---- DIPlusLead[i] = 2*DIPlus + (alpha1 - 2) * DIPlus1 + (1 - alpha1) * DIPlusLead[i+1];
Thank you for the reply fireflies, but there is one part that still eludes me. How do you avoid getting an array out of bounds error if I were to increment the DIPlusLead by one...DIPlusLead[i+1]?
Thank you for the reply fireflies, but there is one part that still eludes me. How do you avoid getting an array out of bounds error if I were to increment the DIPlusLead by one...DIPlusLead[i+1]?
Declare the array size as big as needed
// define MAXDI at least as big as i+1
double DIPlusLead[MAXDI];

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello I am new to mql5 and I realize that I am having a hard time converting my indicators written in mql4 to mql5 because I lack a point of reference.
My indicators are similiar to the one Rosh wrote here: https://www.mql5.com/en/code/7072
Can someone show me what this sample code would look like in mql5.
What happens to the 'shift': i?
does it go away and is it handled by some other variable, and if so how?