今天有兄弟想要 获取eurusd的buy价,然后涨了50点后就出售,代码应该怎么写?
- //+------------------------------------------------------------------+
- //| Expert tick function |
- //+------------------------------------------------------------------+
- void OnTick()
- {
- //---
-
- // 记录之前价格
- double dbPrePrice = MarketInfo("EURUSD",MODE_BID);
-
- while(TRUE)
- {
- RefreshRates();
-
- // 当前价格
- double dbPrice = MarketInfo("EURUSD",MODE_BID);
-
- // 点值,根据小数位数判断点值
- int nPValue = 0;
- int nDigit = MarketInfo("EURUSD", MODE_DIGITS);
- if (nDigit <= 3) nPValue = 100;
- else nPValue = 10000;
-
- // 计算点数
- double dbPoint = (dbPrice - dbPrePrice) * nPValue ;
-
- // 小数点精确后2位
- dbPoint = NormalizeDouble(dbPoint,2);
- Comment(dbPoint);
-
- if (dbPoint >= 50)
- {
- OrderSend("EURUSD",OP_SELL , 0.1, dbPrice, 10, 0, 0, "Hello World!", 0, 0, clrGreen);
- }
-
- Sleep(200);
- }
-
- }
- //+------------------------------------------------------------------+
复制代码
|