Averages/Simple moving average: Difference between revisions

Content added Content deleted
Line 3,471: Line 3,471:


$inputs = @() #Create an array to hold all inputs as they are entered.
$inputs = @() #Create an array to hold all inputs as they are entered.
$Period1 = 3 #Define the periods you want to utilize
$period1 = 3 #Define the periods you want to utilize
$period2 = 5
$period2 = 5


Line 3,492: Line 3,492:
try{$inputs += [decimal] (Read-Host)}catch{Write-Host "Enter only numbers" -ForegroundColor Red} #Enter the numbers. Error checking to help mitigate bad inputs (non-number values)
try{$inputs += [decimal] (Read-Host)}catch{Write-Host "Enter only numbers" -ForegroundColor Red} #Enter the numbers. Error checking to help mitigate bad inputs (non-number values)
"Added " + $inputs[(($inputs.Count) - 1)] + ", sma($Period1) = " + (getsma $inputs $Period1) + ", sma($period2) = " + (getsma $inputs $period2)
"Added " + $inputs[(($inputs.Count) - 1)] + ", sma($period1) = " + (getSMA $inputs $Period1) + ", sma($period2) = " + (getSMA $inputs $period2)
}
}
</lang>
</lang>

=={{header|PureBasic}}==
=={{header|PureBasic}}==
<lang PureBasic>Procedure.d SMA(Number, Period=0)
<lang PureBasic>Procedure.d SMA(Number, Period=0)