Risk Management: Position Size & Risk Reward – Update

Now short sellers can use the Risk Management script to calculate position size and price targets when going short. When you select ‘Are you short selling?’ option in the dialog box, the label will change to the following:

  • Label color will turn red
  • Stop loss will be above the current price
  • Price targets will be below the current price

When choosing to short, the Price target can go no lower than 0.00. When that’s the case, the profit at 0.00 will be shown.

The script now has an error condition to check if custom stop loss is greater than the current price for short and less than the current price when long. Price targets will not show when this error condition returns true.

This script is now in its fifth and almost final revision. Pine script doesn’t provide the ability to do any unit testing, so adding more functionality will make the script unwieldy and more difficult to maintain. I’m planning to remove the Opening Range Breakout feature in the next revision, in order to improve the maintainability of the code.  Let me know if this is something you would like to keep in the script.