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

Easy Canvas - MetaTrader 5 Library | Forex Indicator Download - MT4/MT5 Resources

author EAcpu | 3 reads | 0 comments |

Easy Canvas - library for MetaTrader 5

Below is an example of a simple indicator using this library.

In this example, the indicator body does not have the functionality to handle the OnChartEvent event. But it may exist.

Easy Canvas - library for MetaTrader 5

# Property indicator chart window
#include <canvas\iCanvas.mqh> integer initialization ()
  {
event set millisecond timer ( 33 );
ChartSetInteger ( 0 , ChartShow , True );
Chart set integer ( 0 , CHART_CROSSHAIR_TOOL , wrong ); // Turn off crosshair return ( initialization successful );
  } blank solution init ( const integer reason) { if (reason < 2 ) { chartset integer ( 0 , CHART_CROSSHAIR_TOOL , True ); chart redraw (); }} blank timer ()
  {
Rest integer X= 0 ;
Rest integer Y = 0 ;
if (X!=W.MouseX || Y!=W.MouseY)
    {
      canvas.erase( 0 );
// Draw a fuzzy point for ( integer ix=- 20 ; ix<= 20 ; nine++) for ( integer iy=- 20 ; iy<= 20 ; iy++)
        {
Double p= square root (ix*ix+iy*iy)/ 20.0 ;
if (p> 1 ) p= 1 ;
Uchar P=( Uchar ) round (( 1.0 -p)* 255.0 );
        Canvas.PixelSet(W.MouseX+ix,W.MouseY+iy,ARGB(P, 100 , 0 , 200 ));
        }
//Display information block integer Y1=( integer )Canvas.Y( canvas.Close (W.MouseX));
      Canvas.FillRectangle(W.MouseX,Y1,W.MouseX+ 140 ,Y1+ 67 , 0xA0808080 );
      canvas. Text output (W.MouseX+ 5 ,Y1+ 2 , "off=" + double to string ( canvas.off (W.MouseX), _number ), 0xFFFFFFFF );
      canvas. Text output (W.MouseX+ 5 , Y1+ 18 , "bar=" + double-precision conversion to string (W.MouseBar, 2 ), 0xFFFFFFFF );
      canvas. Text output (W.MouseX+ 5 , Y1+ 34 , string time (W.MouseTime, TIME_DATE | TIME_SECONDS ), 0xFFFFFFFF );
      canvas. Text output (W.MouseX+ 5 ,Y1+ 50 , "Subwindow=" + string (W.MouseSubWin), 0xFFFFFFFF );
// Crosshair Canvas.LineHorizontal( 0 ,W.Width- 1 ,W.MouseY,~W.Color);
      Canvas.LineVertical(W.MouseX, 0 ,W.Height- 1 ,~W.Color);
Integer Ym=(W.MouseY> 16 )?(W.MouseY- 16 ):(W.MouseY+ 2 );
Integer Xm=(W.MouseX<(W.width- 140 ))?(W.MouseX+ 4 ):(W.MouseX- 125 );
      canvas. Text Output (W. Width - 76>, um, double to string (W.MousePrice, _Number ),~W.Color); Canvas. text output ( }

Library features:

Window structure:

structure window {
Unit Color; // Window background color integer Width; // Window width integer Height; // Window height integer Left column; // The number of the leftmost column in the window doubles the right column; // The number of the rightmost column in the window doubles the total number of bars; // The maximum number of bars in the window integer Wind Bar; // The number of visible bars in the window doubles Y_min; // The minimum value of the price in the window doubles Y_max; // The maximum value of the price in the window is doubled dy_pix; // The price change of one pixel is integer dx_pixel ; // Change the number of bars of each pixel integer Mouse The integer Windows total of the sub-window number where the mouse pointer is located ; // The total number of sub-windows, including the main window integer Sub-window; // The current sub-window date and time Time []; // The opening time array of all visible bars in the window };
 class canvas: peoplecanvas { private :
datetime T[ 1 ];
doublePu [ 1 ];
Boolean value FullWinCanvW; // Use a full window canvas by width Boolean value FullWinCanvH; // Use a full window canvas by height
people :
                    iCanvas ( integer
                    ~iCanvas() { destroy();};
Double X ( double the bar);
Double X ( DateTimeTime ) { return
Double Y( double price) { return ((W.Y_max-price)/W.dy_pix); };
double bar( integer x) { return (( double )W.Left_bar+ 1 -( double )x/( double )W.dx_pix);};
DateTime TimePosition ( integerspan>)B));}; double closed ( integer _symbol , _period , integer ( bar (x)) , 1 , Pr); return Pu [0 ] ;}; double low (integer Use full - window canvas Boolean value FullWinCanvHeight ( ) { return FullWinCanvH ; } ; // Use full - window canvas by height ENUM_PROGRAM_TYPE program type ; } ;

Attachment download

📎 test_icanvas.mq5 (6.64 KB)

📎 icanvas.mqh (31.88 KB)

Source: MQL5 #22164

Easy Canvas - MetaTrader 5 library | Forex indicator download - MT4/MT5 resource usage and screening suggestions

Easy Canvas - MetaTrader 5 Library | Foreign Exchange Indicator Download - MT4/MT5 resources are foreign exchange indicator related resources. Before downloading or referencing, it is recommended to confirm the platform version, transaction type, time period, whether DLL is required, whether source code is included, parameter description and historical update records.

Both automated trading tools and foreign exchange indicators should first undergo backtesting, simulated account observation, and small capital verification. Pay special attention to spreads, slippages, maximum drawdowns, position opening frequency, stop loss methods, trading periods and broker rules, and avoid direct real-time execution based only on titles or short-term profit descriptions.

Verification code Refresh