Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Class for working with free-form buttons - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources

author EAcpu | 3 reads | 0 comments |

A class for working with free form buttons - library for MetaTrader 5

This class is designed for creating interactive buttons with various states on price charts.

It has been developed for competition by generous arrangement experts . Thanks.

A class for working with free form buttons - library for MetaTrader 5

Demo of CBtn class

create(long chart_id, int sub_wnd, string name, int x, int y, int dx, int dy) - Creates a button with arguments:

resource(string img_up, string img_up_active = "", string img_dn = "", string img_dn_active = "", string img_up_disable = "", string img_dn_disable = "", string img_mask = "") - Images that define different button states:

SetUseMask(ENUM_USEMASK mask,int x=0,int y=0) - Sets a mask by specifying the color of the pixels; the mask is formed from the standard unpressed button image.

SetUseMask(ENUM_USEMASK mask,uint acolor) - Sets the mask by color; the mask is formed from the normal unpressed button image.

SetCorner(ENUM_BASE_CORNER corner) - Sets the chart corner to which the button is anchored

SetAnchor(ENUM_ANCHOR_POINT anchor point) - Set the anchor point type

setX(int x) - Sets the X coordinate

setY(int y) - Sets the Y coordinate

SetXY(int x,int y) - Single method to set X and Y coordinates

on (boolean state) - sets the button state (true means pressed, false means not pressed)

enabled (boolean state) - enables/disables the button

paint(void) - paints the button

event(int id, long lparam, double dparam, string sparam) - Pass the event to the button All parameters are from the OnChartEvent function

GetX(void) - Get the X coordinate

GetY(invalid) - Get the Y coordinate

GetEnabled(void) - Get enabled/disabled status

get(void) - Get pressed/unpressed status

getcorner(null) - Gets the corner of the chart to which the button is anchored

Get anchor point (void) - Get anchor point type

AddText(int x, int y, string font name, int font size, color text color, string text) - Add text to the button

text(String text) - Update button text (does not work without addText(...) call)

Create a button

By default, buttons have the following parameters:

Set button mask

By default, the button is created based on a normal unpressed button image. Transparent pixels are used as masks.


Attachment download

📎 3dbuttons.mq5 (4.04 KB)

📎 class.mqh (24.14 KB)

Source: MQL5 #12637

Verification code Refresh