Risk Based Position Sizing

Questions about MultiCharts .NET and user contributed studies.
ascales
Posts: 36
Joined: 06 Jan 2017
Has thanked: 4 times
Been thanked: 2 times

Risk Based Position Sizing

Postby ascales » 08 Jul 2020

Hi there,

I have the following code for calculating lot size based on entry and exit price:

Code: Select all

private int CalculateLotSize(double entryPrice, double lossPrice) { var priceDifference = Math.Abs(entryPrice - lossPrice); var ticks = priceDifference * (Bars.Info.MinMove * Bars.Info.PriceScale); var valuePerTick = (ticks * Bars.Info.MinMove / Bars.Info.PriceScale) * Bars.Info.BigPointValue; return (int)(GetRiskAmount() / valuePerTick); }
For EUR/USD it returns the correct lot size; however for AUD/JPY (for example) it is incorrect, with the lot size being significantly smaller.

I have the following values for the currencies provided by the broker LMAX:

EUR/USD: MinMove 1, PriceScale 100,000, BigPointValue 1,000
AUD/JPY: MinMove 1, PriceScale 1,000, BigPointValue 1,000

Any ideas what is wrong?

Best,
A

User avatar
Vlada MultiCharts
Posts: 293
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: Risk Based Position Sizing

Postby Vlada MultiCharts » 27 Jul 2020

Hello,

Our dev team has checked your code. Your code for entries uses the prices and parameters of the symbol.
If it works correctly for one symbol, so it should work correctly for other symbols as well. Please give us more details on what refer to as incorrect lot size for AUD/JPY. Which result do you get and why do you consider it to be wrong? Also, please describe the expected behavior of the code so that we could check this.

ascales
Posts: 36
Joined: 06 Jan 2017
Has thanked: 4 times
Been thanked: 2 times

Re: Risk Based Position Sizing

Postby ascales » 29 Jul 2020

Hi,

Thanks for your response.

The issue was that I was calculating the risk amount in my account currency. This needs to be converted to the symbol currency using the form:

Code: Select all

var riskAmountSymbolCurrency = StrategyInfo.ConvertCurrency(Bars.Time[0], StrategyCurrencyCode, Bars.Info.CurrencyCode, riskAmountAccountCurrency);
This however means that you are limited to currencies contained in the enum MTPA_MCSymbolCurrency. This kind of stuff seems to be covert secret-squirrel like and means spending hours trawling forums and decompiling code.

If anyone has feedback on the above (if it's not correct...) or wishes to contribute approaches for position sizing in MC.NET please go ahead.

Cheers,
A

User avatar
dataheck
Posts: 30
Joined: 19 Nov 2019
Location: Amherst, Nova Scotia
Been thanked: 5 times
Contact:

Re: Risk Based Position Sizing

Postby dataheck » 31 Jul 2020

Hey ascales,

Check out the indicator I made for my own risk management process: viewtopic.php?t=52336

It uses realized volatility to infer the "standard move" in dollars for a position. I personally decide on what daily 1-standard deviation move in profit and loss that I am comfortable with, and keep an eye on the indicator for when I can risk-on or should risk-off.

It comes with a function that calculates the same.


Return to “MultiCharts .NET”