I would like to know how I can use the Ref() function of metastock in MQL4. Ref() in metastock is used to take the previous values of the given data array. for example:
Ref(C,-1)
gives the value of previous day's close.
iClose(_Symbol,PERIOD_D1,1)
for close. In Mql4 0 means the current candle, and increases to the left, so -1 in your case becomes 1; this is true when accessing candle data. For regular arrays, e.g., obtained by CopyBuffer
or looping, array indexes are 0 to ArraySize()-1