[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 287

 
rid писал(а) >>

Such a fix will not work. It will not be able to open the very first trade. Because the condition for opening the very first trade in your variant is to close any previous trade at take or stop!

I.e., it is a vicious circle.

So, the logic of work should be changed.

 
Let me ask you a question. In the 5th trinder, will there be such a thing as a class (OOP)?
 

Can you give me a solution on how to calculate the value of the first N digits of an integer variable?

Only through conversion to string?

 
goldtrader >> :

Can you give me a solution on how to calculate the value of the first N digits of an integer variable?

What number system is it in? In decimal?

Only through conversion to string?

No of course not.

 
TheXpert писал(а) >>

Digits in what number system? Decimal?

Yes, in decimal.

I do so: int -> double -> string -> Substr -> compare.

It works, but it looks somehow awkward, rustic. I would like it more elegantly ))))

 
goldtrader >> :

Yes, in decimal.

I do so: int -> double -> string -> Substr -> compare.

It works, but it looks somehow distorted and rustic. I would like it more elegantly ))))

//+------------------------------------------------------------------+
//|                                                NElementsTest.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, TheXpert"
#property link      "theforexpert@gmail.com"

int FirstN(int N, int value)
{
   int value_ = value;
   
   int length = 0;
   
   while( value_ != 0) 
   {
      value_ /= 10;
      length++;   
   }
   
   int toDivide = MathMax( length - N, 0);
   return ( value/NormalizeDouble(MathPow(10, toDivide), 0));
}

void Out(int N, int value)
{
   Print("Value = ", value, " , First ", N, " = ", FirstN( N, value));
}

int start()
{
   Out(5, 12345678);
   Out(1, 12345678);
   Out(6, 12345);
   Out(5, -1234567);

   return(0);
}
MathPow is slow, it would be a good idea to replace it, but it should be faster than strings.
 
TheXpert писал(а) >>
MathPow is slow, it would be a good idea to replace it, but it should be faster than strings.

I've just started using MathPow. I'd like to clarify... How slow is it? When should I start replacing x^2 = x*x ? And is it worth replacing if the degree is "not great"... or "high"...?

 
TheXpert писал(а) >>
MathPow -- the thing is slow, it would be desirable to replace it, but it should be faster than strings.

Thank you, Andrew!

It's really programmatic!

 
Rosh >> :

If MetaTrader 4 had been "customised for DCs", as you say, it would not have been so popular with traders. Such rumours can only be spread to justify their own software.

100 points! There is a lot of demand on the market, but supply exceeds demand and it is obvious that the new brokerage companies use different tricks to attract clients and get the highest yield from them.

 
DDFedor >> :

I've just started using MathPow. I'd like to clarify... How slow is it? When should I start replacing x^2 = x*x ? And is it worth replacing if the degree is "not great"... or "high"...?

Tut. The expression you quoted is definitely worth it.

goldtrader >> :

>> Thank you, Andrew!

Glad to be of help.

Reason: