分析テクニック(インジケーターや自動売買ストラテジ)が適用されているチャートが、現在どのようなインターバル(日足や週足)で表示されているかを調べるには、BarType を参照します。
BarType は、下記のような整数値を返します。
例えば、日足チャートのみで動作する自動売買ストラテジを記述するには、下記のようにします。
If BarType = 2 then begin
Sell next bar at market;
end;
チャートが分足 (BarType == 1)、秒足 (BarType == 14)、ティック足 (BarType == 0) で表示されている場合は、BarInterval を参照することで、何分足、何秒足、何ティック足の表示かを調べることができます。
下記のようなインジケータープログラムをチャートに適用してみてください。
Once begin
Print("BarType=", BarType:0:0, ", BarInterval=", BarInterval:0:0);
end;
チャートの足種を切り替えるごとに下記のように表示されるはずです。
BarType=0, BarInterval=1BarType=0, BarInterval=10BarType=0, BarInterval=25BarType=14, BarInterval=15BarType=14, BarInterval=30BarType=1, BarInterval=1BarType=1, BarInterval=2BarType=1, BarInterval=3BarType=1, BarInterval=4BarType=1, BarInterval=5BarType=1, BarInterval=10BarType=1, BarInterval=15BarType=1, BarInterval=20BarType=1, BarInterval=30BarType=1, BarInterval=60BarType=2, BarInterval=0BarType=3, BarInterval=0BarType=4, BarInterval=0