//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 获得当前图表的句柄
long handle=ChartID();
string comm="";
if(handle>0) // 如果成功,另外设置图表
{
//--- 禁止自动滚动
ChartSetInteger(handle,CHART_AUTOSCROLL,false);
//--- 设置从右图表边界转移
ChartSetInteger(handle,CHART_SHIFT,true);
//--- 绘制蜡烛图
ChartSetInteger(handle,CHART_MODE,CHART_CANDLES);
//--- 设置跳动量的显示模式
ChartSetInteger(handle,CHART_SHOW_VOLUMES,CHART_VOLUME_TICK);
//--- 在Comment()准备输出文本
comm="Scroll 10 bars to the right of the history start";
//--- 显示注释
Comment(comm);
//--- 滚动10柱到历史记录开始的右侧
ChartNavigate(handle,CHART_BEGIN,10);
//--- 设置图表上第一柱显示的数量(类似时间帧的编号)
long first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
//--- 添加换行符
comm=comm+"\r\n";
//--- 添加到注释
comm=comm+"The first bar on the chart is number "+IntegerToString(first_bar)+"\r\n";
//--- 显示注释
Comment(comm);
//--- 等待5秒查看图表如何移动
Sleep(5000);
//--- 添加到注释文本
comm=comm+"\r\n"+"Scroll 10 bars to the left of the right chart border";
Comment(comm);
//--- 滚动10柱到右图表边界的左侧
ChartNavigate(handle,CHART_END,-10);
//--- 获得图表上第一注显示的数量(类似时间帧的编号)
first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
comm=comm+"\r\n";
comm=comm+"The first bar on the chart is number "+IntegerToString(first_bar)+"\r\n";
Comment(comm);
//--- 等待5秒查看图表如何移动
Sleep(5000);
//--- 图表滚动的新模块
comm=comm+"\r\n"+"Scroll 300 bars to the right of the history start";
Comment(comm);
//--- 滚动300柱到历史记录开始的右侧
ChartNavigate(handle,CHART_BEGIN,300);
first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
comm=comm+"\r\n";
comm=comm+"The first bar on the chart is number "+IntegerToString(first_bar)+"\r\n";
Comment(comm);
//--- 等待5秒查看图表如何移动
Sleep(5000);
//--- 图表滚动的新模块
comm=comm+"\r\n"+"Scroll 300 bars to the left of the right chart border";
Comment(comm);
//--- 滚动300柱到右图表边界的左侧
ChartNavigate(handle,CHART_END,-300);
first_bar=ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR,0);
comm=comm+"\r\n";
comm=comm+"The first bar on the chart is number "+IntegerToString(first_bar)+"\r\n";
Comment(comm);
}
}
|