[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 689

 
chief2000:

I wondered where to start when calculating risk for a new trade, if the main criterion is the lowest risk? -

AccountFreeMargin(), AccountEquity(), AccountBalance() ...?

- AccountBalance() - does not take into account open trades.

- AccountEquity() - this is what we see on the balance chart? - In this case we will rely on the money we don't own yet.

- AccountFreeMargin() - can we use this? (I accept that I may be misunderstanding what it is)

- AccountEquity() - this is our funds... Look at the graph the tester makes. There are two lines there - one (blue) is balance and the other (green) is funds.

The balance is our hypothetical, possible profit that still needs to be made, it is so... nothing... an approximation of what might come out of the deal...

Funds are what we already have and what we risk. And if our order has fallen into deficit, this is immediately shown on the equity curve (the chart of the real means).

That is why AccountBalance() is, in your words, "... what we see on the balance graph... ... money that doesn't already belong to us..."

The funds that belong to us are equity.

When you close a position in minus, the balance curve falls to the equity curve. Although, until we closed the position, the balance does not reflect this and shows the possible account state, creating the appearance of stability and prosperity... :) Meanwhile, the equity curve reflects the real state of our account and our funds.

If there is only one open position in the market, we cannot see the equity curve. As soon as we open another position and close it leaving the second one open, we will immediately see the equity curve as the real position of the account differs from the possible one. Or close one single position partially in profit and the equity curve will immediately become higher than the balance curve. If you close it completely, you will see both curves converge at the same point.

 
Friends, please help. I'm trying to make a function that will search for extrema on the chart of any indicator. The point is that for some of my strategies I need to find the divergences in different indicators and price chart, in different TFs. I.e., I get confused by the implementation of an algorithm for identification of extrema, comparison of extrema matching them on the price chart and, moreover, with the possibility to identify them not only in the chart of some single indicator but also in any indicator specified in the function, or at least written in the code.

Also... I've noticed an interesting feature of Ind. A/D. If we draw trend lines on it (again, through its extremums), then if the A/D chart crosses those lines, we can expect a reversal or correction of the main trend in the price chart. I cannot figure out how to implement it in the code. I even attach a picture:

If you don't mind, please advise me at least the algorithm how to do it.

I can't figure it out in any sort of orderly structure and sequence of operations...

Don't let my colleague here dry up... :)

 
artmedia70:

- AccountEquity() is our means... Look at the graph the tester makes. There are two lines there - one (blue) is balance and the other (green) is funds.

The balance is our hypothetical, possible profit that still needs to be made, it is so... nothing... an approximation of what might come out of the deal...

Funds are what we already have and what we risk. And if our order has fallen into deficit, this is immediately shown on the equity curve (the chart of the real means).

That is why AccountBalance() is, in your words, "... what we see on the balance graph... ... money that doesn't already belong to us..."

The money that belongs to us is equity.

When you close a position in minus, the balance curve falls to the equity curve. Although, until we closed the position, the balance does not reflect this and shows the possible account state, creating the appearance of stability and prosperity... :) Meanwhile, the equity curve reflects the real state of our account and our funds.

If there is always only one open position in the market, we cannot see the equity curve. Once we open another position and close it leaving the second one open, we will immediately see the equity curve as the real position of the account will be different from the possible one. Or close one single position partially in profit and the equity curve will immediately become higher than the balance curve. If you close it completely, you will see both curves converge at the same point.

What I mean is that we see the Equity = Funds (green) line on the balance chart.

.

I disagree with the statement that Equity is what we already have. If I opened a trade with Take Profit = 300 pips, the price passed in +200 pips and this is shown by the Equity line. Suppose at this point I want to open a new trade and carry out a risk calculation (one option -> from Equity). If after that the price turns and goes to zero or minus, the risk taken from Equity will be higher than the risk taken from Balance - and will not be correct at all, as Profit on an unclosed trade is a virtual Profit.

The second case - if profit on the first trade has gone in the red and a new trade should be opened, the risk taken from Balance (which does not see the current=unclosed unprofitable trade) would be overestimated.

The conclusion is to consider the lowest value of both. Here I would like to get information about AccountFreeMargin() - what it is and whether it solves the problem or is it not relevant at all.

 

Can MT4 be reconfigured so that Drawdowns are calculated by Balance and not by Equity?

(I think that was once the case, what version is it in and where do I get it?)

 
chief2000:

I meant that we see the Equity = Funds (green) line on the balance sheet chart.

.

I disagree with the statement that Equity is what we already have. If I opened a trade with Take Profit = 300 pips, the price passed in +200 pips and this is shown by the Equity line. Suppose at this point I want to open a new trade and carry out a risk calculation (one option -> from Equity). If after that the price reverses and goes to zero or minus, the risk taken from Equity will be higher than the risk taken from Balance - and will be incorrect at all, as Profit on an unclosed trade is a virtual Profit.

The second case - if profit on the first trade has gone in the red and a new trade should be opened, the risk taken from Balance (which does not see the current=unclosed unprofitable trade) would be overestimated.

The conclusion is to consider the lowest value of both. This is where I would like to get information about AccountFreeMargin() - what it is and whether it solves the problem or maybe it is not relevant at all.

OK, but if we shift from the balance, what will happen? The balance shows a completely unrealistic state of affairs in our account...?

Let's try an experiment... I have intentionally disabled everything in my Expert Advisor, leaving only open positions according to the market and the trend, removing stop-losses and checking for the end of the trend. We will open all positions that are possible to follow the market and close them partially when the market is moving, and those that have opened on the bottom or on the top will hang and eat margin. Let's look at the balance and equity curves... OK? (Note the column Free funds (equity) in the upper left corner of the indicator window)

So...


Opened the first position and moved 12pp into profit; no balance, funds are already showing an increase...


One position has been partially closed, the other one is in the market. Balance shows funds from partial closing, equity is higher than balance as the current price keeps moving up.

If we close all positions now, the balance is equal to equity...


Here we can already see that the last partial close was at a better price than the last one. Therefore, equity started to decrease, approaching the balance.


And now we look at the balance and the equity...


... Well, after a week of this marathon...


 
What do you think the real position of the account shows - the balance, which is constantly going up, or the funds...?
 
artmedia70:
1. I am trying to make a function that will look for extrema in any indicator chart.

..

2. If we draw trend lines on it (again, through its extremums), then if the A/D chart crosses these lines, we should expect a reversal or correction of the main trend in the price chart. I cannot find out how to implement it in the code.

1. There is no problem with identifying extrema - just feed the indicator to the input of some ZZ instead of the price. Of course, one should realize that the procedure for identifying extrema is fundamentally ambiguous. I remember I showed a picture in this form some time ago. Oh, I found it :)



2. I will not invent a picture, but I have been going to do the following for several years and cannot do it at all: a line is defined by two coefficients, let A and B. You create two arrays, A[] and B[], and a line counter, i. When you create a new line, enter A and B in A[i] and B[i] and increment the line count. If the line count exceeds the size of arrays, increment them or reset the counter (that is, start throwing out old lines in the order of their creation). The rest is simple, you calculate the current position of each line point in arrays A[] and B[] in the loop and check the intersection with the indicator line.

By the way, you should pay for a sample of future indicator as a fee :)

 
To conclude, I will give you an example of closing such trades by increasing equity by a specified number of percents. I increased it by 5%.

Graph, after 16 days. You can clearly see how the balance line falls to the equity line when all positions are closed when it increases by 5%


This is called the total profit of all positions.

 
artmedia70:
Based on the above, can you tell me what shows the real position of the account - the balance, constantly going up, or the funds?

You've confirmed what I've already written about, but you keep sticking to one of the extremes.

Not to deviate too much from the main topic - I'm more interested in the question about AccountFreeMargin() - what it is and whether it solves the problem I described above.

 
chief2000:

You've confirmed what I've already written about, but you keep sticking to one of the extremes.

Not to deviate too much from the main topic - I'm more interested in the question about AccountFreeMargin() - what it is and whether it solves the problem I described above.

double AccountFreeMargin( )
Returns the value of the free margin allowed to open positions in the current account.
Example:
Print("Account Free Margin = ",AccountFreeMargin());
Reason: