-
-
Save Fyzu/8886da964aa2fb023562ae1f51347107 to your computer and use it in GitHub Desktop.
dxScript JS API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input.n = 9 | |
const n = input.n | |
let logPrice = ResultSeries.apply("logPrice", () => { return Math.log(close.last()) }) | |
let logPrevPrice = ResultSeries.apply("logPrevPrice", () => { return Math.log(close.last(1)) }) | |
let triple = trix(logPrice, n); | |
let triplePrev = trix1(logPrevPrice, n) | |
output.TRIX = (triple - triplePrev) * 10000 | |
function trix(x, n) { | |
let ema1 = ResultSeries.apply("compute", () => { | |
return Ema1.init("ema1").compute(x, n); | |
}); | |
let ema2 = ResultSeries.apply("compute2", () => { | |
return Ema1.init("ema2").compute(ema1, n); | |
}) | |
return Ema1.init("ema3").compute(ema2, n); | |
} | |
function trix1(x, n) { | |
let ema1 = ResultSeries.apply("compute_", () => { | |
return Ema1.init("ema1_").compute(x, n); | |
}); | |
let ema2 = ResultSeries.apply("compute2_", () => { | |
return Ema1.init("ema2_").compute(ema1, n); | |
}) | |
return Ema1.init("ema3_").compute(ema2, n); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useInput = (name, def, desc) => input[name] === undefined ? def : input[name] | |
let seriesCounter = 0 | |
const useSeries = (value) => { | |
const series = ResultSeries.apply(seriesCounter.toString(), () => value) | |
seriesCounter++; | |
return series | |
} | |
const useOutput = (name, value) => output[name] = value | |
const ema = (series, n) => { | |
const value = Ema1.init(seriesCounter.toString()).compute(series, n) | |
seriesCounter++; | |
return value | |
} | |
// script code | |
const n = useInput("n", 9, "Depth") | |
const logPrice = useSeries(Math.log(close.last())); | |
const logPrevPrice = useSeries(Math.log(close.last(1))); | |
const triple = trix(logPrice, n); | |
const triplePrev = trix(logPrevPrice, n) | |
useOutput("TRIX", (triple - triplePrev) * 10000) | |
function trix(x, n) { | |
const ema1 = useSeries(ema(x, n)); | |
const ema2 = useSeries(ema(ema1, n)); | |
return ema(ema2, n) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in n = 9 | |
def logPrice = close.ln() | |
def logPricePrev = close[1].ln() | |
def triple = trix(logPrice, n) | |
def triplePrev = trix(logPricePrev, n) | |
out TRIX = (triple - triplePrev) * 10000 | |
fun trix { | |
in x: number | |
in n: const number | |
def ema1 = x.ema(n) // 9 | |
def ema2 = ema1.ema(n) // 18 | |
out = ema2.ema(n) // 27 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input.n = 9 | |
const n = input.n | |
let logPrice = ResultSeries.apply("logPrice", () => { return Math.log(close.last()) }) | |
let logPrevPrice = ResultSeries.apply("logPrevPrice", () => { return Math.log(close.last(1)) }) | |
let triple = trix(logPrice, n); | |
let triplePrev = trix1(logPrevPrice, n) | |
output.TRIX = (triple - triplePrev) * 10000 | |
function trix(x, n) { | |
let ema1 = ResultSeries.apply("compute", () => { | |
return Ema1.init("ema1").compute(x, n); | |
}); | |
let ema2 = ResultSeries.apply("compute2", () => { | |
return Ema1.init("ema2").compute(ema1, n); | |
}) | |
return Ema1.init("ema3").compute(ema2, n); | |
} | |
function trix1(x, n) { | |
let ema1 = ResultSeries.apply("compute_", () => { | |
return Ema1.init("ema1_").compute(x, n); | |
}); | |
let ema2 = ResultSeries.apply("compute2_", () => { | |
return Ema1.init("ema2_").compute(ema1, n); | |
}) | |
return Ema1.init("ema3_").compute(ema2, n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment