mohaddese abbasi
mohaddese abbasi

Reputation: 89

Getting last days prices on iLow(NULL,PERIOD_H1,0)

i have an expert advisor that runs on daily timeframe, in it i need to get a few candles low prices. candles are from 1 to 7; when i use iLow(NULL,,PERIOD_H1,0) till iLow(NULL,,PERIOD_H1,7) i get exactly 0 till 7 low prices but for yesterday! why is it?

tradeTime=D'08:00:00';
void OnTick()
  {     
    if (TimeHour(currentTime) == TimeHour(tradeTime) && TimeMinute(currentTime) == TimeMinute(tradeTime) && tradeFlag==1) 
    {
    
          for(int i = 1; i <= 7; i++) {
            double low = iLow(NULL, PERIOD_H1, i);
            Print(low);
        }
    }
}

i have tried to run it in different times (instead of 8) sometimes it works and sometimes not!

Upvotes: -1

Views: 38

Answers (1)

4xPip Official
4xPip Official

Reputation: 31

  1. iLow(NULL, PERIOD_H1, 0) = Will give you Low price of current candle at H1_TimeFrame. Current candle is under formation
  2. iLow(NULL, PERIOD_H1, 1) = Will give you Low price of previous candle at H1_TimeFrame.
  3. iLow(NULL, PERIOD_H1, 2) = Will give you Low price of previous candle at shift 2 at H1_TimeFrame. ....

So your code is returning Low price at 1 Hour timeframe of last 7 candles. It could be possible that last 7 candles are formed within today or Yesterday. If you have candles of today on the chart, then code will return Low price of Todays candles or yesterdays.

Also make sure that you are running this EA on correct timeframe. If you want to obtain Low price on current timeframe then use iLow(NULL, PERIOD_D1, i);

image of the result

Upvotes: 1

Related Questions