First commit [09/03/2018]

This commit is contained in:
Pierre8rTeam
2018-03-09 16:43:19 +01:00
commit 25e9006a0b
375 changed files with 294601 additions and 0 deletions
+211
View File
@@ -0,0 +1,211 @@
//+------------------------------------------------------------------+
//| CanvasSample.mq5 |
//| Copyright 2009-2017, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2017, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Demonstrating Canvas features"
//---
#include <Canvas\Canvas.mqh>
//+------------------------------------------------------------------+
//| inputs |
//+------------------------------------------------------------------+
input int Width=800;
input int Height=600;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
int OnStart(void)
{
int total=1024;
int limit=MathMax(Width,Height);
int x1,x2,x3,y1,y2,y3,r;
int x[],y[];
//--- check
if(Width<100 || Height<100)
{
Print("Too simple.");
return(-1);
}
//--- create canvas
CCanvas canvas;
if(!canvas.CreateBitmapLabel("SampleCanvas",0,0,Width,Height,COLOR_FORMAT_ARGB_RAW))
{
Print("Error creating canvas: ",GetLastError());
return(-1);
}
//--- deawing
canvas.Erase(XRGB(0x1F,0x1F,0x1F));
canvas.Update();
//--- start randomizer
srand(GetTickCount());
//--- draw pixels
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
y1=rand()%limit;
canvas.PixelSet(x1,y1,RandomRGB());
canvas.Update();
}
//--- erase
canvas.Erase(XRGB(0x1F,0x1F,0x1F));
canvas.Update();
//--- draw horizontal/vertical lines
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
x2=rand()%limit;
y1=rand()%limit;
y2=rand()%limit;
if(i%2==0)
canvas.LineHorizontal(x1,x2,y1,RandomRGB());
else
canvas.LineVertical(x1,y1,y2,RandomRGB());
canvas.Update();
}
//--- draw lines
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
x2=rand()%limit;
y1=rand()%limit;
y2=rand()%limit;
canvas.Line(x1,y1,x2,y2,RandomRGB());
canvas.Update();
}
//--- erase
canvas.Erase(XRGB(0x1F,0x1F,0x1F));
canvas.Update();
//--- draw filled circles
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
y1=rand()%limit;
r =rand()%limit;
canvas.FillCircle(x1,y1,r,RandomRGB());
canvas.Update();
}
//--- draw circles
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
y1=rand()%limit;
r =rand()%limit;
canvas.Circle(x1,y1,r,RandomRGB());
canvas.Update();
}
//--- erase
canvas.Erase(XRGB(0x1F,0x1F,0x1F));
canvas.Update();
//--- draw filled rectangles
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
y1=rand()%limit;
x2=rand()%limit;
y2=rand()%limit;
canvas.FillRectangle(x1,y1,x2,y2,RandomRGB());
canvas.Update();
}
//--- draw rectangles
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
y1=rand()%limit;
x2=rand()%limit;
y2=rand()%limit;
canvas.Rectangle(x1,y1,x2,y2,RandomRGB());
canvas.Update();
}
//--- erase
canvas.Erase(XRGB(0x1F,0x1F,0x1F));
canvas.Update();
//--- draw filled triangles
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
y1=rand()%limit;
x2=rand()%limit;
y2=rand()%limit;
x3=rand()%limit;
y3=rand()%limit;
canvas.FillTriangle(x1,y1,x2,y2,x3,y3,RandomRGB());
canvas.Update();
}
//--- draw triangles
for(int i=0;i<total && !IsStopped();i++)
{
x1=rand()%limit;
y1=rand()%limit;
x2=rand()%limit;
y2=rand()%limit;
x3=rand()%limit;
y3=rand()%limit;
canvas.Triangle(x1,y1,x2,y2,x3,y3,RandomRGB());
canvas.Update();
}
//--- erase
canvas.Erase(XRGB(0x1F,0x1F,0x1F));
canvas.Update();
//---
ArrayResize(x,10);
ArrayResize(y,10);
//--- draw polyline
for(int i=0;i<10;i++)
{
x[i]=rand()%Width;
y[i]=rand()%Height;
}
canvas.Polyline(x,y,RandomRGB());
canvas.Update();
//--- draw polygon
for(int i=0;i<10;i++)
{
x[i]=rand()%Width;
y[i]=rand()%Height;
}
canvas.Polygon(x,y,RandomRGB());
canvas.Update();
//--- filling
for(int i=0;i<total && !IsStopped();i++)
{
int xf=rand()%Width;
int yf=rand()%Height;
canvas.Fill(xf,yf,RandomRGB());
canvas.Update();
}
//--- erase
canvas.Erase(XRGB(0x1F,0x1F,0x1F));
canvas.Update();
//--- draw text
string text;
x1=Width/2;
y1=Height/2;
r =y1-50;
for(int i=0;i<8;i++)
{
double a=i*M_PI_4;
uint clr=RandomRGB();
int deg=(int)(180*a/M_PI);
x2=x1+(int)(r*cos(a));
y2=y1-(int)(r*sin(a));
canvas.LineAA(x1,y1,x2,y2,clr,STYLE_DASHDOTDOT);
text="Angle "+IntegerToString(deg);
canvas.FontSet(canvas.FontNameGet(),canvas.FontSizeGet(),canvas.FontFlagsGet(),10*deg);
canvas.TextOut(x2,y2,text,clr,TA_RIGHT|TA_BOTTOM);
canvas.Update();
}
//--- finish
ObjectDelete(0,"SampleCanvas");
canvas.Destroy();
return(0);
}
//+------------------------------------------------------------------+
//| Random RGB color |
//+------------------------------------------------------------------+
uint RandomRGB(void)
{
return(XRGB(rand()%255,rand()%255,rand()%255));
}
//+------------------------------------------------------------------+
@@ -0,0 +1,66 @@
//+------------------------------------------------------------------+
//| HistogramChartSample.mq5 |
//| Copyright 2009-2017, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2017, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Example of using histogram"
//---
#include <Canvas\Charts\HistogramChart.mqh>
//+------------------------------------------------------------------+
//| inputs |
//+------------------------------------------------------------------+
input bool Accumulative=true;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
int OnStart(void)
{
int k=100;
double arr[10];
//--- create chart
CHistogramChart chart;
if(!chart.CreateBitmapLabel("SampleHistogramChart",10,10,600,450))
{
Print("Error creating histogram chart: ",GetLastError());
return(-1);
}
if(Accumulative)
{
chart.Accumulative();
chart.VScaleParams(20*k*10,-10*k*10,20);
}
else
chart.VScaleParams(20*k,-10*k,20);
chart.ShowValue(true);
chart.ShowScaleTop(false);
chart.ShowScaleBottom(false);
chart.ShowScaleRight(false);
chart.ShowLegend();
for(int j=0;j<5;j++)
{
for(int i=0;i<10;i++)
{
k=-k;
if(k>0)
arr[i]=k*(i+10-j);
else
arr[i]=k*(i+10-j)/2;
}
chart.SeriesAdd(arr,"Item"+IntegerToString(j));
}
//--- play with values
while(!IsStopped())
{
int i=rand()%5;
int j=rand()%10;
k=rand()%3000-1000;
chart.ValueUpdate(i,j,k);
Sleep(200);
}
//--- finish
chart.Destroy();
return(0);
}
//+------------------------------------------------------------------+
@@ -0,0 +1,66 @@
//+------------------------------------------------------------------+
//| LineChartSample.mq5 |
//| Copyright 2009-2017, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2017, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Example of using line chart"
//---
#include <Canvas\Charts\LineChart.mqh>
//+------------------------------------------------------------------+
//| inputs |
//+------------------------------------------------------------------+
input bool Accumulative=false;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
int OnStart(void)
{
int k=100;
double arr[10];
//--- create chart
CLineChart chart;
//--- create chart
if(!chart.CreateBitmapLabel("SampleHistogrammChart",10,10,600,450))
{
Print("Error creating line chart: ",GetLastError());
return(-1);
}
if(Accumulative)
{
chart.Accumulative();
chart.VScaleParams(20*k*10,-10*k*10,20);
}
else
chart.VScaleParams(20*k,-10*k,15);
chart.ShowScaleTop(false);
chart.ShowScaleRight(false);
chart.ShowLegend();
chart.Filled();
for(int j=0;j<5;j++)
{
for(int i=0;i<10;i++)
{
k=-k;
if(k>0)
arr[i]=k*(i+10-j);
else
arr[i]=k*(i+10-j)/2;
}
chart.SeriesAdd(arr,"Item"+IntegerToString(j));
}
//--- play with values
while(!IsStopped())
{
int i=rand()%5;
int j=rand()%10;
k=rand()%3000-1000;
chart.ValueUpdate(i,j,k);
Sleep(200);
}
//--- finish
chart.Destroy();
return(0);
}
//+------------------------------------------------------------------+
@@ -0,0 +1,97 @@
//+------------------------------------------------------------------+
//| PieChartSample.mq5 |
//| Copyright 2009-2017, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2017, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Example of using pie chart"
//---
#include <Canvas\Charts\PieChart.mqh>
//+------------------------------------------------------------------+
//| inputs |
//+------------------------------------------------------------------+
input int Width=600;
input int Height=450;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
int OnStart(void)
{
//--- check
if(Width<=0 || Height<=0)
{
Print("Too simple.");
return(-1);
}
//--- create chart
CPieChart pie_chart;
if(!pie_chart.CreateBitmapLabel("PieChart",10,10,Width,Height))
{
Print("Error creating pie chart: ",GetLastError());
return(-1);
}
pie_chart.ShowPercent();
//--- draw
for(uint i=0;i<30;i++)
{
pie_chart.ValueAdd(100*(i+1),"Item "+IntegerToString(i));
Sleep(10);
}
Sleep(2000);
//--- disable legend
pie_chart.LegendAlignment(ALIGNMENT_LEFT);
Sleep(2000);
//--- disable legend
pie_chart.LegendAlignment(ALIGNMENT_RIGHT);
Sleep(2000);
//--- disable legend
pie_chart.LegendAlignment(ALIGNMENT_TOP);
Sleep(2000);
//--- disable legend
pie_chart.ShowLegend(false);
Sleep(2000);
//--- disable percentage
pie_chart.ShowPercent(false);
Sleep(2000);
//--- disable descriptors
pie_chart.ShowDescriptors(false);
Sleep(2000);
//--- enable all
pie_chart.ShowLegend();
pie_chart.ShowValue();
pie_chart.ShowDescriptors();
Sleep(2000);
//--- or like this
pie_chart.ShowFlags(FLAG_SHOW_LEGEND|FLAG_SHOW_DESCRIPTORS|FLAG_SHOW_PERCENT);
uint total=pie_chart.DataTotal();
//--- play with values
for(uint i=0;i<total && !IsStopped();i++)
{
pie_chart.ValueUpdate(i,100*(rand()%10+1));
Sleep(1000);
}
//--- play with colors
for(uint i=0;i<total && !IsStopped();i++)
{
pie_chart.ColorUpdate(i%total,RandomRGB());
Sleep(1000);
}
//--- rotate
while(!IsStopped())
{
pie_chart.DataOffset(pie_chart.DataOffset()+1);
Sleep(200);
}
//--- finish
pie_chart.Destroy();
return(0);
}
//+------------------------------------------------------------------+
//| Random RGB color |
//+------------------------------------------------------------------+
uint RandomRGB(void)
{
return(XRGB(rand()%255,rand()%255,rand()%255));
}
//+------------------------------------------------------------------+