This script can be used to approximate a strategy, and find optimal leverage. The output will consist of two columns, one for the median account size at end of trading, and one for the share of accounts liquidated.
The script assumes a 100% position size for the account. This does not take into account size deviations for earnings and losses, so use with a grain of salt if your positions vary greatly in that aspect.
Code preview cdn.discordapp.com/attachments/592684708551327764/848701541766529034/carbon.png TradingView does not allow posting external links until you've reached a specific reputation, so i can't use the url feature
Input explanation
WINRATE : chance of winning trade
AVGWIN : average earning per winning trade
AVGLOSS : average loss per losing trade
MAX_LEVERAGE : maximum leverage available to you
TRADES : how many trades per account you want to simulate
ACCOUNTS : how many accounts you want to simulate
the inputs used in the source code are from one of my older strategies, change them to suit your algorithm
Source code pastebin.com/69EKdVFC
Good luck, Have fun -Vin
Trade ativo
Left a mistake in the code, here's an updated version:
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.