Is there a way in mql4 to get prices second by second?
Is there a way in mql4 to get prices second by second?
Loading saved threads...
Dandi · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Dandi
Original post: https://stackoverflow.com/questions/74551457
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I am a beginner in mql4 and I'm trying something out.
I need to calculate the speed rate of price changes from one second to another. Either on mql4 or pine script.
Is there a way to achieve that?
Quote
Report
G.Lebret · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: G.Lebret
Original post: https://stackoverflow.com/a/74554525
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Yes in TradingView, if you have a paid version, you can access the 1 second timeframe and then make your calculation.
Quote
Report
samad hamdast · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: samad hamdast
Original post: https://stackoverflow.com/a/74565514
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
it is so easy.just use predifined variable "Ask".
Use following codes:
{double Price=Ask;
Comment("Ask");}
Quote
Report
Dragon · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Dragon
Original post: https://stackoverflow.com/a/74868305
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
If you want to calculate something, you can do this by
every Tick = OnTick()
every x Seconds = OnTimer()
My code down shows the OnTimer() Event every 1 Second.
//+------------------------------------------------------------------+
//| 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
}
Quote
Report
Post Reply
Checking account access…