How to calculate current equity when back testing in Forex?

 

Hi forum,

Apologies if this is the wrong place to post but I could do with some help please. When back testing, i'd like to know how much my portfolio is currently worth. I'm finding this tricky as I have multiple buy and sell orders present at any one time. To illustrate this, I have attached a screenshot from a workbook, if anybody tech savvy could be so kind as to take a look and help me out.

Kind regards,

CPerry.

Files:
 

If nobody knows how to work this out, could somebody at least point me to someone/some place that may know please?

TIA

CPerry.

 

Perhaps you should read the manual. ACCOUNT_EQUITY
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

 
CPerry: Apologies if this is the wrong place to post but I could do with some help please. When back testing, i'd like to know how much my portfolio is currently worth. I'm finding this tricky as I have multiple buy and sell orders present at any one time. To illustrate this, I have attached a screenshot from a workbook, if anybody tech savvy could be so kind as to take a look and help me out. Kind regards, CPerry.

Your query is unclear!

Usually when someone talks about back-testing on this forum it is about running a back test in the Strategy Tester, where the Balance and equity curve is shown in a graph.

In your case, you seem to be doing a manual paper testing and keep track of it on paper. So, keeping track of profit or equity can be difficult.

To do it you have to refer to the chart data for each symbol on which you paper traded. You have to look at the opening time of each trade and follow the chart to see the maximum excursions of each trade, be it favourable and adverse excursions, and calculate their value in points, pips or in money based on their tick size and value. If needed You also have to do currency conversion at the time of those excursions. It can be very time consuming and require plenty of manual work and calculations.

In the following image you can see a spreadsheet to follow along 3 currency pairs for virtual trades opened up at 08:00 on 2022-08-10, and then tracked for each H1 bar thereafter during 24 hours, tracking the Upper and Lower excursions and retracements, and then analysing those results as if they were both buy and sell orders. The spreadsheet is only analysing points, and not actual money values, that would require conversion into deposit currency.

In essence, it is a lot of work and that is why most traders automate the strategy so as to be able to test it in the strategy tester instead.

EDIT: One more thing to note, in your screenshot, you mention leverage, but that has no relevance on how much a position is worth.

EDIT2: Yes, you can buy or sell fractions of a lot. Usually you can go as low as 0.01 Lots.

EDIT3: Also study up on the concept of a tick size and tick value, which is what is used to calculate the value of a position based on the opening and current quote prices and the volume of the position at any one give moment.


 

Hi @William Roeder,

I have read the manual page you directed me to but nothing on that page seemed to explain my query. I’ll have a deeper dive but something there did catch my eye:  

ACCOUNT_STOPOUT_MODE_PERCENT

ACCOUNT_STOPOUT_MODE_MONEY

When trading forex, IG has a base leverage of 1:30 with GBP/USD so my profits and losses will be magnified. To understand the risks, I think I need to fully understand the following:

When specifically will my trading platform margin call me out of a position? Is there a certain formula for multiple open orders or is it done on an order-to-order basis? Can each order only drop my a certain specific % or something before I get forcefully closed out of a position?

Thank you for helping me learn,

CPerry.

 

Hi @Fernando Carreiro,

Yes, I am manually analysing some markets myself using a workbook (paper testing yes but not actually on paper aha). The reason for me doing this is I am pretty decent at using VBA in Excel and have half developed a simple testing system which loops around thousands of combinations, simply at this stage to understand the shape and size of the markets rather than to back-fit a certain strategy.

If I were to do this in MT5, this would take me months. There may be a way to do what I’m doing but, since transitioning, I thought I’d leverage my existing skillset so I have somewhere to start.


Using your screenshot, If I bought one lot of AUD/USD at 8:00am (0.69570) and sold it at the close that same hour (0.69551) then wouldn’t my calculation simple be:

0.69551 – 0.69570 = -0.00019 = -1.9 pips

-1.9 multiplied by $10 = -$19

-$19 divided by 0.69551 = -(AUD)27.32 (rounded from -27.3180831)?

=-$19 or -(AUD)27.32


But how does this work with multiple buy orders if I add to a position? I’m going to have another play tomorrow but it does get rather confusing so any confirmation/guidance/advice at this stage is greatly appreciated!

CPerry.

 

P.S. Also I’m English and have deposited GBP into my account so how does that work if neither the base currency (AUD) or quote currency (USD) are GBP? Do I then need to convert my negative (AUD) into GBP at the current AUD/GBP price to get my current equity or will MT5 automatically display my current equity in GBP without this additional step, in live mode?

Edit 1 reply: Leverage has no relevance to how much a position is worth? I thought with a 1:30 leverage then instead of 1 lot = $10, 1 lot would = $10 x 30 = $300 per pip?

Edit 2 reply: This makes sense. I have found out IG offer a mini lot as the minimum but if you use MT4, you can trade with micro lots. This now makes sense to me.

Edit 3 reply: I'll add this to the top of my research list and crack on with this first thing in the morning.

Again, thank you for much for taking the time to help me!

 
CPerry #: I have read the manual page you directed me to but nothing on that page seemed to explain my query.

Your query was:

CPerry: How to calculate current equity when back testing in Forex?

Answer given: AccountInfoDouble(ACCOUNT_EQUITY). Doesn't that exactly answer you?

 
CPerry #: Again, thank you for much for taking the time to help me!

Your questions are about very basic concepts about trading (in this case Forex). Trying to come up with a strategy without having a good understanding of the basics is going to trip you up. I would suggest you invest some time on gaining that knowledge first. I took my first steps into Forex education with BabyPips School of Pipsology, and it is a very good starting point in my opinion. Should the link be removed for violation of forum rules, just run a search on Google.

Learn Forex Trading at School of Pipsology - BabyPips.com
Learn Forex Trading at School of Pipsology - BabyPips.com
  • www.babypips.com
Learn forex trading with training and education at BabyPips.com's School of Pipsology.
 

Thank you @Fernando Carreiro,

I have plenty of ideas and research about strategies already but it's true i'm still learning about the basics of the mechanics behind the software. I want to make sure I thoroughly understand what's going on before I come off of practise mode. I'll happily check out BabyPips so thank you for that link. Would you mind confirming/denying if my calculations in my previous post are correct please?

For anybody new reading this thread, I found out how using GBP for various other currencies is converted:

https://www.ig.com/uk/help-and-support/spread-betting-and-cfds/fees-and-charges/what_are-ig_s-currency-conversion-feesforspread-bet-or-cfd-accou

The need for currencies to be converted mainly depends on your trading account’s base currency, funding currency, conversion settings and the markets you’re trading.

Our standard FX conversion fee is 0.5% which is added to the best available exchange rate provided from several banks. To add our FX conversion fee, we multiply the underlying exchange rate by 1.005 before converting.

For example, if the GBP/USD exchange rate is 1.4, the FX conversion rate applicable would be 1.4 x 1.005 = 1.407.

By default, spread bet and CFD accounts are set to ‘instant’ conversion. This means we automatically convert any realised profit, loss, funding, dividend adjustments or commission to your base currency.

I think i'm going to stick with GBP pairs to begin with until I have a better understanding of this matter.

CPerry.

 
William Roeder #:

Your query was:

Answer given: AccountInfoDouble(ACCOUNT_EQUITY). Doesn't that exactly answer you?

 Hi William Roeder,

Sorry, I may be completely missing something painfully obvious - in the link you sent, all I can see is that Account Equity is displayed as a double which is "a value from -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values and from 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values"

Whereas i'm trying to figure out how the value is calculated, not displayed. I've copied some numbers into a spreadsheet and i'm trying to work it out for myself still. I believe I need bid and ask prices instead of OHLCV values though for the calculation so i'm back doing that now.

CPerry.

 
CPerry #: Using your screenshot, If I bought one lot of AUD/USD at 8:00am (0.69570) and sold it at the close that same hour (0.69551) then wouldn’t my calculation simple be:

0.69551 – 0.69570 = -0.00019 = -1.9 pips
-1.9 multiplied by $10 = -$19
-$19 divided by 0.69551 = -(AUD)27.32 (rounded from -27.3180831)?
=-$19 or -(AUD)27.32

Correct, but it is important to take into account the spread when converting from one currency into another. I'm not sure at the moment when to use bid or ask when doing this (I need to refresh my memory on this), but if I am not mistaken in this case you would have to use the Ask price to convert USD into AUD, since you are selling USD ad buying AUD for the conversion.

CPerry #: But how does this work with multiple buy orders if I add to a position? 

If you are adding to the position during the life of the original position, you need to analyse each added position separately and then sum the profits and losses.

How to Calculate the Net Resulting Equivalent Order

The math is self explanatory, but here are the variables anyway:

  • vi = volume of individual position
  • oi = open price of individual position
  • ci = close price of individual position
  • Vn = total volume for a basket of positions
  • On = net mean open price for a basket of positions
  • Cn = net mean close price for a basket of positions
  • PLn = profit/loss for a basket of positions
The rest is in the math calculations.
CPerry #: Also I’m English and have deposited GBP into my account so how does that work if neither the base currency (AUD) or quote currency (USD) are GBP? Do I then need to convert my negative (AUD) into GBP at the current AUD/GBP price to get my current equity or will MT5 automatically display my current equity in GBP without this additional step, in live mode?

In the example above your loss was $19 USD (not in AUD), so you would convert USD into GBP at the time the position was closed. However, in MetaTrader that conversion is done automatically for you. You would only need to do this for your spreadsheet paper trading.

CPerry #: Edit 1 reply: Leverage has no relevance to how much a position is worth? I thought with a 1:30 leverage then instead of 1 lot = $10, 1 lot would = $10 x 30 = $300 per pip?

Incorrect! Leverage has no effect on the gain, be it loss or gain. In the example above, the only thing that would affect the gain would be the volume (lots) of the position. Leverage only affects the required margin when you place the trade, which is then returned to you when you close the trade. It does not affect the profit or loss of the trade, only the required margin.

Reason: