Skip to content

Chart Properties

Chart Properties

Identifiers of ENUM_CHART_PROPERTY enumerations are used as parameters of functions for working with charts. The abbreviation of r/o in the “Property Type” column means that this property is read-only and cannot be changed. The w/o abbreviation in the “Property Type” column means that this property is write-only and it cannot be received. When accessing certain properties, it’s necessary to specify an additional parameter-modifier (modifier), which serves to indicate the number of chart subwindows. 0 means the main window.

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.

For functions ChartSetInteger() and ChartGetInteger()

ENUM_CHART_PROPERTY_INTEGER

IDDescriptionProperty Type
CHART_SHOWPrice chart drawing. If false, drawing any price chart attributes is disabled and all chart border indents are eliminated, including time and price scales, quick navigation bar, Calendar event labels, trade labels, indicator and bar tooltips, indicator subwindows, volume histograms, etc.

Disabling the drawing is a perfect solution for creating a custom program interface using the graphical resources.

The graphical objects are always drawn regardless of the CHART_SHOW property value.
bool
CHART_IS_OBJECTIdentifying “Chart” (OBJ_CHART) object – returns true for a graphical object. Returns false for a real chartbool r/o
CHART_BRING_TO_TOPShow chart on top of other chartsbool
CHART_CONTEXT_MENUEnabling/disabling access to the context menu using the right click.

When CHART_CONTEXT_MENU=false, only the chart context menu is disabled. The context menu of objects on the chart remains available.
bool (default is true)
CHART_CROSSHAIR_TOOLEnabling/disabling access to the Crosshair tool using the middle click.bool (default is true)
CHART_MOUSE_SCROLLScrolling the chart horizontally using the left mouse button. Vertical scrolling is also available if the value of any following properties is set to true: CHART_SCALEFIX, CHART_SCALEFIX_11 or CHART_SCALE_PT_PER_BAR

When CHART_MOUSE_SCROLL=false, chart scrolling with the mouse wheel is unavailable
bool
CHART_EVENT_MOUSE_WHEELSending messages about mouse wheel events (CHARTEVENT_MOUSE_WHEEL) to all mql5 programs on a chartbool (default is true)
CHART_EVENT_MOUSE_MOVESend notifications of mouse move and mouse click events (CHARTEVENT_MOUSE_MOVE) to all mql5 programs on a chartbool
CHART_EVENT_OBJECT_CREATESend a notification of an event of new object creation (CHARTEVENT_OBJECT_CREATE) to all mql5-programs on a chartbool
CHART_EVENT_OBJECT_DELETESend a notification of an event of object deletion (CHARTEVENT_OBJECT_DELETE) to all mql5-programs on a chartbool
CHART_MODEChart type (candlesticks, bars or line)enum ENUM_CHART_MODE
CHART_FOREGROUNDPrice chart in the foregroundbool
CHART_SHIFTMode of price chart indent from the right borderbool
CHART_AUTOSCROLLMode of automatic moving to the right border of the chartbool
CHART_KEYBOARD_CONTROLAllow managing the chart using a keyboard (“Home”, “End”, “PageUp”, “+”, “-”, “Up arrow”, etc.). Setting CHART_KEYBOARD_CONTROL to false disables chart scrolling and scaling while leaving intact the ability to receive the keys pressing events in OnChartEvent().bool
CHART_QUICK_NAVIGATIONAllow the chart to intercept Space and Enter key strokes to activate the quick navigation bar. The quick navigation bar automatically appears at the bottom of the chart after double-clicking the mouse or pressing Space/Enter. It allows you to quickly change a symbol, timeframe and first visible bar date.bool
CHART_SCALEScaleint from 0 to 5
CHART_SCALEFIXFixed scale modebool
CHART_SCALEFIX_11Scale 1:1 modebool
CHART_SCALE_PT_PER_BARScale to be specified in points per barbool
CHART_SHOW_TICKERDisplay a symbol ticker in the upper left corner. Setting CHART_SHOW_TICKER to ‘false’ also sets CHART_SHOW_OHLC to ‘false’ and disables OHLCbool
CHART_SHOW_OHLCDisplay OHLC values in the upper left corner. Setting CHART_SHOW_OHLC to ’true’ also sets CHART_SHOW_TICKER to ’true’ and enables the tickerbool
CHART_SHOW_BID_LINEDisplay Bid values as a horizontal line in a chartbool
CHART_SHOW_ASK_LINEDisplay Ask values as a horizontal line in a chartbool
CHART_SHOW_LAST_LINEDisplay Last values as a horizontal line in a chartbool
CHART_SHOW_PERIOD_SEPDisplay vertical separators between adjacent periodsbool
CHART_SHOW_GRIDDisplay grid in the chartbool
CHART_SHOW_VOLUMESDisplay volume in the chartenum ENUM_CHART_VOLUME_MODE
CHART_SHOW_OBJECT_DESCRDisplay textual descriptions of objects (not available for all objects)bool
CHART_SHOW_TRADE_HISTORYDisplay trades from the trading history as entry/exit arrows on a chart. See the “Show trading history” option descriptions in the platform settings.bool
CHART_VISIBLE_BARSThe number of bars on the chart that can be displayedint r/o
CHART_WINDOWS_TOTALThe total number of chart windows, including indicator subwindowsint r/o
CHART_WINDOW_IS_VISIBLEVisibility of subwindowsbool r/o modifier - subwindow number
CHART_WINDOW_HANDLEChart window handle (HWND)int r/o
CHART_WINDOW_YDISTANCEThe distance between the upper frame of the indicator subwindow and the upper frame of the main chart window, along the vertical Y axis, in pixels. In case of a mouse event, the cursor coordinates are passed in terms of the coordinates of the main chart window, while the coordinates of graphical objects in an indicator subwindow are set relative to the upper left corner of the subwindow.

The value is required for converting the absolute coordinates of the main chart to the local coordinates of a subwindow for correct work with the graphical objects, whose coordinates are set relative to the upper left corner of the subwindow frame.
int r/o modifier - subwindow number
CHART_FIRST_VISIBLE_BARNumber of the first visible bar in the chart. Indexing of bars is the same as for timeseries.int r/o
CHART_WIDTH_IN_BARSChart width in barsint r/o
CHART_WIDTH_IN_PIXELSChart width in pixelsint r/o
CHART_HEIGHT_IN_PIXELSChart height in pixelsint modifier - subwindow number
CHART_COLOR_BACKGROUNDChart background colorcolor
CHART_COLOR_FOREGROUNDColor of axes, scales and OHLC linecolor
CHART_COLOR_GRIDGrid colorcolor
CHART_COLOR_VOLUMEColor of volumes and position opening levelscolor
CHART_COLOR_CHART_UPColor for the up bar, shadows and body borders of bull candlestickscolor
CHART_COLOR_CHART_DOWNColor for the down bar, shadows and body borders of bear candlestickscolor
CHART_COLOR_CHART_LINELine chart color and color of “Doji” Japanese candlestickscolor
CHART_COLOR_CANDLE_BULLBody color of a bull candlestickcolor
CHART_COLOR_CANDLE_BEARBody color of a bear candlestickcolor
CHART_COLOR_BIDBid price level colorcolor
CHART_COLOR_ASKAsk price level colorcolor
CHART_COLOR_LASTLine color of the last executed deal price (Last)color
CHART_COLOR_STOP_LEVELColor of stop order levels (Stop Loss and Take Profit)color
CHART_SHOW_TRADE_LEVELSDisplaying trade levels in the chart (levels of open positions, Stop Loss, Take Profit and pending orders)bool
CHART_DRAG_TRADE_LEVELSPermission to drag trading levels on a chart with a mouse. The drag mode is enabled by default (true value)bool
CHART_SHOW_DATE_SCALEShowing the time scale on a chartbool
CHART_SHOW_PRICE_SCALEShowing the price scale on a chartbool
CHART_SHOW_ONE_CLICKShowing the “One click trading” panel on a chartbool
CHART_IS_MAXIMIZEDChart window is maximizedbool r/o
CHART_IS_MINIMIZEDChart window is minimizedbool r/o
CHART_IS_DOCKEDThe chart window is docked. If set to false, the chart can be dragged outside the terminal areabool
CHART_FLOAT_LEFTThe left coordinate of the undocked chart window relative to the virtual screenint
CHART_FLOAT_TOPThe top coordinate of the undocked chart window relative to the virtual screenint
CHART_FLOAT_RIGHTThe right coordinate of the undocked chart window relative to the virtual screenint
CHART_FLOAT_BOTTOMThe bottom coordinate of the undocked chart window relative to the virtual screenint

For functions ChartSetDouble() and ChartGetDouble()

ENUM_CHART_PROPERTY_DOUBLE

IDDescriptionProperty Type
CHART_SHIFT_SIZEThe size of the zero bar indent from the right border in percentsdouble (from 10 to 50 percents)
CHART_FIXED_POSITIONChart fixed position from the left border in percent value. Chart fixed position is marked by a small gray triangle on the horizontal time axis. It is displayed only if the automatic chart scrolling to the right on tick incoming is disabled (see CHART_AUTOSCROLL property). The bar on a fixed position remains in the same place when zooming in and out.double
CHART_FIXED_MAXFixed chart maximumdouble
CHART_FIXED_MINFixed chart minimumdouble
CHART_POINTS_PER_BARScale in points per bardouble
CHART_PRICE_MINChart minimumdouble r/o modifier - subwindow number
CHART_PRICE_MAXChart maximumdouble r/o modifier - subwindow number

For functions ChartSetString() and ChartGetString()

ENUM_CHART_PROPERTY_STRING

IDDescriptionProperty Type
CHART_COMMENTText of a comment in a chartstring
CHART_EXPERT_NAMEThe name of the Expert Advisor running on the chart with the specified chart_idstring r/o
CHART_SCRIPT_NAMEThe name of the script running on the chart with the specified chart_idstring r/o

Example:

int chartMode=ChartGetInteger(0,CHART_MODE);
   switch(chartMode)
     {
      case(CHART_BARS):    Print("CHART_BARS");   break;
      case(CHART_CANDLES): Print("CHART_CANDLES");break;
      default:Print("CHART_LINE");
     }
   bool shifted=ChartGetInteger(0,CHART_SHIFT);
   if(shifted) Print("CHART_SHIFT = true");
   else Print("CHART_SHIFT = false");
   bool autoscroll=ChartGetInteger(0,CHART_AUTOSCROLL);
   if(autoscroll) Print("CHART_AUTOSCROLL = true");
   else Print("CHART_AUTOSCROLL = false");
   int chartHandle=ChartGetInteger(0,CHART_WINDOW_HANDLE);
   Print("CHART_WINDOW_HANDLE = ",chartHandle);
   int windows=ChartGetInteger(0,CHART_WINDOWS_TOTAL);
   Print("CHART_WINDOWS_TOTAL = ",windows);
   if(windows>1)
     {
      for(int i=0;i<windows;i++)
        {
         int height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,i);
         double priceMin=ChartGetDouble(0,CHART_PRICE_MIN,i);
         double priceMax=ChartGetDouble(0,CHART_PRICE_MAX,i);
         Print(i+": CHART_HEIGHT_IN_PIXELS = ",height," pixels");
         Print(i+": CHART_PRICE_MIN = ",priceMin);
         Print(i+": CHART_PRICE_MAX = ",priceMax);
        }
     }

See also

Examples of Working with the Chart

Last updated on