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

  • Thread starter YungTraderFromMontana
  • Start date
YungTraderFromMontana

YungTraderFromMontana

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.
https://tos.mx/ZsBXz35

Here is the components of the code.
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;
#"red"
def FREMAdown = EMA_Signal < zeroLine;
#"green"
def FREMAup = EMA_Signal > zeroLine;

#Supertrend
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;

#TTM_Trend
input compBars2 = 6;
#"green"
def TrendUp = Double.NaN;
#"red"
def TrendDown = Double.NaN;
 
Last edited by a moderator:
H

HighBredCloud

Well-known member
VIP
@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...
 

Similar threads

Top