[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 317

 

help! or explain! why this function does not count the current state of the account: it outputs zero

double Profit() {
   double k1=0; int k2;
   datetime dlast;
   if (dlast!=TimeSeconds(TimeCurrent())) {
   for (k2=OrdersTotal(); k2<0; k2--) {
     if (OrderSelect(k2, SELECT_BY_POS,MODE_TRADES)) {
            if (OrderType()<2 && OrderSymbol()==Symbol() && OrderCloseTime()==0 && OrderMagicNumber()==MG) {
               k1=k1+OrderProfit(); 
               } 
            }
   }
   dlast=TimeSeconds(TimeCurrent());
   
   }
   return(k1); 
   //Print(k1);    
}
 

Hello everyone!

Can you please tell me what the problem is? When I try to place one pending order, I get 2.

while (Ticket2<0)

{

RefreshRates();

Ticket2=OrderSend(Symbol(),2,Lots_New*2,price,2,0,TP,"",MN); //1 order is pending Buy

Alert ("Error in Cycle",GetLastError()); Alert ("TIK2= ",Ticket2;)

Sleep(500);

}


 
paibolit:

Help - the situation has been taken to the point of absurdity !!!

When running this piece of code, the whole log is flooded with this:

Error 1 error appears when trying to change TP value equal to tpb or tps value, but why the line in the code

allows to do this ?????!!!!!!!!!


Question cleared - solved
 
todem:

help! or explain! why this function does not count the current state of the account: it outputs zero

question removed, it's solved.
 

I'm sorry if I'm not clear about what I wrote, but I'm still a beginner. I'm sorry if I didn't write it clearly, I'm just a newbie.

 

How can I programmatically remove the marks (arrows) set at the opening and closing of positions?

 
charter:

How can I programmatically remove the marks (arrows) set at the opening and closing of positions?


Wouldn't it be easier not to?
 
charter:

How can I programmatically remove the marks (arrows) set at the opening and closing of positions?

arrows are objects, so see how to work with objects.
 
Roger:

Wouldn't it be easier not to?


You should.))

But the spent ones have to be removed. It gets in the way.

 
sergeev:
arrows are objects, so see object work.

Now we'll try it.)))