MQL4参考 图表操作

Chart Operations

These are functions for working with charts. All chart operations are allowed in Expert Advisors and scripts only.

The functions defining the chart properties are actually used for sending change commands to the chart. If these functions are executed successfully, the command is included in the common queue of the chart events. The changes are implemented to the chart when handling the queue of the chart events.

Thus, do not expect an immediate visual update of the chart after calling these functions. Generally, the chart is updated automatically by the terminal following the change events - a new quote arrival, resizing the chart window, etc. Use ChartRedraw() function to forcefully update the chart.

Function

Action

ChartApplyTemplate

Applies a specific template from a specified file to the chart

ChartSaveTemplate

Saves current chart settings in a template with a specified name

ChartWindowFind

Returns the number of a subwindow where an indicator is drawn

ChartTimePriceToXY

Converts the coordinates of a chart from the time/price representation to the X and Y coordinates

ChartXYToTimePrice

Converts the X and Y coordinates on a chart to the time and price values

ChartOpen

Opens a new chart with the specified symbol and period

ChartFirst

Returns the ID of the first chart of the client terminal

ChartNext

Returns the chart ID of the chart next to the specified one

ChartClose

Closes the specified chart

ChartSymbol

Returns the symbol name of the specified chart

ChartPeriod

Returns the period value of the specified chart

ChartRedraw

Calls a forced redrawing of a specified chart

ChartSetDouble

Sets the double value for a corresponding property of the specified chart

ChartSetInteger

Sets the integer value (datetime, int, color, bool or char) for a corresponding property of the specified chart

ChartSetString

Sets the string value for a corresponding property of the specified chart

ChartGetDouble

Returns the double value property of the specified chart

ChartGetInteger

Returns the integer value property of the specified chart

ChartGetString

Returns the string value property of the specified chart

ChartNavigate

Performs shift of the specified chart by the specified number of bars relative to the specified position in the chart

ChartID

Returns the ID of the current chart

ChartIndicatorDelete

Removes an indicator with a specified name from the specified chart window

ChartIndicatorName

Returns the short name of the indicator by the number in the indicators list on the specified chart window

ChartIndicatorsTotal

Returns the number of all indicators applied to the specified chart window.

ChartWindowOnDropped

Returns the number (index) of the chart subwindow the Expert Advisor or script has been dropped to

ChartPriceOnDropped

Returns the price coordinate of the chart point the Expert Advisor or script has been dropped to

ChartTimeOnDropped

Returns the time coordinate of the chart point the Expert Advisor or script has been dropped to

ChartXOnDropped

Returns the X coordinate of the chart point the Expert Advisor or script has been dropped to

ChartYOnDropped

Returns the Y coordinate of the chart point the Expert Advisor or script has been dropped to

ChartSetSymbolPeriod

Changes the symbol value and a period of the specified chart

ChartScreenShot

Provides a screenshot of the chart of its current state in a gif format

Period

Returns timeframe of the current chart

Symbol

Returns a text string with the name of the current financial instrument

WindowBarsPerChart

Returns the amount of bars visible on the chart

WindowExpertName

Returns the name of the executed Expert Advisor, script, custom indicator, or library

WindowFind

Returns the window index containing this specified indicator

WindowFirstVisibleBar

Returns index of the first visible bar in the current chart window

WindowHandle

Returns the system handle of the chart window

WindowIsVisible

Returns the visibility flag of the chart subwindow

WindowOnDropped

Returns the window index where Expert Advisor, custom indicator or script was dropped

WindowPriceMax

Returns the maximal value of the vertical scale of the specified subwindow of the current chart

WindowPriceMin

Returns the minimal value of the vertical scale of the specified subwindow of the current chart

WindowPriceOnDropped

Returns the price of the chart point where Expert Advisor or script was dropped

WindowRedraw

Redraws the current chart forcedly

WindowScreenShot

Saves current chart screen shot as a GIF, PNG or BMP file depending on specified extension

WindowTimeOnDropped

Returns the time of the chart point where Expert Advisor or script was dropped

WindowsTotal

Returns total number of indicator windows on the chart

WindowXOnDropped

Returns the value at X axis in pixels for the chart window client area point at which the Expert Advisor or script was dropped

WindowYOnDropped

Returns the value at Y axis in pixels for the chart window client area point at which the Expert Advisor or script was dropped