
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
This is the correct way to check the base currency. Unfortunately, OP mistitled the thread. The title should have been, "How to check if a symbol is in a list of symbols?"
That's what I use.
live_base = SymbolInfoString(Symbol(),SYMBOL_CURRENCY_BASE);
But I can only find this solution for the quote.
live_quote = StringSubstr(Symbol(), 3, 3);
Why isn't there? SymbolInfoString(Symbol(),SYMBOL_CURRENCY_QUOTE);
I use this to get that character.
last_char = StringSubstr(Symbol(),6);
That's what I use.
live_base = SymbolInfoString(Symbol(),SYMBOL_CURRENCY_BASE);
But I can only find this solution for the quote.
live_quote = StringSubstr(Symbol(), 3, 3);
Why isn't there? SymbolInfoString(Symbol(),SYMBOL_CURRENCY_QUOTE);
The thread is mistitled. OP wants,
"if the currency pair on the current chart is one of those : USDJPY or EURJPY or CADJPY".
The thread is mistitled. OP wants,
Sorry for writting the wrong title.
I did not know there were so many problems.
unfortunately, I am still stuck to the same point, as I really do not know what to write in my code.
Should I create a program that check the name of the symbols an then use those names?
Sorry for writting the wrong title.
I did not know there were so many problems.
unfortunately, I am still stuck to the same point, as I really do not know what to write in my code.
Should I create a program that check the name of the symbols an then use those names?
Did you read my post? I gave you the answer...
Did you read my post? I gave you the answer...
Are you talking about that?
And then, I will know the right format of the symbol?
So I use that and then I can use :
Are you talking about that?
And then, I will know the right format of the symbol?
So I use that and then I can use :
There's a principal in programming called DRY, which means don't repeat yourself. Since you're new I'm sure on the surface it looks more intimidating to make a function instead of writing out our expressions longhand, but what happens when you want to add a few more symbols? What happens when you need to do a similar evaluation with different symbols?
Your code should be as reusable as possible. That's why the problem you are describing has a commonly used design pattern. You add the acceptable values to an array then loop over the array to check if your value is contained within the array. So just to confirm, do you fully understand how the code I shared with you works?
There's a principal in programming called DRY, which means don't repeat yourself. Since you're new I'm sure on the surface it looks more intimidating to make a function instead of writing out our expressions longhand, but what happens when you want to add a few more symbols? What happens when you need to do a similar evaluation with different symbols?
Your code should be as reusable as possible. That's why the problem you are describing has a commonly used design pattern. You add the acceptable values to an array then loop over the array to check if your value is contained within the array. So just to confirm, do you fully understand how the code I shared with you works?
DRY >> I did not know that, and I will try my best to respect it.
I think I understand 95% it but it took me some time.
So, what I understand is:
- that your function check if the currency pair is one of the one allowed.
- that the rest of your code is supposed to print a message saying if it is allowed or not.
What I do not understand is:
- why shouldn't I add the other formats of the symbols such as USDJPYe and USDJPYm.
Here what I wrote.. Does it makes sense?
Thanks for your time and understanding