Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 996
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What you are trying to print is not correct. The correct way is this.
Here's the breakdown:
42 is a numerical identifier: ACCOUNT_MARGIN_FREE
i.e. we can get the free margin from the constant
Or by its numeric identifier:
AccountInfoDouble(42)
Thank you!
Here's the breakdown:
42 is a numerical identifier: ACCOUNT_MARGIN_FREE
i.e. we can get the free margin from the constant
Or by its numeric identifier:
Thank you!
The first version of writing is more informative.
https://www.mql5.com/ru/docs/constants/environment_state/marketinfoconstants
This is probably a silly question, but can these functions be used in MQL4? It's just that MQL4 tools are more limited.
How to get the data in MQL4:
SYMBOL_SESSION_DEALS
Number of trades in the current session
SYMBOL_SESSION_BUY_ORDERS
Total number of buy orders at the moment
long
SYMBOL_SESSION_SELL_ORDERS
Total number of sell orders at the moment
long
SYMBOL_VOLUME
Volume - Volume of the last trade
long
SYMBOL_VOLUMEHIGH
Maximum Volume for the day
long
SYMBOL_VOLUMELOW
Minimum Volume for the day
SYMBOL_BID
Bid - best bid
double
SYMBOL_BIDHIGH
Maximum Bid for the day
double
SYMBOL_BIDLOW
Minimum Bid for the day
double
SYMBOL_ASK
Ask - best bid
double
SYMBOL_ASKHIGH
Maximum Ask for the day
double
SYMBOL_ASKLOW
Minimum Ask for the day
SYMBOL_SESSION_VOLUME
Total volume of trades in the current session
double
SYMBOL_SESSION_TURNOVER
Total turnover in the current session
double
SYMBOL_SESSION_INTEREST
Total volume of open positions
double
SYMBOL_SESSION_BUY_ORDERS_VOLUME
Total volume of buy orders at the moment
double
SYMBOL_SESSION_SELL_ORDERS_VOLUME
Total volume of sell orders at the moment
double
SYMBOL_SESSION_OPEN
Session open price
double
SYMBOL_SESSION_CLOSE
Close price
double
It's a treasure trove of useful data in one go. The only question is how to do it in MQL4. Since MQL5 has a wider functionality, someone may ask, why I'm not studying MQL5. It's simple. Not all brokers support it. At the moment MQL4 is still the most popular and in demand.
https://www.mql5.com/ru/docs/constants/environment_state/marketinfoconstants
This is probably a silly question, but can these functions be used in MQL4? It's just that MQL4 tools are more limited.
How to get data in MQL4:
It's a treasure trove of useful data in one click. But how to do it in MQL4. This article will also contain some tips on how to prepare MQL5 for studying in MQL5. It's simple. Not all brokers support it. At the moment MQL4 is still the most popular and in demand.
In the documentation of mql4 all that do not work are marked.
SYMBOL_BID
Bid - best bid
double
SYMBOL_BIDHIGH
Not supported
double
SYMBOL_BIDLOW
Not supported
double
SYMBOL_ASK
Ask - best offer to buy
double
SYMBOL_ASKHIGH
Not supported
double
SYMBOL_ASKLOW
Not supported
double
SYMBOL_LAST
Not supported
double
SYMBOL_LASTHIGH
Not supported
double
SYMBOL_LASTLOW
Not supported
double
SYMBOL_POINT
Single point value
double
This is not the whole table. There is more than one in the documentation, you just have to press F1 and read it.
In the mql4 documentation all those that don't work are marked.
Log lines:
2019.11.16 12:38:40.660 2019.01.02:35:00 To calculate stops, take value from broker = 30
2019.11.16 13:20:18.791 2019.01.02:03:00 Open an order: Price = 1.14595, Stop Loss = 1.14565, Take Profit = 1.14625
2019.11.16 13:20:18.791 2019.01.02 02:03:00 failed instant buy 0.01 EURUSD at 1.14595 sl: 1.14565 tp: 1.14625 [invalid stops]
2019.11.16 13:20:18.792 2019.01.02:03:00 CTrade::OrderSend: instant buy 0.01 EURUSD at 1.14595 sl: 1.14565 tp: 1.14625 [invalid stops]
And now a little clarity for this case:
In the code before opening an order I calculate:
price = best market price to buy, depending on the order, in this case a buy.
SL = calculate a right stop (the broker allows a stop of at least 30 units from the price) i.e.
price (1.14595) - 0.0003 = SL (1.14565)
TP = calculate a right stop (the broker allows a stop of at least 30 units from the price) i.e.
price (1.14595) + 0.0003 = TP (1.14625)
Well everything looks correct, I hold 30 points, but I get a setting error.
If we set SL = 0, then everything is OK, order and TP are set.
I get an error in calculation of SL, where is the error?
Help me understand, I can't get the stop loss set correctly.
Log lines:
2019.11.16 12:38:40.660 2019.01.02 02:35:00 To calculate stops, take value from broker = 30
2019.11.16 13:20:18.791 2019.01.02 02:03:00 Open an order: Price = 1.14595, Stop Loss = 1.14565, Take Profit = 1.14625
2019.11.16 13:20:18.791 2019.01.02 02:03:00 failed instant buy 0.01 EURUSD at 1.14595 sl: 1.14565 tp: 1.14625 [Invalid stops]
2019.11.16 13:20:18.792 2019.01.02 02:03:00 CTrade::OrderSend: instant buy 0.01 EURUSD at 1.14595 sl: 1.14565 tp: 1.14625 [invalid stops]
And now some clarity for this case:
In the code I calculate before opening an order:
price = best market price to buy, depending on the order, in this case a buy.
SL = calculate a right stop (the broker allows stops at least 30 units away from the price), i.e.
price (1.14595) - 0.0003 = SL (1.14565)
TP = Calculate correct stop (broker allows stops at least 30 units away from price) i.e.
price (1.14595) + 0.0003 = TP (1.14625)
Well, everything seems to be right, I hold 30 pips, but I get a setting error.
We set SL = 0, then everything is OK, order and TP are set.
It turns out to be an error in calculation of SL, where is the error?
what type of price ?
what type of price ?
When buying Price = SYMBOL_ASK
On sale Price = SYMBOL_BID
When buying Price = SYMBOL_ASK
When selling Price = SYMBOL_BID
Have you tried adding a spread?
Have you tried adding a spread?
Fixed it this way: