ROUNDEDDOWN

Category: ProBacktest

ROUNDEDDOWN is a function in the ProBuilder language used primarily to round down numerical values to the nearest whole number. This function is particularly useful in trading scenarios where you need to determine the maximum number of whole shares that can be purchased with a given amount of cash, based on the current share price.

Syntax:

ROUNDEDDOWN(expression)

Example:

Suppose you have a trading strategy where you want to invest a fixed amount of cash in a stock, but you can only buy whole shares. If you have $1000 to invest and the current stock price is $123.45, you can use the ROUNDEDDOWN function to calculate the maximum number of shares you can buy:

cash = 1000
pricePerShare = 123.45
maxShares = ROUNDEDDOWN(cash / pricePerShare)

This will result in maxShares being 8, as 1000 divided by 123.45 equals approximately 8.1, and rounding down gives 8.

Additional Information:

  • The ROUNDEDDOWN function is essential for ensuring that calculations in trading strategies adhere to the practical constraints of buying whole shares or units of any financial instruments.
  • It helps in maintaining budget constraints by not exceeding the available cash.

Understanding and using the ROUNDEDDOWN function can help in creating more realistic and executable trading strategies in the ProBuilder environment.

Related Instructions:

  • ROUNDEDUP probacktest
  • Logo Logo
    Loading...