//--- 输入参数
input uint InpBars = 100000; // Desired number of bars
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 获得服务器上可用柱形图的数量
uint bars_total = Bars(Symbol(),Period());
if(bars_total==0)
{
PrintFormat("Data for timeseries %s %s not yet generated in the terminal. Please try again later.",Symbol(),StringSubstr(EnumToString(Period()),7));
return;
}
//--- 从两个值中获取最小柱形图数量 - 从服务器上可用的值和从设置中请求的值
int bars = (int)MathMin(bars_total,InpBars);
//--- 如果请求的柱形图数量多于服务器上可用的柱形图,请在日志中报告此情况
if(bars_total<InpBars)
PrintFormat("Number of bars on the server (%u) is less than requested (%u)",bars_total,InpBars);
//--- 在日志中显示可用于工作的柱形图数量
Print("Bars available for work: ",bars);
}
|