I'm running MT4 and using MQL4. I need to access the price values at the bar thats at the Fixed Chart Position. CHART_FIXED_POSITION seems to be a place to start but thats a percentage of the screen. I need the bar offset (FixedChartBar) so that I can enter it in one of the pricing functions like
iOpen(NULL, PERIOD_D1, FixedChartBar)
iOpen requires bar number as third parameter.
You have to know which bar you need, newest bar has index 0(zero).
If you have time of the bar, you can get it's index number using iBarShift()

- docs.mql4.com
- There is no such thing as a fixed position; new bars form, old bars shifts left.
- Shifting the chart left only effects the on screen visual. Code as no eyes; You can read any bar, on screen or not. That is not the place to start.
- You need the offset; yes you do. There are no mind readers here and our crystal balls are cracked. Only you know what offset you need. Until you can state your need in concrete terms, it can not be coded. Do you really expect an answer to that vague "I need?"
-
iOpen(NULL, PERIOD_D1, FixedChartBar)
Don't use NULL.- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
-
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4
- There is no such thing as a fixed position; new bars form, old bars shifts left.
There is a feature of MT4 called the Fixed Chart Position. Its a little grey triangle that by default is in the lower left corner of the chart, when auto scroll is off. You can drag that out to, say, the centre of the screen. I want to be able to derive the bar values there, which seems like I need to know the date/time at that point then I can use iBarShift(). I'm writing a tool to help with manual back testing. So the user can indicate which bar to use by dragging the Fixed Chart Position to the appropriate bar. - Shifting the chart left only effects the on screen visual. Code as no eyes; You can read any bar, on screen or not. That is not the place to start.
Yes, I understand, see (1). Its a visual tool that I'm writing. I must translate from screen to code. The screen IS the place that I need to start. - You need the offset; yes you do. There are no mind readers here and our crystal balls are cracked. Only you know what offset you need. Until you can state your need in concrete terms, it can not be coded. Do you really expect an answer to that vague "I need?"
See (1). I informed you in the OP "I need to access the price values at the bar thats at the Fixed Chart Position." - Don't use NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
Thanks - Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
Thanks - Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
See Fixed Chart Position - MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
I think I need to use iHigh to access the different time frames on the one chart?
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not. OrderSend does not.
-
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4
Are you saying I need to use the download_history function if I need to reference other symbol or other TF? Then I need to do that. Where are the error codes defined? - ERR_HISTORY_WILL_UPDATED and ERR_NO_HISTORY_DATA
- FCP is usually used to scroll the chart after changing TF to keep the corresponding bar, in position.
- You want to complicate things. Stop autoscroll and drag the triangle. If you then press a left/right arrow, or page up/down, chart scrolls multiple bars; you are no longer pointing to the correct bar and there is no way to know that; the chart is not fixed.
- If you insist, read the percentage. get the chart's size in pixels. Compute the "centered" x coordinate. Convert XY to price/time. Use time, get shift.
- Instead, just drag a vertical line over a bar and read its time. It stays with the current bar even with shifting and TF changes. Getting the bar time is easy. It is obvious which bar has been indicated, even during dragging.
- read the percentage. get the chart's size in pixels. Compute the "centered" x coordinate. Convert XY to price/time. Use time, get shift.
Thanks William. Very helpful.
I've worked out how to get the percentage and been told how to convert time to get the shift.
How do I get:
1. the chart's size in pixels.
2. Compute the "centered" x coordinate.
3. Convert x coordinate to time
- Perhaps you should read the manual.
ChartGetInteger - Chart Operations - MQL4 Reference
Chart Properties - Chart Constants - Constants, Enumerations and Structures - MQL4 Reference - If there are n pixels, what is the middle one? When in doubt, THINK.
- Perhaps you should read the manual.
ChartXYToTimePrice - Chart Operations - MQL4 Reference
- Perhaps you should read the manual.
ChartGetInteger - Chart Operations - MQL4 Reference
Chart Properties - Chart Constants - Constants, Enumerations and Structures - MQL4 Reference - If there are n pixels, what is the middle one? When in doubt, THINK.
- Perhaps you should read the manual.
ChartXYToTimePrice - Chart Operations - MQL4 Reference
Thanks WIlliam. I should be able to put it together now. You've really sped up my learning.
I do find the manuals hard to read given their translation from Russian to English, I think. I've read a lot, just not the right bits. I read time series a number of times over a number of days before it sunk in what it was on about.
Its great having somebody who is so supportive and respectful of newbies learning the ways of MQL.
<Deleted>

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm running MT4 and using MQL4. I need to access the price values at the bar thats at the Fixed Chart Position. CHART_FIXED_POSITION seems to be a place to start but thats a percentage of the screen. I need the bar offset (FixedChartBar) so that I can enter it in one of the pricing functions like
iOpen(NULL, PERIOD_D1, FixedChartBar)