//+------------------------------------------------------------------+
//| 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>
//+------------------------------------------------------------------+
//| 输入 |
//+------------------------------------------------------------------+
input bool Accumulative=false;
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
int OnStart(void)
{
int k=100;
double arr[10];
//--- 创建图表
CLineChart 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));
}
//--- 使用值
while(!IsStopped())
{
int i=rand()%5;
int j=rand()%10;
k=rand()%3000-1000;
chart.ValueUpdate(i,j,k);
Sleep(200);
}
//--- 完成
chart.Destroy();
return(0);
}
|