BelParticipant
New
Using 1440 period same fast and slow setting AMA (adaptive moving average) I get completely different results on PRT and TW. Maybe thats because on PRT i use Cash Contract and on TW its Emini futures? Tried on futures contract on PRT same thing completely different results. Any thoughts? Thanks in advance.
Regards,
Bel.
There can only be two reasons.
- Different data – which you will have as they are not using the same data feeds.
- Different calculation methods. You would need to provide the code for the TW AMA to compare with the PRT AMA.
BelParticipant
New
Thanks for reply Vonasi. It’s def the code from what I can tell. Can I paste the code here to have a quick glance if time permits:)?
Regards,
Bel.
Yes – Nicolas is the expert on other platform codes so hopefully he will be able to look at it.
BelParticipant
New
/
/@version=3
// Copyright (c) 2018-present, Alex Orekhov (everget)
// Adaptive Moving Average script may be freely distributed under the MIT license.
study("Adaptive Moving Average", shorttitle="AMA", overlay=true)
length = input(title="Length", type=integer, defval=14)
fastLength = input(title="Fast EMA Length", type=integer, defval=2)
slowLength = input(title="Slow EMA Length", type=integer, defval=30)
highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true)
src = input(title="Source", type=source, defval=close)
fastAlpha = 2 / (fastLength + 1)
slowAlpha = 2 / (slowLength + 1)
hh = highest(length + 1)
ll = lowest(length + 1)
mltp = hh - ll != 0 ? abs(2 * src - ll - hh) / (hh - ll) : 0
ssc = mltp * (fastAlpha - slowAlpha) + slowAlpha
ama = 0.0
ama := nz(ama[1]) + pow(ssc, 2) * (src - nz(ama[1]))
amaColor = highlightMovements ? (ama > ama[1] ? green : red) : #6d1e7f
plot(ama, title="AMA", linewidth=2, color=amaColor, transp=0)
Be so kind to always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read. Thank you 🙂
BelParticipant
New
Thats exactly what I wanted to do but read insert PRT code and thought TW won’t do:) My bad!
Thank you.
Regards,
Bel.
This is the code that returns exactly the same values as the platforms built in AMA. Hopefully Nicolas can tell if their are any differences.
Period = 9
FastPeriod = 2
SlowPeriod = 30
Fastest = 2 / (FastPeriod + 1)
Slowest = 2 / (SlowPeriod + 1)
if barindex < Period+1 then
Kama=close
else
Num = abs(close-close[Period])
Den = summation[Period](abs(close-close[1]))
ER = Num / Den
Alpha = SQUARE(ER *(Fastest - Slowest )+ Slowest)
KAMA = (Alpha * Close) + ((1 -Alpha)* Kama[1])
endif
return kama