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

 

Can you tell me where I can find a script that shows the amount of real money
for example
account balance = 10000
amount of money with leverage = 10000
amount of real money = 100

 
novicek:

Tell me where to find a script which would show the amount of real money
for example
the amount in the account = 10000
the amount of money with leverage = 10000
the amount of real money = 100



The amount of real money is the account balance. The value is returned by the function AccountBalance(). The three figures you listed are all the same. The last one will also be 10,000.
 

Sancho77


for(int i=orderstotal-1 ; i>=0 ;i--)
   {
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {   
      if(OrderSymbol() != Symbol() // ордер в торговом пуле и его символ не соответсвует текущему
        
 
tol64:

The amount of real money is the account balance. The value is returned by AccountBalance(). The three figures you listed are all the same. The last one would also be 10,000.
I would say the amount of real money is AccountEquity() though. Otherwise, there's little that hangs in the minus - until the trades are closed, the balance won't reflect the state of affairs in the account.
 
tol64:

The amount of real money is the account balance. The value is returned by AccountBalance(). The three figures you listed are all the same. The last one will also be 10,000.
Forget about the balance. And don't mislead others. Equity is your real funds. If your funds allow, your balance can be zero, but not the other way around. Even if you have a balance of even a million, and funds have fallen to a critical value, wait for the Margin Call, and then the Stop Out... ...if you don't get the money into your account in time.
 
Dimka-novitsek:

Yeah, sorry really, it's the heat of the moment, I've been running a little low. Sorry about that. Thanks!!!!!!!!!

Don't bother... Do you need to close all positions and delete all orders if the last closed position closed at TakeProfit ?

Here is your next homework assignment.

   int j=-1;
   datetime t;
   string PoseType;
   // Поищем в цикле последнюю закрытую позицию, которая закрылась по TakeProfit
   for (int i=0; i<OrdersHistoryTotal(); i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
         if (OrderSymbol()!=Symbol())     continue;
         if (OrderType()>1)               continue;
         if (OrderMagicNumber()==1000 || OrderMagicNumber()==2000) {
            if (t<OrderCloseTime()) {
                t=OrderCloseTime();
                j=i;
               }
            }
         }
      }
   if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
      if (NormalizeDouble(OrderClosePrice()-OrderTakeProfit(),Digits)<0.5*Point) {
         Alert("Позиция с тикетом #",OrderTicket()," закрыта по TakeProfit, закрываем остальные прозиции и удаляем отложенные ордера");
         for (int k=OrdersTotal()-1; k>=0; k--) {
            if (OrderSelect(k, SELECT_BY_POS) {
               if (OrderSymbol()!=Symbol())  continue;
               if (OrderMagicNumber()==1000 || OrderMagicNumber()==2000) {
                  if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
                     if (OrderType()==0) PoseType="BUY"; else PoseType="SELL";
                     Alert("Закрываем позицию ",PoseType," с тикетом #",OrderTicket());
                     // Здесь вставьте команду для закрытия рыночной позиции (для тестера). Для реала здесь должен быть вызов 
                     // полноценной функции закрытия позиций с проверкой и обработкой ошибок сервера
                     }
                  if (OrderType()>1 && OrderType()<=5) {
                     if (OrderType()==2) PoseType="BUYLIMIT";
                     if (OrderType()==3) PoseType="BUYSTOP";
                     if (OrderType()==4) PoseType="SELLLIMIT";
                     if (OrderType()==5) PoseType="SELLSTOP";
                     Alert("Удаляем отложенный ордер ",PoseType," с тикетом #",OrderTicket());
                     // Здесь команда для удаления отложенного ордера (для тестера). Для реала здесь должен быть вызов 
                     // полноценной функции удаления отложенного ордера с проверкой и обработкой ошибок сервера
                     }
                  }
               }
            }
         }
      }

For the love of God, don't pile everything up again... I've already done everything for you - all you have to do is fart twice... I even wrote where... :) And, of course, clean up all the alerts and the code that goes with them... although... I'm not sure that you'll find what, where and how, and for what...

 
artmedia70:
Forget about the balance. And don't mislead others. Equity is your real money. If your funds allow, your balance can be zero, but not vice versa. Even if you have a balance of even a million, and funds have fallen to a critical value, wait for the Margin Call, and then the Stop Out... ...if you don't get the money into your account in time.

I didn't do it on purpose.)
It turns out that this is a relative concept.)) Balance is a fixed profit/loss. And this is real. Funds, AccountEquity(), can still change as many times as you like and this is in principle also real, but already quite vague. Of course, we should not increase the critical value of our account and control the deposit load and risk away from stop out and margin percentage. Such an example has already been given above. The same "kamikaze")))

In that case novicek should have been more specific and used clear definitions such as Balance/Equity (clear) rather than Real/Unreal (vague). Would the example below work for you then?

For me, AccountEquity(), as an unformed candle and other indicators that interest me, I calculate on the balance, but of course, I also follow the means, to be aware of when Equity (means) should be converted into real or virtual (if it is a test) money, that is balance. ))

 
artmedia70:

Don't bother... Do you need to close all positions and delete all orders if the last closed position closed at TakeProfit ?

Here's your next homework assignment.

Beautifully structured code even without comments is clear. Like a book.)
 
tol64:

I didn't do it on purpose.)
It turns out to be a relative concept.) A balance sheet is a fixed profit/loss. And it's real. Funds, AccountEquity(), can still change as many times as you like and this is in principle also real, but already quite vague. Of course, we should not increase the critical value of our account and control the deposit load and risk away from stop out and margin percentage. Such an example has already been given above. The same "kamikaze"))).

In that case, novicek should be more specific and use a clear, understandable definitions, such as Balance / Equity (clear), and not Real / Unreal (vague). Would the example below work for you then?

For me, AccountEquity(), as an unformed candle and other indicators that interest me, I calculate on the balance, but of course, I also follow the means, to be aware of when Equity (means) should be converted into real or virtual (if it is a test) money, that is balance. ))

And it is better to close all positions when the equity line rises above the balance line. After all, when closing the open positions, the balance becomes equal to equity. :)

Well, you're wrong about the "unequity candle" in relation to equity... Equity is your profit/loss that has already been formed, while the balance, when positions are not closed, is dust, nothing...

 
artmedia70:

Equity is your already generated profit/loss, and the balance with uncovered positions is dust, nothing...


That's why I close a position when funds reach a certain value over the balance, but I should also close a position when funds are under the balance, if I was wrong and price went in the wrong direction.) If you do not close a position timely, when funds are above the balance, after a while it may turn out that the funds will be under the balance and not rise higher for a long time, and then go even steeper down to stop-loss, and after the stop-loss even further, and some people do not even put a stop)). Where did those funds go when they were over the balance? They turned into dust, into nothing.))

It's like a poem.)) Actually we're talking about the same thing most likely. About the unformed candle. I meant entry and exit conditions. Orders do not fall into this category. Closing positions by stop-loss, opening by pending orders of course do not take place by a formed candle.))

Reason: