What is the value of one pixel?
What is the value of one pixel on the Y axis of the current chart? Thank you in advance.
The value ?
A pixel doesn't have a "value".
What do you mean ?
What is the value of one pixel on the Y axis of the current chart? Thank you in advance.
The value ? A pixel doesn't have a "value".
What do you mean ?
min_price = ChartGetDouble(0,CHART_PRICE_MIN);
long chart_height = ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS);
printf("1 pixel = %f",(max_price-min_price)/chart_height);
min_price = ChartGetDouble(0,CHART_PRICE_MIN);
long chart_height = ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS);
printf("1 pixel = %f",(max_price-min_price)/chart_height);
If a pixel does not have a value, how then is it possible to draw a line using x and y axes (of course these variables take values in pixels) or to create buttons etc that use the coordinates?
Please see: https://www.mql5.com/en/docs/chart_operations/chartxytotimeprice
- www.mql5.com
If a pixel does not have a value, how then is it possible to draw a line using x and y axes (of course these variables take values in pixels) or to create buttons etc that use the coordinates?
It is probably worth mentioning that there are 2 different ways to draw objects.
- Using time / price... such as OBJ_TREND and OBJ_TEXT
- These objects will move along the screen as you scroll the chart left/right/up/down.
- Using X/Y pixels... such as OBJ_BUTTON and OBJ_LABEL
- These objects will not move on the screen, even if the chart scrolls.
Sometimes it is necessary to mix these up e.g. you want to draw an object relative to time on the X axis, and pixels on the Y axis.
Under these circumstances, you will want to use ChartXYToTimePrice() or ChartTimePriceToXY() as Marco has suggested.
long chart_id, // Chart ID
int sub_window, // The number of the subwindow
datetime time, // Time on the chart
double price, // Price on the chart
int& x, // The X coordinate for the time on the chart
int& y // The Y coordinates for the price on the chart
);
There could be a very large bar at the far left of the screen, when that bar moves out of the visible area then any values calculated would cgange again as the chart adjusts to the total range.
What about when you have the terminal and/or strategy tester windows open?
There would be nothing uniform at all by using pixels
Wow! I think this one should be a lot useful. Thanks a lot. I will combine it with the following reverse function:
long chart_id, // Chart ID
int sub_window, // The number of the subwindow
datetime time, // Time on the chart
double price, // Price on the chart
int& x, // The X coordinate for the time on the chart
int& y // The Y coordinates for the price on the chart
);
I need this value so that I can calculate the value of 600 pixels.
This is because I want 600 pixel take profit level, and not 600 Points or 600 pips.
I want a uniform take profit levels on all charts, regardless of their Point values or Pip values.
It is time to trade in terms of pixels. Thank you in advance somebody.