Getting last days prices on iLow(NULL,PERIOD_H1,0)
Getting last days prices on iLow(NULL,PERIOD_H1,0)
Loading saved threads...
mohaddese abbasi · External communityPost link
External question — Stack Overflow Stack Exchange
Author: mohaddese abbasi
Original post: https://stackoverflow.com/questions/78918603
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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!
Quote
Report
4xPip Official · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: 4xPip Official
Original post: https://stackoverflow.com/a/79068133
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
iLow(NULL, PERIOD_H1, 0)
= Will give you Low price of current candle
at H1_TimeFrame. Current candle is under formation
iLow(NULL, PERIOD_H1, 1)
= Will give you Low price of previous candle at
H1_TimeFrame.
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);
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: 4xPip Official Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/a/79068133 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. iLow(NULL, PERIOD_H1, 0) = Will give you Low price of current candle at H1_TimeFrame. Current candle is under formation iLow(NULL, PERIOD_H1, 1) = Will give you Low price of previous candle at H1_TimeFrame. 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);
Checking account access…