Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 934

 
Leo59:
What's wrong? Why are there blue areas left out?




Frankly, I don't dig into other people's codes unless I have to! You'll find everything in the Doc, the help and the database! There's plenty of examples!
 

Could you please tell me how to organise the recalculation of the deposit currency.

My robot calculates the lot based on the balance and funds in the account. But this is, of course, if the deposit is in dollars.

If I open a ruble deposit, then I have to divide the lot by the usdrur rate.

Can I allow my Expert Advisor to look at the deposit currency and, if necessary, divide it by usdrur?

 
neman:

Could you please tell me how to organise the recalculation of the deposit currency.

My robot calculates the lot based on the balance and funds in the account. But this is, of course, if the deposit is in dollars.

If I open a ruble deposit, then I have to divide the lot by the usdrur rate.

Can I allow my Expert Advisor to look at the deposit currency and, if necessary, divide it by usdrur?

Well, AccountCurrency() and based on this form a pair and determine the Bid.
 

I understand that, I just don't know how to write it correctly

For example:


double KursS=iClose("USDRUR",H1,0);

If AccountCurrency() = USD, then K=1;

If AccountCurrency() = RUR, thenK=KursS ;

How do I record this correctly?


 
neman:

I understand that, I just don't know how to write it correctly

For example:


double KursS=iClose("USDRUR",H1,0);

If AccountCurrency() = USD, then K=1;

If AccountCurrency() = RUR, thenK=KursS ;

How do I record this correctly?


You have skipped over it. First of all, you have to define the currency "USDRUR". If your deposit is in euros, you need to set EURUSD rate.

That is, you should define the string K_Symbol = "USDRUR"; provided that the deposit is in rubles.

I think you can figure out how to do it. If the broker opens accounts in other currencies, it would be additional checks.

 
AlexeyVik:

You're the one who skipped over it. First, you have to determine that the currency you want is "USDRUR". If you want to save the deposit in euros, you have to set EURUSD rate.

I.e. to define string K_Symbol = "USDRUR"; on condition that the deposit is in rubles.

I think you can figure out how to do it. If the broker opens accounts in other currencies, it would be additional checks.

In words I understand everything. The question was how to record...

 
neman:

In words I understand everything. The question was how to write it down...


Well, there's everything in our dialogue.

string K_Symbol;

if(AccountCurrency() == "USD") K = 1;
else
if(AccountCurrency() == "RUR")
 {
  K_Symbol = "USDRUR";
  K = iClose(K_Symbol, H1, 0);
 }
else
if(AccountCurrency() == "EUR")
 {
  K_Symbol = "EURUSD";
  K = iClose(K_Symbol, H1, 0);
 }


The second option is a little shorter...

string K_Symbol;

if(AccountCurrency() == "USD") K = 1;
else
 {
  if(AccountCurrency() == "RUR") K_Symbol = "USDRUR";
   if(AccountCurrency() == "EUR") K_Symbol = "EURUSD";
  K = iClose(K_Symbol, H1, 0);
 }


And the third option, for all occasions and all currencies of the deposit, a little more complicated, and I will not make it up, and ready do not have, there was no need to write.

 

Thank you so much!

 
pycha:

If it makes things easier, I'll re-post it correctly. i've written a function for detecting flytags and i stumbled in something that i don't understand. if statement does not work. maybe i wrote something wrong somewhere, i want you to take a fresh look, because i don't understand why. i even recorded a debugger video showing equaling values, but it does not work. please put my brain back into))))




video link https://www.youtube.com/watch?v=k9Zo0SgrMCA



Note that I can't delete the previous post, I copied everything into html and removed the tag that is required to edit the post

Have you heard anything about comparing real numbers?

The solution to the problem was suggested a long time ago and more than once.

I deleted the previous post.

 
Good time, everyone! This question: is it possible to shift indexing of array elements by 1 unit without creating one more similar array and element by element copying information from the first array (and then back) into it? In fact, in MT4 it is somehow done in arrays of timeseries (when a new bar is formed, the index 0 is assigned to it, and the indexes of all previous elements of the array are shifted by 1 unit).
Reason: