繁体   English   中英

mql4 中有没有一种方法可以逐秒获取价格?

[英]Is there a way in mql4 to get prices second by second?

我是 mql4 的初学者,我正在尝试一些东西。

我需要计算价格从一秒到另一秒的变化速度。 在 mql4 或 pine 脚本上。 有没有办法做到这一点?

是的,在 TradingView 中,如果您有付费版本,您可以访问 1 秒的时间范围,然后进行计算。

非常简单。只需使用预定义变量“Ask”。 使用以下代码:{double Price=Ask; 评论(“问”);}

如果你想计算一些东西,你可以这样做

  • 每个 Tick = OnTick()
  • 每 x 秒 = OnTimer()

我的代码每 1 秒显示一次 OnTimer() 事件。

 //+------------------------------------------------------------------+ //| MQL4 Code | //| | //+------------------------------------------------------------------+ #property strict int OnInit(){ // Timer event for every -1- Second EventSetTimer(1); return(INIT_SUCCEEDED); } void OnDeinit(const int reason){ EventKillTimer(); } void OnTick(){ } void OnTimer(){ // Check every Second new values get_Current_Price(); } void get_Current_Price(){ // MQL Get Current Price. // Get Ask and Bid of the current pair with MarketInfo // and save the values in variables. double PriceAsk = MarketInfo(Symbol(), MODE_ASK); double PriceBid = MarketInfo(Symbol(), MODE_BID); // Print and Comment the values. Print ("Bid = " + DoubleToString(PriceBid, Digits) + " Ask = " + DoubleToString(PriceAsk, Digits)); Comment("Bid = " + DoubleToString(PriceBid, Digits) + " Ask = " + DoubleToString(PriceAsk, Digits)); // MessageBox possible, but will not be the best way //MessageBox("Bid = " + DoubleToString(PriceBid, Digits) + " Ask = " + DoubleToString(PriceAsk, Digits)); // calculate what ever you need }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM