BenTen
Administrative
Staff
VIP
Please post the whole script. Is this based on the Supertrend indicator?
# Mobius
# SuperTrend
# Chat Room Request
# V03.10.2015
# Written as Strategy: Added alerts and label for cycle counts.
# Altered default settings for values that made more sense on Intraday Futures. Added Color and ColorBars.
#Hint:Supertrend Indicator: shows trend direction and gives buy or sell signals according to that. It is based on a combination of the average price rate in the current period along with a volatility indicator. The ATR indicator is most commonly used as volatility indicator. The values are calculated as follows:
# Up = (HIGH + LOW) / 2 + Multiplier * ATR
# Down = (HIGH + LOW) / 2 – Multiplier * ATR
# When the change of trend occurs, the indicator flips
# For RP: Add AR trend, Aberrant Vol, R State, PTR
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
input BubbleOn = no;
input ShowLabel = no;
input AlertOn = no;
input PlotLine = no;
def h = high;
def l = low;
def c = close;
def v = volume;
def bar = barNumber();
def EOD = if SecondsTillTime(1545) == 0 and
SecondsFromTime(1545) == 0
then 1
else 0;
def NotActive = if SecondsFromTime(1545) > 0
then 1
else 0;
def ATR = MovingAverage(AvgType, TrueRange(h, c, l), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if c < ST[1]
then Round(UP / tickSize(), 0) * tickSize()
else Round(DN / tickSize(), 0) * tickSize();
plot SuperTrend = ST;
SuperTrend.SetHiding(!PlotLine);
SuperTrend.AssignValueColor(if c < ST then Color.RED else Color.GREEN);
SuperTrend.SetPaintingStrategy(PaintingStrategy.Line);
AssignPriceColor(if PaintBars and c < ST
then Color.RED
else if PaintBars and c > ST
then Color.GREEN
else Color.CURRENT);
plot ST_point = if isNaN(close[-1])
then ST
else double.nan;
ST_point.SetStyle(Curve.Points);
ST_point.SetLineWeight(3);
ST_point.SetDefaultColor(Color.Yellow);
plot ST_value = if isNaN(close[-1])
then ST_point
else double.nan;
ST_value.SetPaintingStrategy(PaintingStrategy.Values_Below);
ST_value.SetDefaultColor(color.yellow);
AddChartBubble(BubbleOn and c crosses below ST, l[1], l[1], Color.DARK_GRAY);
AddChartBubble(BubbleOn and c crosses above ST, h[1], h[1], Color.DARK_GRAY, no);
Alert(AlertOn and c crosses below ST, "c " + c, Alert.BAR, Sound.Chimes);
Alert(AlertOn and c crosses above ST, "c" + c, Alert.Bar, Sound.Ring);
def upBars = if c < ST
then upBars[1] + 1
else upBars[1];
def upCycles = if c < ST and c[1] > ST[1]
then upCycles[1] + 1
else upCycles[1];
def dnBars = if c > ST
then dnBars[1] + 1
else dnBars[1];
def dnCycles = if c > ST and c[1] < ST[1]
then dnCycles[1] + 1
else dnCycles[1];
def upCycleCount = upBars / upCycles;
def dnCycleCount = dnBars / dnCycles;
def thisCycle = if c < ST and c[1] > ST[1]
then 1
else if c < ST
then thisCycle[1] + 1
else if c > ST and c[1] < ST[1]
then 1
else if c > ST
then thisCycle[1] + 1
else thisCycle[1];
def Volup = (fold i = 0 to thisCycle
do if i > 0
then VolUp[1] + v
else Volup[1]) / thisCycle;
AddLabel(ShowLabel, "Up Bars = " + upBars + "; " +
" Up Cycles = " + upCycles + "; " +
" Dn Bars = " + dnBars + "; " +
" Dn Cycles = " + dnCycles + "; " +
" Avg Up Cycle Count = " + Round(upCycleCount, 0) +
" Avg Dn Cycle Count = " + Round(dnCycleCount, 0) +
" This Cycle = " + thisCycle, Color.WHITE);
# End Code SuperTrend
I mean from supertrend code@Mneef What do you mean "the last version"? Did you watch the video above? Did you use the script I linked?
Thank you very much !
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
SuperTrend and RSI Laguerre Indicator for ThinkorSwim | Indicators | 16 | ||
T | Supertrend Conditional Order | Questions | 2 | |
J | Convert Fibonacci SuperTrend from NinjaTrader? | Questions | 4 | |
L | Help converting Pivot Point Supertrend to thinkscript | Questions | 1 | |
R | 3 SuperTrend + Support and Resistance Level Strategy for ThinkorSwim | Strategies | 56 |