//+------------------------------------------------------------------+ //| スクリプトプログラムを開始する関数 | //+------------------------------------------------------------------+ 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); } } |