check my code for Dynamic Retracement Target for ThinkorSwim

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/

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:
I tried to convert Dynamic Retracement Target for ThinkorSwim. However, my code doesn't show any signals. 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/

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;
It does show right signals in one-min chart, but not in higher timeframes.
 
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/

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;

i stared at the codes, pine and yours for awhile. it looks good.
i loaded your tos code and it works for me , on all the time frames i pick. 1 min up to week.
there is a split second pause after picking the time frame, before the lines appear...
not sure why it doesn't work for you.
 
i stared at the codes, pine and yours for awhile. it looks good.
i loaded your tos code and it works for me , on all the time frames i pick. 1 min up to week.
there is a split second pause after picking the time frame, before the lines appear...
not sure why it doesn't work for you.
Thank you very much for feedback. I restart ThinkorSwim system. But It still only works in one-min timeframe, not in higher timeframes. I add following code in order to force it to use daily timeframe. It still doesn't work in my computer.

input aggregationPeriod = AggregationPeriod.DAY;
def close = close(period = aggregationPeriod);

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;
input aggregationPeriod = AggregationPeriod.DAY;
def close = close(period = aggregationPeriod);
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:
Thank you very much for feedback. I restart ThinkorSwim system. But It still only works in one-min timeframe, not in higher timeframes. I add following code in order to force it to use daily timeframe. It still doesn't work in my computer.

input aggregationPeriod = AggregationPeriod.DAY;
def close = close(period = aggregationPeriod);

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;
input aggregationPeriod = AggregationPeriod.DAY;
def close = close(period = aggregationPeriod);
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;
they do maintenance some friday nights, like tonight. maybe it affects some users worse than others. in the past , there were mauntenence nights where my charts would not load.

other thoughts,
how many studies do you have loaded?
every one uses resources.

long shot, check computer,
i have an i7 laptop , with cat5 , to 100mb internet. i don't want to rely on wifi, across my house.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
331 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top