You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.
Have I written custom code (as opposed to using zenbot vanilla): No
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): ubuntu 16.04
Zenbot version (commit ref, or version): latest
Zenbot branch: unstable
NodeJS version:
Python version (when using a python script):
Exact command to reproduce (include everything): Comparing output with TV
Did I make any changes to conf-sample.js?: No
Describe the problem
Zenbot actually lags behind one candle when you compare to the output of Tradingview, after some troubleshooting I found that everything is calculated on lookback[0] but the current s.period is not pushed to that array so the functionality at the end of a candle is not correct when going for averages like EMA.
It does not calculated from the current s.period data but always from the previous one, which is even incorrect I believe for most of the formula.
Source code / Error logs
I have some issues uploading to Git since a while so I can't create the pull request myself.
Example for ema.js where I would make a change for myself, so basically taking one less input from the lookback and adding the current s.period value instead.
module.exports = function ema (s, key, length, source_key) {
if (!source_key) source_key = 'close'
if (s.lookback.length >= length) {
var prev_ema = s.lookback[0][key]
if (typeof prev_ema === 'undefined' || isNaN(prev_ema)) {
var sum = 0
s.lookback.slice(0, length -1 ).forEach(function (period) {
sum += period[source_key]
}) sum += s.period[source_key]
prev_ema = sum / length
}
var multiplier = 2 / (length + 1)
s.period[key] = (s.period[source_key] - prev_ema) * multiplier + prev_ema
}
}
The text was updated successfully, but these errors were encountered:
Can you "prove" that its wrong by a citation With the right formular? As you are adding the current source key to Previos ema calculation it does not make any sense for me w/o a citation.
Edit Hint: i am not claiming that the formula is correct, but this changes looks not right for me
edit 2: i searched a citation by myself. Its not the best source, but it is one. http://investexcel.net/how-to-calculate-ema-in-excel/
here the "first" ema value is valculated for values until line 16. the next line does NOT include the current close, so for me it seems still wrong to include it into sum for previous.
System information
Describe the problem
Zenbot actually lags behind one candle when you compare to the output of Tradingview, after some troubleshooting I found that everything is calculated on lookback[0] but the current s.period is not pushed to that array so the functionality at the end of a candle is not correct when going for averages like EMA.
It does not calculated from the current s.period data but always from the previous one, which is even incorrect I believe for most of the formula.
Source code / Error logs
I have some issues uploading to Git since a while so I can't create the pull request myself.
Example for ema.js where I would make a change for myself, so basically taking one less input from the lookback and adding the current s.period value instead.
module.exports = function ema (s, key, length, source_key) {
if (!source_key) source_key = 'close'
if (s.lookback.length >= length) {
var prev_ema = s.lookback[0][key]
if (typeof prev_ema === 'undefined' || isNaN(prev_ema)) {
var sum = 0
s.lookback.slice(0, length -1 ).forEach(function (period) {
sum += period[source_key]
})
sum += s.period[source_key]
prev_ema = sum / length
}
var multiplier = 2 / (length + 1)
s.period[key] = (s.period[source_key] - prev_ema) * multiplier + prev_ema
}
}
The text was updated successfully, but these errors were encountered: