MQL4自编指标学习2-Bars iBars() Print()

0
回复
6226
查看
[复制链接]

360

主题

15

回帖

2473

积分

超级版主

积分
2473
来源: 2019-11-23 18:51:12 显示全部楼层 |阅读模式
函数Print()学习

void Print(
argument, // first value
… // next values
);

Parameters
[in] Any values separated by commas. The number of parameters cannot exceed 64.

Note
Arrays cannot be passed to the Print() function. Arrays must be input element-by-element.

例子1
  1. Print("c=",c, "    Pi=",M_PI, "    (float)M_PI=",(float)M_PI);
  2. // c=3.14159    Pi=3.141592653589793    (float)M_PI=3.14159
复制代码
预定义Bars学习

Number of bars in the current chart.
例子2

  1. printf(Bars);
  2.    //2018.11.28 10:36:48.160        柱体标号索引学习 EURUSD,H1: 2221
  3.    //2018.11.28 10:35:55.080        柱体标号索引学习 EURUSD,H4: 8031
  4.    //2018.11.28 10:36:26.926        柱体标号索引学习 EURUSD,Daily: 2049
复制代码

例子3

  1. int counter=1;
  2.   for(int i=1; i<=Bars; i++)
  3.     {
  4.      Print(Close[i-1]);
  5.     }
  6. /*
  7. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.12909
  8. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.1313
  9. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.16021
  10. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.16069
  11. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.16898
  12. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.16816
  13. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.1691
  14. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.20767
  15. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.23257
  16. .....
  17. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.1091
  18. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.1334
  19. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.1113
  20. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: 1.0819
  21. 0        10:57:08.496        柱体标号索引学习 EURUSD,Monthly: initialized
  22. */
复制代码

函数iBars()学习


int iBars(

string symbol, // symbol

int timeframe // timeframe

);

Parameters

symbol

[in] Symbol the data of which should be used to calculate indicator. NULL means the current symbol.

timeframe

[in] Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.

Returned value

The number of bars on the specified chart.

例子4

  1. rint("Bar count on the 'EURUSD,H1' is ",iBars("EURUSD",PERIOD_H1));
  2.    //2018.11.28 10:38:16.128        柱体标号索引学习 EURUSD,H4: Bar count on the 'EURUSD,H1' is 2221
  3.    //2018.11.28 10:38:37.721        柱体标号索引学习 EURUSD,H1: Bar count on the 'EURUSD,H1' is 2221
复制代码

03.jpg



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册
关注微信