Errors, bugs, questions - page 2137

 

Error when reading the profit (or am I already misunderstanding something).

There is a function within the EA:

bool Fn_profit_summ(double &profit_summ, bool is_buy, ulong magic, bool prnt=false){
   profit_summ = 0;
   string str=(is_buy?"B":"S")+" -> "; 
   //-----------------------------             
   int total = PositionsTotal();          
   for(int i=total-1; i>=0; i--){
      const ulong tic= PositionGetTicket(i); if(tic<=0)     return(false); //--- asinchr
      if(!PositionSelectByTicket(tic)                   )   return(false); //--- asinchr 
      bool is_buy_ = (PositionGetInteger(POSITION_TYPE  )==POSITION_TYPE_BUY); 
      if( is_buy_                             !=  is_buy)   continue; 
      if( PositionGetInteger(POSITION_MAGIC ) !=  magic )   continue;
      if( PositionGetSymbol (POSITION_SYMBOL) != _Symbol)   continue;
      profit_summ += PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP);
      str+=IntegerToString(tic)+" - "+DoubleToString((PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP)), 2)+"/";
      }
   //-----------------------------
   if( prnt) Print(str+" --> "+DoubleToString(profit_summ, 2));
   return(true);}

I can see in the log:

2018.02.21 01:44:04.315 2018.02.14 04:59:49   S -> 273 - -5.62/ --> -5.62

That would be OK, but it's a buy order profit, not a sell order

The ticket is exactly for a Sell order (273, as in the log)


I thought I checked in the function and the same type was considered correctly, but the profit is really not the same. If it is true, then it is the apocalypse - the client closes Sell and Buy positions separately upon reaching specified profit/loss and it constantly closes Sell, because it takes a Buy profit. The same way the deposit may be unwittingly drained

(If I overworked and am already imagining things - correct me, please. I sincerely hope that this is true and there is no such a critical bug)

 
Galina Bobro:

Error when reading the profit (or am I already misunderstanding something).

There is a function within the EA:

I can see in the log:

That would be OK, but it's a buy order profit, not a sell order

The ticket is exactly for a Sell order (273, as in the log)


I thought I checked in the function and the same type was considered correctly, but the profit is really not the same. If it is true, then it is the apocalypse - the client closes Sell and Buy positions separately upon reaching specified profit/loss and it constantly closes Sell, because it takes a Buy profit. The same way the deposit may be unwittingly drained

(If I overworked and am already imagining things - correct me, please. I sincerely hope that this is true and there is no such a critical bug)

string str=(! is_buy?"B":"S")+" -> ";
 
Kirill Belousov:
What is this about? Why would I want "if bye withdraw S"?
 

I often work with custom characters. For example, I need to conduct debugging on one of these. This requires entering its name here


But the names of custom characters (and not just custom characters) can be long/complex, which makes it hard to type them in from the keyboard. Mechanism of copying the name of the symbol to the buffer is nowhere. Therefore, I propose to add to this menu item "Copy symbol name".


ZZY Add milliseconds to the Tester Visualizer, please!

 
fxsaber:

ZS Add milliseconds to the Tester Visualiser, please!

Add

 

Error during execution

struct A {
template<typename T>
        void Print(   T t ) { ::Print( 2 ); }
        ~A() { Print( 1 ); }
};
void OnStart() { A a; }

Result : 1

Expected : 2

 
A100:

Expected: void A::Print<int>(int):1

This is most likely due to the cunning nature of the regular Print. You may also overload iCustom in the same way. I think it will produce the same result.

The namespace for Print, Comment, Alert, iCustom, ... - something special, it seems.

 
fxsaber:

Most likely has to do with the tricky nature of in-house Print.

Not related.

void Print2( int )           { Print( 1 ); }
struct A {
template<typename T>
        void Print2(   T t ) { Print( 2 ); }
        ~A() { Print2( 1 ); }
};
void OnStart() { A a; }

Same result.

 

SymbolInfoTick for custom symbols produces an empty tick (when no CustomTicksAdd has been made), even when there are ticks in History.

I suggest that on Terminal side, after any CustomTicksReplace the last tick (or just its time) in History should be a SymbolInfoTick.


Please advise the developers on this matter, who should this action logically hang on - the Terminal or a User?

I think the Terminal, because it will save the User from occasional bugs in his code (caught one).

Now, for example, lately a symbol has to be found like this

  ulong GetOriginalLastTime( void ) const
  {
    MqlTick Tick[1] = {0};

    ::SymbolInfoTick(this.Symb, Tick[0]);
    
    if (!Tick[0].time_msc)
      ::CopyTicks(this.Symb, Tick, COPY_TICKS_ALL, 0, 1);

    return(Tick[0].time_msc);
  }
 
A100:

Not related.

The result is the same

Yes, it's a bug. Never encountered it, as I always attribute this to methods.