Can you please tell me why my code doesn't set vol and ask? The value zero is always displayed in Print. Spread is "clamping" normally, it shows the correct value.
Can you please tell me why my code doesn't set vol and ask? The value zero is always displayed in Print. Spread is "clamping" normally, it shows the correct value.
I attach EA to LTCUSD chart.
What is the error?
You should apply either CSymbolInfo::Refresh or CSymbolInfo::RefreshRates method before getting it - depending on what you need.
Maybe you can also suggest: how to get a symbol name usingCSymbolInfo Name method? When I try to do it this way
I get a boolean value true in the name variable.
I do so - I initialize variable of CSymbolInfo class.
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//---
***
if(!m_symbol.Name(Symbol())) // sets symbol name
{
Print(__FILE__," ",__FUNCTION__,", ERROR: CSymbolInfo.Name");
return(INIT_FAILED);
}
RefreshRates();
***
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Refreshes the symbol quotes data |//+------------------------------------------------------------------+bool RefreshRates()
{
//--- refresh ratesif(!m_symbol.RefreshRates())
{
if(InpPrintLog)
Print(__FILE__," ",__FUNCTION__,", ERROR: ","RefreshRates error");
return(false);
}
//--- protection against the return value of "zero"if(m_symbol.Ask()==0 || m_symbol.Bid()==0)
{
if(InpPrintLog)
Print(__FILE__," ",__FUNCTION__,", ERROR: ","Ask == 0.0 OR Bid == 0.0");
return(false);
}
//---return(true);
}
If you want to get a name (for example when comparing position symbol with current symbol), you need to use CSymbolInfo::Name() method.
Example usage:
//+------------------------------------------------------------------+//| Is position exists |//+------------------------------------------------------------------+bool IsPositionExists(void)
{
for(int i=PositionsTotal()-1; i>=0; i--)
if(m_position.SelectByIndex(i)) // selects the position by index for further access to its propertiesif(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==InpMagic)
return(true);
//---return(false);
}
The help shows two forms of calling the Name method
Name
Gets the name of financial instrument.
string Name() const
Returned value
Name of financial instrument.
Name
Sets the name of the financial instrument for further work with it.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I dont know how to open a demo account.
I'm on android.
MetaQuotes is not a broker - therefore you can only open a demo account on MetaQuotes-Demo servers.
A real trading account must be opened with a broker.
Hi connoisseurs !
Can you please tell me why my code doesn't set vol and ask? The value zero is always displayed in Print. Spread is "clamping" normally, it shows the correct value.
I attach EA to LTCUSD chart.
What is the error?
Hi connoisseurs !
Can you please tell me why my code doesn't set vol and ask? The value zero is always displayed in Print. Spread is "clamping" normally, it shows the correct value.
I attach EA to LTCUSD chart.
What is the error?
You should apply either CSymbolInfo::Refresh or CSymbolInfo::RefreshRates method before getting it - depending on what you need.
Here is the code of these functions:
You must apply either CSymbolInfo::Refresh or CSymbolInfo::RefreshRates method before getting - depending on what you need
Thank you very much, dear Vladimir!
Maybe you can also tell me how to get the symbol name with theCSymbolInfo Name method? When I try to do so
I get a boolean value true in the name variable.
Thank you very much, dear Vladimir!
Maybe you can also suggest: how to get a symbol name usingCSymbolInfo Name method? When I try to do it this way
I get a boolean value true in the name variable.
I do so - I initialize variable of CSymbolInfo class.
If you want to get a name (for example when comparing position symbol with current symbol), you need to use CSymbolInfo::Name() method.
Example usage:
The help shows two forms of calling the Name method
Name
Gets the name of financial instrument.
Returned value
Name
Sets the name of the financial instrument for further work with it.
Returned value
If you want to get a name (e.g. when comparing a position symbol to the current symbol), you need to use the CSymbolInfo::Name() method.
Example usage:
The help shows two forms of calling the Name method
Name
Gets the name of financial instrument.
Returned value
I have a question on this form of method Name.
HOW do I get instrument's NAME in the variable? Because doing it this way:
I get boolean true inname. How to get a string with name of the instrument in it, usingmethod CSymbolInfo::Name() ?
I have a question about this particular form of the Name method.
HOW do I get tool's NAME into a variable? Because doing this:
I get a boolean true inname. How do I get a string with tool name in it, usingCSymbolInfo::Name()method?
First we INITIALIZE it. Then we use method Name().
We run the code on the '' character.
Result:
1 (EURUSD,H1) текущий символ: EURUSDFirst we INITIALIZE. Then we use the Name() method.
Run the code on the '' character.
Result:
Got it. Thanks for your patience )).
PS: my compiler is blaming return in your code. When I removed it, everything is fine.
Got it. Thanks for your patience )).
PS: my compiler is blaming return in your code. When I removed it, it's fine.
This is a script (I gave an example of a script), not an EA. If you copied my code into EA, there will be an error.