petergluis
Active member
I tried to convert Dynamic Retracement Target for ThinkorSwim. However, my code doesn't show any signals in daily timeframe. Could you please help me to check my code and see what is wrong with it?
https://www.tradingview.com/script/xFsGprP4-Dynamic-Retracement-Target/
https://www.tradingview.com/script/xFsGprP4-Dynamic-Retracement-Target/
Ruby:
def Period_fast = 34;
def Period_medium = 144;
def Period_slow = 610;
def Target_level_superior = 1.236;
def Fib_level_sup = 0.764;
def Fib_level_mid = 0.500;
def Fib_level_inf = 0.236;
def Target_level_inferior = -0.236;
script ALMA {
input Data = close;
input Window = 9;
input Sigma = 6;
input Offset = 0.85;
def m = (Offset * (Window - 1));
def s = Window / Sigma;
def SumVectorData = fold y = 0 to Window with WS do WS + Exp(-(Sqr(y - m)) / (2 * Sqr(s))) * GetValue(Data, (Window - 1) - y);
def SumVector = fold z = 0 to Window with CW do CW + Exp(-(Sqr(z - m)) / (2 * Sqr(s)));
plot ALMA = SumVectorData / SumVector;
}
def mf = alma(close, Period_fast, 0.786, 3.236);
def mm = alma(close, Period_medium, 0.786, 3.236);
def ms = alma(close, Period_slow, 0.786, 3.236);
def ta = max (mf, mm);
def tb = min (mf,mm);
def highest_alma = Max(ta, ms);
def lowest_alma = Min(tb, ms);
def A_level_superior = lowest_alma + (highest_alma - lowest_alma) * Target_level_superior;
def A_sup = highest_alma;
def A_level_sup = lowest_alma + (highest_alma - lowest_alma) * Fib_level_sup;
def A_level_mid = lowest_alma + (highest_alma - lowest_alma) * Fib_level_mid;
def A_level_inf = lowest_alma + (highest_alma - lowest_alma) * Fib_level_inf;
def A_inf = lowest_alma;
def A_level_inferior = lowest_alma + (highest_alma - lowest_alma) * Target_level_inferior;
plot ALevelSuperior = A_level_superior;
plot ASup = A_sup;
plot ALevelSup = A_level_sup;
plot ALevelMid = A_level_mid;
plot ALevelInf = A_level_inf;
plot AInf = A_inf;
plot ALevelInferior = A_level_inferior;
Last edited: