OPEN-SOURCE SCRIPT
מעודכן

The Ultimate Lot Size Calculator

489
Backstory

I created this Pine Script tool to calculate lot sizes with precision. While there are many lot size calculators available on TradingView, I found that most had significant flaws. I started teaching myself Pine Script over three and a half years ago with the sole purpose of building this tool. My first version was messy and lacked accuracy, so I never published it. I wanted it to be better than any other available tool, but my limited knowledge back then held me back.

Recently, I received a request to create a similar tool, as the current options still fail to deliver the precision and reliability traders need. This inspired me to revisit my original idea. With improved skills and a better understanding of Pine Script, I redesigned the tool from scratch, making it as precise, reliable, and efficient as possible.

This tool features built-in error detection to minimize mistakes and ensure accuracy in lot size calculations. I've spent more time on this project than on any other, focusing on delivering a solution that stands out on TradingView. While I plan to add more features based on user feedback, the current version is already a powerful, dependable, and easy-to-use tool for traders who value precision and efficiency in their lot size calculations.

How to use the tool ?

At first it might seem complicated, but it is quite easy to use the tool. There are two modes: auto and manual. By default, the tool is set on manual mode. When you apply the tool on the chart, it will ask you to choose the entry price, then the stop-loss price, and at last the take-profit price. Select all of them one by one. These values can be changed later.
תמונת-בזק
תמונת-בזק
תמונת-בזק

Settings

There are various setting given for making the tool as flexible as possible. Here is the explanation for some of most important settings. Play with them and make yourself comfortable.

  • General settingsתמונת-בזקAuto mode : Use this mode if you want the the risk reward to be fixed and stop loss to be based on ATR. However the stop loss can be changed to be based on user input.

    Manual mode : Use this mode if you want full control over entry, stop loss and take profit.

    Contract Size : The tool works perfectly for all forex pairs including gold and silver but as the contract size is different for different assets it is difficult to add every single asset into the script manually so i have provided this option. In case you want to calculate lot size for a asset other then forex, gold or silver make sure to change this. Contract size = Quantity of the asset in 1 standerd lot.

  • Account settingsתמונת-בזק
  • Automatic mode settings and ATR stop settings תמונת-בזק
  • Manual mode settingsתמונת-בזק

    Table and risk-reward box settings are pretty much self-explanatory i guess.


Error handling

A lot size calculator is a complex program. There are numerous points where it may fail and produce incorrect results. To make it robust and accurate, these issues must be addressed and managed properly, which practically all existing lot size calculator scripts fail to do.
תמונת-בזק
תמונת-בזק
תמונת-בזק



Golden tip

When the symbol is changed it will display a symbol change warning as the entry, stop loss and take profit price won't change.
תמונת-בזק

There are 2 ways to get fix this. Either manually enter all three values which i hate the most or remove the script from the chart and re-apply the script on chart again.

So to re-apply the indicator in most easy way follow the following instructions:
תמונת-בזק

Note : If you encounter any other error then read the instruction to fix it and if it is an unknow error pleas report it to me in comments or DM.
הערות שחרור

  • Some minor bug fixes
  • Table layout enhanced
    תמונת-בזקDaily ATR : Daily ATR tells that on average how much a pair moves in a day. We can get an idea about how much we can expect market to move in a day and set the target accordingly. e.g. if daily ATR is 100 pips that means the a target of 60 to 80 pips is ok. However it can be more or less according to your plan but if you are expecting the price to move 200 pips in a day that might be unrealistic.

    Chart ATR : This tells you the average movement on current timeframe. This gives you an idea about how much price movement can you on current timeframe, given that there is no news at the moment because during news the volatility increases significantly and price can move more then average.

    Timeframe - ATR ( Multiplier) : This tells you a custom value which can be help full in stoploss placement. This can be configured from settings.
הערות שחרור
  • Changed chart image to new layout
  • Improved code.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.