FTL
FTL
study("FTL", overlay=true)
// INPUTS:
lenFast = input(1, title="Length of Fast ", type=input.integer, minval=1)
lenSlow = input(5, title="Length of Slow ", type=input.integer, minval=1)
lenC = input(10, title="Length of Curve", type=input.integer, minval=1)
//@version=4
///study(title="Candles", shorttitle="Candles", format=format.price, precision=4,
overlay=false)
plot(signal, color=color.orange)
//@version=4
// Copyright (c) 2021-present, Alex Orekhov (everget)
///study("HalfTrend", overlay=true)
atr2 = atr(100) / 2
dev = channelDeviation * atr2
highPrice = high[abs(highestbars(amplitude))]
lowPrice = low[abs(lowestbars(amplitude))]
highma = sma(high, amplitude)
lowma = sma(low, amplitude)
if nextTrend == 1
maxLowPrice := max(lowPrice, maxLowPrice)
if trend == 0
if not na(trend[1]) and trend[1] != 0
up := na(down[1]) ? down : down[1]
arrowUp := up - atr2
else
up := na(up[1]) ? maxLowPrice : max(maxLowPrice, up[1])
atrHigh := up + dev
atrLow := up - dev
else
if not na(trend[1]) and trend[1] != 1
down := na(up[1]) ? up : up[1]
arrowDown := down + atr2
else
down := na(down[1]) ? minHighPrice : min(minHighPrice, down[1])
atrHigh := down + dev
atrLow := down - dev
ht = trend == 0 ? up : down
// @version=4
////study("Dynamic Structure Indicator v2.0", shorttitle="DSI", overlay=true)
// Get highest body and lowest body for the current candle
highestBody = open > close ? open : close
lowestBody = open > close ? close : open
// Set up our persistent S&R variables (1 = the wick and 2 = the body)
var res1 = 0.0
var res2 = 0.0
var sup1 = 0.0
var sup2 = 0.0
var lookForNewResistance = true
var lookForNewSupport = true
// Set up our *previous* support & resistance variables (for drawing support-
turned-resistance etc)
var previousRes1 = 0.0
var previousRes2 = 0.0
var previousSup1 = 0.0
var previousSup2 = 0.0
// Check if potential resistance zone has already been violated. If it has, reset
our potential R1 & R2
if close > potentialR1 and barstate.isconfirmed
potentialR1 := na
potentialR2 := na
// Check if potential support zone has already been violated. If it has, reset our
potential S1 & S2
if close < potentialS1 and barstate.isconfirmed
potentialS1 := na
potentialS2 := na
// If the previous resistance high has been violated then begin searching for a new
resistance zone
if close >= res1 and barstate.isconfirmed
lookForNewResistance := true
lookForNewSupport := true
resCount := resCount + 1
// If the previous support low has been violated then begin searching for a new
support zone
if close <= sup1 and barstate.isconfirmed
lookForNewSupport := true
lookForNewResistance := true
supCount := supCount + 1
// If our current resistance zone has been violated, store its values to draw new
*potential* support zone
// The idea being that once a major resistance zone is violated it often becomes
future support
// But we only save previous S&R if we don't already have one saved (or our zone
update count exceeds newStructureReset)
if (close > res1 and na(previousRes1) and barstate.isconfirmed) or previousRes1 ==
0.0 or supCount >= newStructureReset
previousRes1 := res1
previousRes2 := res2
supCount := 0
// If our current support zone has been violated, store its values to draw new
*potential* resistance zone
// The idea being that once a major support zone is violated it often becomes
future resistance
// But we only save previous S&R if we don't already have one saved (or our zone
update count exceeds newStructureReset)
if (close < sup1 and na(previousSup1) and barstate.isconfirmed) or previousSup1 ==
0.0 or resCount >= newStructureReset
previousSup1 := sup1
previousSup2 := sup2
resCount := 0
// If our support-turned-resistance zone has been violated, reset our saved support
variables
if close > previousSup2 and barstate.isconfirmed
previousSup1 := na
previousSup2 := na
// Draw our current resistance zone
r1 = plot(res1 == res1[1] ? res1 : na, color=close >= res1 ? color.green :
color.red, style=plot.style_linebr, title="R1")
r2 = plot(res1 == res1[1] ? res2 : na, color=close >= res1 ? color.green :
color.red, style=plot.style_linebr, title="R2")
fill(r1, r2, color=close > res1 ? color.green : color.red, transp=50,
title="Resistance Zone")
// Trigger alerts
alertcondition(alertResistance or alertSupport or alertResistanceBO or
alertSupportBO, title="[DSI] Alert!", message="DSI alert for {{ticker}}")
alertcondition(alertResistance, title="[DSI] Resistance Alert", message="Price has
entered current potential resistance zone for {{ticker}}")
alertcondition(alertSupport, title="[DSI] Support Alert", message="Price has
entered current potential support zone for {{ticker}}")
alertcondition(alertResistanceBO, title="[DSI] Resistance Breakout", message="Price
has broken past potential resistance zone for {{ticker}}")
alertcondition(alertSupportBO, title="[DSI] Support Breakout", message="Price has
broken past potential support zone for {{ticker}}")