【发布时间】:2022-12-21 04:05:29
【问题描述】:
我是 mql4 的初学者,我正在尝试一些东西。
我需要计算价格从一秒到另一秒的变化速度。在 mql4 或 pine 脚本上。 有没有办法做到这一点?
【问题讨论】:
-
请提供足够的代码,以便其他人可以更好地理解或重现问题。
标签: pine-script mql4 mql5 mql mt4
我是 mql4 的初学者,我正在尝试一些东西。
我需要计算价格从一秒到另一秒的变化速度。在 mql4 或 pine 脚本上。 有没有办法做到这一点?
【问题讨论】:
标签: pine-script mql4 mql5 mql mt4
是的,在 TradingView 中,如果您有付费版本,您可以访问 1 秒的时间范围,然后进行计算。
【讨论】:
非常简单。只需使用预定义变量“Ask”。 使用以下代码: {double Price=要价; 评论(“问”);}
【讨论】:
如果你想计算一些东西,你可以这样做
我的代码每 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
}
【讨论】: