sergey1294: ...it is not mentioned in the help, that for successful work of this function it is necessary for the tool to be present in the MarketWatch window
The help really needs to be staffed with normal examples and bottlenecks.
PS
Also, there are often situations where, after making changes in the language, some EAs from the base stop working (or generate compilation errors).
This is probably for those symbols that are not present in MarketWatch, as for SymbolName it says:
Output the name of the symbol for which you get an unexpected result and compare it to the list in MarketWatch.
For symbols that are not present in MarketWatch, SymbolInfoTick() returns an error ERR_MARKET_SELECT_ERROR "Symbol not selected in MarketWatch" (code 4302). Only EURUSD and GBPUSD are selected in MarketWatch. An elementary run shows that SymbolInfoTick() returns an error ERR_MARKET_SELECT_ERRORfor unselected symbols :
IS 01 (EURUSD,M15) 01:53:21 ************************************************
MF 01 (EURUSD,M15) 01:53:21 Инструмент - EURUSD
RR 01 (EURUSD,M15) 01:53:21 Валюта депозита = USD
RG 01 (EURUSD,M15) 01:53:21 Базовая валюта = EUR
QM 01 (EURUSD,M15) 01:53:21 Валюта маржи = EUR
CH 01 (EURUSD,M15) 01:53:21 Маржа для покупки = 1271.23
QG 01 (EURUSD,M15) 01:53:21 Маржа для продажи = 1271.05
CQ 01 (EURUSD,M15) 01:53:21 ************************************************
JQ 01 (EURUSD,M15) 01:53:21 Инструмент - GBPUSD
HQ 01 (EURUSD,M15) 01:53:21 Валюта депозита = USD
EH 01 (EURUSD,M15) 01:53:21 Базовая валюта = GBP
RN 01 (EURUSD,M15) 01:53:21 Валюта маржи = GBP
MI 01 (EURUSD,M15) 01:53:21 Маржа для покупки = 1553.53
DP 01 (EURUSD,M15) 01:53:21 Маржа для продажи = 1553.25
MG 01 (EURUSD,M15) 01:53:21 ************************************************
LR 01 (EURUSD,M15) 01:53:21 Инструмент - USDCHF
NG 01 (EURUSD,M15) 01:53:21 Валюта депозита = USD
NJ 01 (EURUSD,M15) 01:53:21 Базовая валюта = USD
EQ 01 (EURUSD,M15) 01:53:21 Валюта маржи = USD
RI 01 (EURUSD,M15) 01:53:21SymbolInfoTick() failed, error = 4302
GL 01 (EURUSD,M15) 01:53:21 ************************************************
PE 01 (EURUSD,M15) 01:53:21 Инструмент - USDJPY
DL 01 (EURUSD,M15) 01:53:21 Валюта депозита = USD
DF 01 (EURUSD,M15) 01:53:21 Базовая валюта = USD
OL 01 (EURUSD,M15) 01:53:21 Валюта маржи = USD
HL 01 (EURUSD,M15) 01:53:21SymbolInfoTick() failed, error = 4302
QH 01 (EURUSD,M15) 01:53:21 ************************************************
...
By the way, the last data block in sergey1294's log is different from the others: first, SymbolInfoTick() returns the same error code this time, and second, - don't you think that the instrument, base currency and margin currency have some strange names in this data block?
Is this a bug? Have you noticed this weirdness at all?
CE 0OrderCalcMargin (EURUSD,M1) 20:44:27 ************************************************
IG 0OrderCalcMargin (EURUSD,M1) 20:44:27 Инструмент -
LS 0OrderCalcMargin (EURUSD,M1) 20:44:27 Валюта депозита = USD
DD 0OrderCalcMargin (EURUSD,M1) 20:44:27 Базовая валюта =
CL 0OrderCalcMargin (EURUSD,M1) 20:44:27 Валюта маржи =
RG 0OrderCalcMargin (EURUSD,M1) 20:44:27SymbolInfoTick() failed, error = 4302
As for the last block of data, this is just a bit of a glitch in the loop, and in the last data query it accessed a non-existent instrument, so all fields except the deposit currency are empty
sergey1294: As for the last data block, it's just the brute force loop glitched a bit and in the last data query accessed a non-existing symbol, so all fields except deposit currency are empty
How is this? I mean, the log is not from the version of the code that was given?
Judging by the code, everything is fine there.
Or SymbolsTotal() returned one value, but during the script run, somewhere in the middle of the cycle, by a terrible accident, the broker, setting the server part, removed one symbol from available, and the SymbolsTotal() - if the script requested it - would return a new value, one less, but, since the loop end condition was based on the old value stored in the Total variable, then the corresponding functions at the last iteration when accessing the now non-existing symbol returned empty lines? :)
So far, only this scenario came up to make this happen. :)
... Then the calculated value is explicitly converted to ulong. Exactly to ulong, because there is a guarantee that the value to be casted is non-negative.
While being cast to an integer type, the fractional part of the real type is discarded. It is not rounding to the nearest one, but precisely the throwing away of the fractional part that guarantees non-increasing of maximum lots' value, which free margin allows. That is exactly what we need.
Simpleton, I also followed a similar way, but used an explicit conversion to int type. I assumed that the maximum possible lot size will be limited either by broker/dealer, or by the size of my own funds. So using int should be enough. Do you think there are any pitfalls with this approach (rounding "from below" using int)?
This is probably for those symbols that are not in MarketWatch, as it says for SymbolName:
Output the name of the symbol for which you get an unexpected result and compare with the list in MarketWatch....it is not mentioned in the help, that for successful work of this function it is necessary for the tool to be present in the MarketWatch window
The help really needs to be staffed with normal examples and bottlenecks.
PS
Also, there are often situations where, after making changes in the language, some EAs from the base stop working (or generate compilation errors).
Noticed today...MT5(access.metatrader5.com:443)
EURJPY, Daily:
For example GBPJPY, Daily: Everything is fine here.
And here is a screenshot of EURJPY, Daily of one MT4 DC:
The difference is visible to the naked eye....
How can this be fixed?
This is probably for those symbols that are not present in MarketWatch, as for SymbolName it says:
Output the name of the symbol for which you get an unexpected result and compare it to the list in MarketWatch.For symbols that are not present in MarketWatch, SymbolInfoTick() returns an error ERR_MARKET_SELECT_ERROR "Symbol not selected in MarketWatch" (code 4302). Only EURUSD and GBPUSD are selected in MarketWatch. An elementary run shows that SymbolInfoTick() returns an error ERR_MARKET_SELECT_ERRORfor unselected symbols :
By the way, the last data block in sergey1294's log is different from the others: first, SymbolInfoTick() returns the same error code this time, and second, - don't you think that the instrument, base currency and margin currency have some strange names in this data block?
Is this a bug? Have you noticed this weirdness at all?
As for the last data block, it's just the brute force loop glitched a bit and in the last data query accessed a non-existing symbol, so all fields except deposit currency are empty
How is this? I mean, the log is not from the version of the code that was given?
Judging by the code, everything is fine there.
Or SymbolsTotal() returned one value, but during the script run, somewhere in the middle of the cycle, by a terrible accident, the broker, setting the server part, removed one symbol from available, and the SymbolsTotal() - if the script requested it - would return a new value, one less, but, since the loop end condition was based on the old value stored in the Total variable, then the corresponding functions at the last iteration when accessing the now non-existing symbol returned empty lines? :)
So far, only this scenario came up to make this happen. :)
... Then the calculated value is explicitly converted to ulong. Exactly to ulong, because there is a guarantee that the value to be casted is non-negative.
While being cast to an integer type, the fractional part of the real type is discarded. It is not rounding to the nearest one, but precisely the throwing away of the fractional part that guarantees non-increasing of maximum lots' value, which free margin allows. That is exactly what we need.
Developers.
How do I make parameters appear in the scripts (I'm too lazy to constantly change the code for new conditions)...?
Developers.
How do I make parameters appear in the scripts (I'm too lazy to constantly change the code for new conditions)...?
#property script_show_inputs