Dislikedstatic datetime opn = iOpen(Symbol(), PERIOD_MN1, D'01.01.2019'); //D'31.12.2019' ; static datetime cls = iClose(Symbol(), PERIOD_MN1, D'31.12.2018'); // D'31.12.2018' ; IS IT RIGHTIgnored
double iOpen(
string symbol, // symbol
int timeframe, // timeframe
int shift // shift
);
Also 'Static' means the variable is permanent for the duration of the program (but can have it's value updated) - but is probably not what you intend.
First, find the bar number for the date using iBarShift:
int iBarShift(
string symbol, // symbol
int timeframe, // timeframe
datetime time, // time
bool exact=false // mode
);
like this:
datetime some_time=D'2004.03.21 12:00';
int barNum = iBarShift(_Symbol, PERIOD_H1, some_time, false);
Then use that number in the iOpen and iClose calls, like so:
double openValue = iOpen(_Symbol, PERIOD_H1, barNum);
1