FRAMA Fractal Adaptive Moving Average with Standard Deviation Bands For ThinkOrSwim

FRAMA Fractal Adaptive Moving Average with Standard Deviation Bands For ThinkOrSwim
found on OneNote
Ruby:
Mobius©: # FRAMA Fractal Adaptive Moving Average with Standard Deviation Bands
# Mobius
# Mobius on MyTrade
# V01.07.2013

input n = 16;
input price = HL2;
input SDmult = 3;
input DisplayBands = yes;

def n1;
def n2;
def n3;
def hh;
def ll;
def dimen;
def alpha;
def filt;

N3 = (Highest(high, N) - Lowest(low, N)) / N;
HH = high;
LL = low;

def count = fold i = 0 to (n/2)
            with p
            do if GetValue(HH, GetMaxValueOffset(hh, n/2), n) > HH
               then GetValue(HH, GetMaxValueOffset(hh, n/2), n)
            else if GetValue(LL, GetMinValueOffset(ll, n/2), n) < LL
                 then GetValue(LL, GetMinValueOffset(ll, n/2), n)
            else count[1];

N1 = (HH - LL) / (N/2);
def HH1 = high[n/2];
def LL1 = low[n/2];
def count2 = fold j = n/2 to n
             with q
             do if GetValue(HH1, GetMaxValueOffset(HH1, n/2), n) > HH1
                then GetValue(HH1, GetMaxValueOffset(HH1, n/2), n)
             else if GetValue(LL1, GetMinValueOffset(LL1, n/2), n) < LL1
                  then GetValue(LL1, GetMinValueOffset(LL1, n/2), n)
             else count[1];

N2 = (count - count2) / (N / 2);
dimen = if N1 > 0 and N2 > 0 and N3 > 0 then (Log(N1 + N2) - Log(N3)) / Log(2) else 0;
alpha = if Dimen == .7
        then .02
        else if Dimen == .05
        then .33
        else if Exp(-4.6*(Dimen - 1)) < .01
        then .01
        else if Exp(-4.6* (Dimen - 1)) > 1 then 1
        else 0;
Filt = alpha * Price + (1 - alpha) * Filt[1];

plot FRAMA = Inertia(filt, n);
     FRAMA.SetDefaultColor(Color.Yellow);

def SD = StDev(close, n);

plot upper = FRAMA + (SDmult * SD);
     upper.SetHiding(!DisplayBands);
     upper.SetDefaultColor(CreateColor(50,50,50));
plot lower = FRAMA - (SDmult * SD);
     lower.SetHiding(!DisplayBands);
     lower.SetDefaultColor(CreateColor(50,50,50));
 
Last edited:

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
214 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