0% found this document useful (0 votes)
214 views1 page

TTK Code

This document describes a SuperTrend trading strategy that uses two timeframes. It defines SuperTrend calculations for a main and shorter timeframe. Signals are generated when the shorter timeframe crosses into a new direction and validates the main timeframe's direction. Positions are taken long when the shorter timeframe turns up and validates the main timeframe's up trend. Positions are taken short when the shorter timeframe turns down and validates the main timeframe's down trend.

Uploaded by

raydipanjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
214 views1 page

TTK Code

This document describes a SuperTrend trading strategy that uses two timeframes. It defines SuperTrend calculations for a main and shorter timeframe. Signals are generated when the shorter timeframe crosses into a new direction and validates the main timeframe's direction. Positions are taken long when the shorter timeframe turns up and validates the main timeframe's up trend. Positions are taken short when the shorter timeframe turns down and validates the main timeframe's down trend.

Uploaded by

raydipanjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//@version=2

//supertrend strategy multitimeframe analysis...

strategy("TTK TOOL", overlay=true, default_qty_value=100)


res = input(title="Main SuperTrend Time Frame", type=resolution, defval="720")
Factor=input(2, minval=1,maxval = 100)
Pd=input(10, minval=1,maxval = 100)

tp = input(500,title="Take Profit")
sl = input(400,title="Stop Loss")

Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
MUp=security(tickerid,res,hl2-(Factor*atr(Pd)))
MDn=security(tickerid,res,hl2+(Factor*atr(Pd)))

Mclose=security(tickerid,res,close)

TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn

MTrendUp=Mclose[1]>MTrendUp[1]? max(MUp,MTrendUp[1]) : MUp


MTrendDown=Mclose[1]<MTrendDown[1]? min(MDn,MTrendDown[1]) : MDn

Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)


Tsl = Trend==1? TrendUp: TrendDown

MTrend = Mclose > MTrendDown[1] ? 1: Mclose< MTrendUp[1]? -1: nz(MTrend[1],1)


MTsl = MTrend==1? MTrendUp: MTrendDown

linecolor = Trend == 1 ? green: red


plot(Tsl, color = linecolor , style = line , linewidth = 4,title = "SuperTrend")

Mlinecolor = MTrend == 1 ? black : red


plot(MTsl, color = Mlinecolor , style = line , linewidth = 4,title = "Main
SuperTrend")

plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow",


shape.triangleup,location.belowbar,black,0,0)
plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown ,
location.abovebar, black,0,0)
up = Trend == 1 and Trend[1] == -1 and MTrend == 1
down = Trend == -1 and Trend[1] == 1 and MTrend == -1

golong = Trend == 1 and Trend[1] == -1 and MTrend == 1


goshort = Trend == -1 and Trend[1] == 1 and MTrend == -1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy