ChartNavigate

通过指定的关系柱完成指定图表到图表中的指定位置的转换。

bool  ChartNavigate(

   long                  chart_id,     // 图表 ID

   ENUM_CHART_POSITION   position,     // 位置

   int                   shift=0       // 移动值

   );

参量

chart_id

[in]  图表 ID. 0 意味着当前图表。

position

[in]  完成转换的图表位置。可以是ENUM_CHART_POSITION值中的一个。

shift=0

[in]  转换图表的柱数。正值意味着向右移动(图表末端),负值意味着左移(到图表起点)。0值用来控制图表的起止。

返回值

若成功,返回true,否则返回false。

示例:

//+------------------------------------------------------------------+

//| 脚本程序起始函数                                                   |

//+------------------------------------------------------------------+

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);

     }

  }