I'm trying to get the current quote for a symbol not in current window. Unfortunately it doesn't work.
I have tried with iClose(mySymbolString, 0, 0), MarketInfo(mySymbolString, MODE_BID), and even SymbolInfoDouble(mySymbolString, SYMBOL_BID).
What I have tried so far:
1.- Any of the 3 above mentioned functions work when using Symbol() (that means, it works with symbol in current chart), but not with other Symbols NOT in current chart.
2.- When using iClose with a symbol NOT using Symbol() (even if the symbol is in current chart!) , but part of "Market Watch", then I get the quote BUT without decimals! (example: EURJPY should be 138.78, but I get 13878 (without decimal))
3.- For MarketInfo() and SymbolInfoDouble(), what I get is just "0", even when using a string with the symbol in current window.
My EA code:
Please show the excerpt from the log file . . . and then repeat with your code moved from init() to start() and show the excerpt from the log file again.
Please show the excerpt from the log file . . . and then repeat with your code moved from init() to start() and show the excerpt from the log file again.
I execute the code as an script.
One more info: my compiler version:
MQL4/MQL5 Compiler build 914 (21 Mar 2014)
my MetaTrader 4 version:
Version: 4.00 Build 646 (30 Apr 2014)
With the same code (copy-paste) in both, start() and init() + "Hello/Goodbye, from ..." messages to identify where it is being called:
Terminal > Journal Tab output:
2014.06.26 08:05:48.559 Script g_test EURUSDdd,H4: removed
2014.06.26 08:05:48.515 Script a_active\g_test EURUSDdd,H4: loaded successfully
Terminal > Experts Tab output:
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: uninit reason 0
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: Goodbye, from start()
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: --
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 80250
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 121677
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 138781
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 136365
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 1.3636
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 1.3636
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.558 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 1.3636
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 80250 <-- YYYY
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 121856 <-- YYYY
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 138781 <-- YYYY
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 136365 <-- YYYY
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 1.3633 <-- YYYY
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 1.3633 <-- YYYY
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: Hello, from start()
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: initialized
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: --
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: Goodbye, from init()
2014.06.26 08:05:48.557 g_test EURUSDdd,H4: 80250
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 121677
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 138781
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 136365
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 1.3636
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 1.3636
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 0
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 1.3636
2014.06.26 08:05:48.556 g_test EURUSDdd,H4: 80250 <-- YYYY
2014.06.26 08:05:48.551 g_test EURUSDdd,H4: 121856 <-- YYYY
2014.06.26 08:05:48.549 g_test EURUSDdd,H4: 138781 <-- YYYY
2014.06.26 08:05:48.546 g_test EURUSDdd,H4: 136365 <-- YYYY
2014.06.26 08:05:48.541 g_test EURUSDdd,H4: 1.3633 <-- YYYY
2014.06.26 08:05:48.541 g_test EURUSDdd,H4: 1.3633 <-- YYYY
2014.06.26 08:05:48.540 g_test EURUSDdd,H4: Hello, from init()
2014.06.26 08:05:48.515 Script a_active\g_test EURUSDdd,H4: loaded successfully
indicators "can not" open or close orders
I'm aware of that.
iClose https://docs.mql4.com/series/iclose doesn't try to open / close orders, just get the close price (or the latest bid price if current bar is used).
This code is not for an indicator, as there are no macros:
#property indicator_separate_window // or #property indicator_chart_window
Print(iClose("EURGBP", NULL, 0));
or
Print(iClose("EURGBP", Period(), 0));
or
Good try! But unfortunately it doesn't work either ...
But did you try to run the code in your computer just to see if you get the same results? If it works in yours, then I'll have to dig into how my mt4 is installed, because I don't see where is the problem in the code ...
By the way, I run it as an script. That's what I'm working on
Good try! But unfortunately it doesn't work either ...
But did you try to run the code in your computer just to see if you get the same results? If it works in yours, then I'll have to dig into how my mt4 is installed, because I don't see where is the problem in the code ...
By the way, I run it as an script. That's what I'm working on
Solved. Thanks.
I have mt4 installed twice in 2 different directories: default one and another. When running the script with default, using iClose works. When using the other installation not. All other scripts that I have work great on both. I also use hard links between them, so each installation is always up to date. As I said, iClose only works with script and mt4 are installed in the default directory.
Again, thanks for taking your time to review.
Solved. Thanks.
I have mt4 installed twice in 2 different directories: default one and another. When running the script with default, using iClose works. When using the other installation not. All other scripts that I have work great on both. I also use hard links between them, so each installation is always up to date. As I said, iClose only works with script and mt4 are installed in the default directory.
Again, thanks for taking your time to review.
UPDATE - Final Answer: the problem end up being wrong info when using a demo server (just a specific demo server, all other demo servers provide right data). All functions (iClose(), MarketInfo() and SymbolInfoDouble()) do their job as expected, even if mt4 installed multiple times in different directories. (I tested it after a clean OS installation installing mt4 twice on 2 different directories).
It is also important to remember to add to MarketWatch window, the symbols that are going to be queried.
UPDATE - Final Answer: the problem end up being wrong info when using a demo server (just a specific demo server, all other demo servers provide right data). All functions (iClose(), MarketInfo() and SymbolInfoDouble()) do their job as expected, even if mt4 installed multiple times in different directories. (I tested it after a clean OS installation installing mt4 twice on 2 different directories).
It is also important to remember to add to MarketWatch window, the symbols that are going to be queried.
That was going to be my suggestion to the issue.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm trying to get the current quote for a symbol not in current window. Unfortunately it doesn't work.
I have tried with iClose(mySymbolString, 0, 0), MarketInfo(mySymbolString, MODE_BID), and even SymbolInfoDouble(mySymbolString, SYMBOL_BID).
What I have tried so far:
1.- Any of the 3 above mentioned functions work when using Symbol() (that means, it works with symbol in current chart), but not with other Symbols NOT in current chart.
2.- When using iClose with a symbol NOT using Symbol() (even if the symbol is in current chart!) , but part of "Market Watch", then I get the quote BUT without decimals! (example: EURJPY should be 138.78, but I get 13878 (without decimal))
3.- For MarketInfo() and SymbolInfoDouble(), what I get is just "0", even when using a string with the symbol in current window.
My EA code: