# How to determine previous close price ??

139
2010.05.18 22:58

Hi,

in Mql4, i coding the previous close price (shift) as below

double pr0=iClose("EURUSD",0,0);

double pr1=iClose("EURUSD",0,1);

double pr2=iClose("EURUSD",0,2);

how to convert this to MLQ5.....help me

tq

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
• www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants - Documentation on MQL5
648
2010.05.18 23:31
haidzatul posted  :

Hi,

in Mql4, i coding the previous close price (shift) as below

double pr0=iClose("EURUSD",0,0);

double pr1=iClose("EURUSD",0,1);

double pr2=iClose("EURUSD",0,2);

how to convert this to MLQ5.....help me

tq

Try this. This sets an array "myClose" of 10 previous bar close values.

```double CurrentClose, PreviousClose1, PreviousClose2;
double myClose;
CopyClose(_Symbol, _Period, 0, 10, myClose);
ArraySetAsSeries(myClose,true);
CurrentClose = myClose[0]; // current bar close.
PreviousClose1 = myClose[1]; // equals bar close 1 bar back from current bar.
PreviousClose2 = myClose[2]; // equals bar close 2 bars back from current bar.
```

53
2010.05.19 00:04
I like using MqlRates variable to get high,close,open,time......
```   MqlRates rates[];
ArraySetAsSeries(rates,true);
int copied=CopyRates(Symbol(),Period(),0,Bars(Symbol(),Period()),rates); // Copied all datas
double pr0_close= rates[0].close;
double pr1_close= rates[1].close;        // rates[1].high,rates[1].open for high
datetime t1 = rates[1].time;

//------------------------

```