[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 333

 

Can you give me a hint? There is a button "MQL4.community" in the terminal and clicking on it opens Word with the corresponding page, but when I try to click on any link, a window pops up saying that there is a restriction on my computer! ???

How do you deal with it? Thank you.

 
void start()
  {
  double tickvalue = MarketInfo(Symbol(), MODE_TICKVALUE);
  double profitbuy, profitsell;
  
  for(int i = OrdersTotal()-1; i >= 0;i--)
    {
    if(!OrderSelect(i,SELECT_BY_POS)) continue;
    if(OrderSymbol()!=Symbol() || OrderType() >= 2) continue;
    if(OrderType() == 0)
      profitbuy +=((Bid - OrderOpenPrice())/Point*tickvalue*OrderLots())+OrderCommission()+OrderSwap();
    if(OrderType() == 1)
      profitsell+=((OrderOpenPrice() - Ask)/Point*tickvalue*OrderLots())+OrderCommission()+OrderSwap();
    }
  
  Comment(profitbuy+profitsell);
  }
В чем прикол, не могу правильно рассчитать суммарный профит для всех ордеров по одной паре, в терминале пишет одно, а у меня получается другое?

Итак, мои домыслы, своп в терминале нужно нормализовать обязательно, там точность больше двух бывает - это проверил, но как нормализовать - для каждого ордера или суммарно? Непонятно в общем...
Я уже всяко перепробовал, минимальная разница доходила до 0.02 центов, но это все равно не то, что нужно.

Вопрос, как мне мой код подогнать под работу функции - AccountProfit()?

 
I see what you mean, am I counting wrong? I will explain: I have trades opened only on one pair, I run this script on this pair and it outputs a different result than the one returned by the account profit function. The solution proposed by you does not suit me, because instead of asc and bid I will put the new data, is that clear?
 
fore-x:
Ah see what you mean, am I counting wrong?

No, I meant

Вопрос, как мне мой код подогнать под работу функции - AccountProfit()?

It seems to be well explained there.

And try normalizing the expression (OrderOpenPrice() - Ask)/Point to an integer.

 
Roger:

No, I meant

It seems to be well explained there.

And try normalizing the expression (OrderOpenPrice() - Ask)/Point to an integer

void start()
  {
  double tickvalue = MarketInfo(Symbol(), MODE_TICKVALUE);
  double profitbuy, profitsell;
  
  for(int i = OrdersTotal()-1; i >= 0;i--)
    {
    if(!OrderSelect(i,SELECT_BY_POS)) continue;
    if(OrderSymbol()!=Symbol() || OrderType() >= 2) continue;
    if(OrderType() == 0)
      Alert(
            OrderTicket(),"   ",
            NormalizeDouble(OrderCommission()+OrderSwap(),2),"   ",
            NormalizeDouble(NormalizeDouble((Bid - OrderOpenPrice())/Point,0)*tickvalue*NormalizeDouble(OrderLots(),2),2)
           );
           
    if(OrderType() == 1)
      Alert(
            OrderTicket(),"   ",
            NormalizeDouble(OrderCommission()+OrderSwap(),2),"   ",
            NormalizeDouble(NormalizeDouble((OrderOpenPrice() - Ask)/Point,0)*tickvalue*NormalizeDouble(OrderLots(),2),2)
           );
    }
  }

Не получается, но хоть со спредом вопрос отпал!
 
What's not working out? Where is the discrepancy?
 
Roger:
What's not working out? Where is the discrepancy?


Or is it my alert that's frozen and yours that's not?
 
fore-x:


And you, did it add up?
Are you suggesting that I should also whip up a quick advisor and start checking it out? Well, fire me, I'd rather do it virtually.
 
Roger:
What's not working? Where is the discrepancy?

I switched the ask and bid, and now it's like this:


That's better :)))