should Buy
fun shouldBuy(latestPrice: Double, sma: Double, margin: Double, priceVolatility: Double, buyThreshold: Double): Boolean
Determines whether to buy based on the latest price, SMA, margin, price volatility, and a buy threshold.
The decision is based on the criteria that the latest price is below the SMA, the margin is positive, and the price volatility is below the specified threshold.
Return
true
if the conditions are met for buying, otherwise false
.
Parameters
latest Price
The most recent price.
sma
The Simple Moving Average (SMA) value.
margin
The margin calculated from SMA and latest price.
price Volatility
The calculated price volatility.
buy Threshold
The volatility threshold below which buying is considered.