[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 506

 
MaxZ:
What if a trade was opened manually!? Or the terminal was reloaded!? In fact, this condition is suitable only for TF D1.

iTime( ) is valid for any TF, unlike Time[ ] :))
 
borilunad:

iTime( ) is good for any TF, unlike Time[ ] :))

I figured it out myself... About TF I deleted my own argument! ;) Read a new one! :D

 
MaxZ:

Perhaps... Loki have always been and always will be a profiteer for DCs. Otherwise they'd all be banned! :DD

Although in the case under discussion you could argue, but I don't feel like it.

You'd better tell me if you know if there are such accounts in MT4!? :)))


If I'm not mistaken, interbankfh releases margin on opening counter accounts.
 
VladislavVG:

If I am not mistaken, interbankfh exempts the margin on opening a counter.
F4U does too... They have a feature called "locked margin". Only, as I know, you cannot open such a lock either, if the available funds are in deficit.
 
MaxZ:

What if there is a manual transaction open!?

There is no need to use the wrong handles and break the logic of the TS.

Choose one or the other:

  1. Crooked handles
  2. Semi-automatic, i.e. the automation signals, the trader executes.
  3. Autotrading

If you do not need it, cross it out.

 
MaxZ:

I figured it out myself... About TF Your argument deleted! ;) Read the new argument! :D

Agreed! It's good to have all the conditions and solve them all together!

If I don't need to open more than one, I also use ExistPosts() from KimIV, but that works as long as the position is not closed!

 
borilunad:

I agree! It's good to have all the conditions and solve them all together!

If I don't need to open more than one, I also use ExistPostions() from KimIV, but that works until the position is closed!

All in all, it's worked out! :))) Oh, and Man Us wrote a thank you! :)

But this remains unclear:

MaxZ:

Are there any MT4 accounts, where you can open a lock with negative equity? I am asking this question for the sake of interest. The dispute arose on another forum. I am told that such accounts do exist! :DD

So that there are no unnecessary questions, here's an example:

You have opened one trade with volume N. Your terminal says after the line "Free:": "-XXX.XX"... Would you be able to open a lock with volume N!? I don't think so in a regular account... And I was told that there are some special accounts! :)))))) I don't believe it...

 
MaxZ:

Anyway, it's sorted! :))) Oh, and Man Us wrote thank you! :)

This, however, remains unclear:



And I don't believe it! Is Uncle Kolya resting there?

It's normal, if the account is in deficit, all positions are closed by force. Another thing is if you managed to open a loss, because the margin for the loss does not increase, while in the same direction you cannot even open a pending position.

 

Dear Professionals, help with the functions. I have two functions (not mine) which I use to calculate current profit (loss) on a pair in open orders, look like this:

double PPLot;//(в глобальных настройках)
//----------------------------------------------------------------------
//Вспомогательная функция для расчета общей прибыли (убытка) по паре
double Auto_Points()
{
  if(Digits==5 || Digits==3){
    PPLot=10*MarketInfo(Symbol(),MODE_TICKVALUE);
    return(Point*10.0);
  }
  else{
    PPLot=MarketInfo(Symbol(),MODE_TICKVALUE);
    return(Point);
  }
}
//Функция расчета Прибыли/убытка по паре
double SummSymbol()
{
    int n=0;
    double SumSymbol=0;
    int NBuy=0;
    int NSell=0;
    int ttl=OrdersTotal();
    for(int cnt=0;cnt<ttl;cnt++){
        OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
        if(OrderSymbol()==Symbol()){
           n++;
           if(OrderType()==OP_BUY){
              NBuy++;
              SumSymbol+=OrderSwap()+((Bid-OrderOpenPrice())/Auto_Points())*OrderLots()*PPLot;
           }
           if(OrderType()==OP_SELL){
              NSell++;
              SumSymbol+=OrderSwap()+((OrderOpenPrice()-Ask)/Auto_Points())*OrderLots()*PPLot;
           }
        }
    }
    return(SumSymbol);
}

But the problem is that they only count on the pair on which the EA is standing and I need to specify for which pair to count profit (loss), for example like this: SummSymbol(string OrdSmb)

I changed Symbol() to OrdSmb but my calculations are wrong for all pairs except advisor's one.

 
Lians:

Dear Professionals, help with the functions. I have two functions (not mine) which I use to calculate current profit (loss) on a pair in open orders, look like this:

But the problem is that they only count on the pair on which the EA is standing and I need to specify for which pair to count profit (loss), for example like this: SummSymbol(string OrdSmb)

I changed Symbol() to OrdSmb but my calculations are wrong for all pairs except advisor's one.


Check

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает суммарный профит открытых позиций в валюте депозита |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
double GetProfitOpenPosInCurrency(string sy="", int op=-1, int mn=-1) {
  double p=0;
  int    i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (mn<0 || OrderMagicNumber()==mn) {
            p+=OrderProfit()+OrderCommission()+OrderSwap();
          }
        }
      }
    }
  }
  return(p);
}
Reason: