Create a strategy based on Supertrend, FREMA, and TTM?


Well-known member
I've been trying to create a strategy using the Supertrend, FREMA, and TTM Trend indicators. The conditions I want in the strategy are as follows.

Entry Long- [All 3 show green] This would be triggered by a switch from less then 3 showing green to all 3 showing green at the close of the candle. For example the FREMA and TTM Trend are showing green going into the start of a candle, during the candle the Supertrend changes to green. This would trigger a buy. This concept applies to all triggers.
Exit Long- [2/3 show red]
Enter Short- [All 3 show red]
Exit Short- [2/3 show green]

The reason I'm looking for help is because I am very new to thinkscript and when I attempt it the entrys and exits do not line up to what I wanted. If someone could help me get this into code It would be easy for me to understand the logic going forward to improve this strategy by possibly adding more conditions. If you guys have any questions please ask, I would love any help on this.

Here is a link with the three studies in LED bars. Supertrend and Frema are combined in one study.
Order on the bottom is
  • TTM
  • Supertrend
  • Frema
An example of a trigger would be a short sell trigger at the open of 12:36 after 3/3 close red, this short sell would be flattened at the open of 13:36 when 2/3 closed green at 13:35.

Here is the components of the code.
# Inputs:
input AA = .1;

# Vars:
def CC;
def zeroline = 0;
def RE1;
def RE2;
def RE3;
def RE4;
def RE5;
def RE6;
def RE7;
def RE8;
def EMA;

CC = if CC[1] == 0 then .9 else 1 – AA;
EMA = AA * close + CC * EMA[1];
RE1 = CC * EMA + EMA[1];
RE2 = Power(CC, 2) * RE1 + RE1[1];
RE3 = Power(CC, 4) * RE2 + RE2[1];
RE4 = Power(CC, 8) * RE3 + RE3[1];
RE5 = Power(CC, 16) * RE4 + RE4[1];
RE6 = Power(CC, 32) * RE5 + RE5[1];
RE7 = Power(CC, 64) * RE6 + RE6[1];
RE8 = Power(CC, 128) * RE7 + RE7[1];

def EMA_Signal = EMA – AA * RE8;
def FREMAdown = EMA_Signal < zeroLine;
def FREMAup = EMA_Signal > zeroLine;

input Mult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;
input paintbars = yes;
def x = close;
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (Mult * ATR);
def DN = HL2 + (-Mult * ATR);
#"green" else "red"
def AG = if x < AG[1] then UP else DN;
input compBars = 6;
plot algotrend = AG;

input compBars2 = 6;
def TrendUp = Double.NaN;
def TrendDown = Double.NaN;
Last edited by a moderator:
@YungTraderFromMontana I just saw this...are you still tinkering with this set up? SuperTrends work good on lower timeframes...the higher you go on a timeframe the less likely a SuperTrend will catch pullbacks in time...From my testing I found the best is to use sensitive studies like Stochastics FULL or Stoch RSI on higher timeframes...and trading in the direction set by those higher timeframes 15m+ and then trade on lower time frames using SuperTrend on anything lower than 5 min...

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
307 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.