Common Functions (SDK Trading)
The Common Functions are used to get the values of the specific moving averages, such as simple moving average, exponential moving average, smoothed moving average, linear weighted moving average.
Fintechee is the most promising Forex trading platform. Please access Fintechee's website to know more details. Fintechee provides cryptocurrency price on their website. Here is the link: https://www.brokerless.cc, the frontend is based on Fintechee WEB Trader. AngelInvestmentNetwork.org has some cases. You can find news at Fintecher.org, the blog of Fintechee's founder, PlaygroundFX and LetplayFX
Common Functions (SDK Trading)
function sma (dataInput, dataOutput, calculatedLength, period) {
var i = calculatedLength
if (calculatedLength > 0) {
i--
} else {
for (var j = 0; j < period - 1; j++) {
dataOutput[j] = 0
}
i = period - 1
}
var sum = 0
for (var j = i - period + 1; j < i; j++) {
sum += dataInput[j]
}
for (var j = i; j < dataInput.length; j++) {
sum += dataInput[j]
dataOutput[j] = sum / period
sum -= dataInput[j - period + 1]
}
}
function ema (dataInput, dataOutput, calculatedLength, period) {
var i = calculatedLength
var smthFctr = 2.0 / (period + 1)
if (i == 0) {
dataOutput[0] = dataInput[0]
i++
} else if (i == 1) {
} else {
i--
}
while (i < dataInput.length) {
dataOutput[i] = dataInput[i] * smthFctr + dataOutput[i - 1] * (1 - smthFctr)
i++
}
}
function smma (dataInput, dataOutput, calculatedLength, period) {
var i = calculatedLength
var sum = 0
if (i > 0) {
i--
} else {
i = period - 1
for (var j = 1; j < period; j++) {
dataOutput[i - j] = 0
sum += dataInput[i - j]
}
sum += dataInput[i]
dataOutput[i] = sum / period
i++
}
while (i < dataInput.length) {
sum = dataOutput[i - 1] * period - dataOutput[i - 1] + dataInput[i]
dataOutput[i] = sum / period
i++
}
}
function lwma (dataInput, dataOutput, calculatedLength, period) {
var i = calculatedLength
if (i > 0) {
i--
} else {
for (var j = 0; j < period - 1; j++) {
dataOutput[j] = 0
}
i = period - 1
}
var sum = 0
var diffsum = 0
var weight = 0
for (var j = 1; j < period; j++) {
sum += dataInput[i - j] * (period - j)
diffsum += dataInput[i - j]
weight += j
}
weight += period
while (i < dataInput.length) {
sum += dataInput[i] * period
dataOutput[i] = sum / weight
diffsum += dataInput[i]
sum -= diffsum
diffsum -= dataInput[i - period + 1]
i++
}
}