For every backup in price you need to add [number] how long you want to look back.......
last say you want to look 10th bar before current one, you will code this;
double OpenPrice=Open; .....the number 9 is ok becouse you are counting from zero bar (9+current bar is 10 bars)!!!
In most of the codes(especialy indicators) you will see ; double OpenPrice=Open[i];
take a note that you need to have initialized i ......int i; ...so i represents a zero bar!!!
For every bar back you want to look, just add u number to i...........
double OpenPrice=Open[i]; // CURRENT BAR double OpenPrice=Open[i+1]; // LAST BAR double OpenPrice=Open[i+2]; // CURRENT BAR-2 double OpenPrice=Open[i+9]; // CURRENT BAR-9 ETC..........
Joined Jun 2008
Status: Programming for a better future.
int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)
Search for bar by open time. The function returns bar shift with the open time specified. If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.
assuming variable "theTime" is the unix-timestamp of the time you need, and we're using the current symbol and current timeframe.
int theShift = iBarShift( NULL, 0, theTime, false);
now you can use Open[theShift], High[theShift], Low[theShift], Close[theShift]