Blackflag FTS indicator
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Blackflag FTS indicator
- This topic has 2 replies, 2 voices, and was last updated 3 days ago by
Stenozar.
-
-
03/26/2025 at 5:12 PM #245324
Buon pomeriggio, chiedo la traduzione del seguente indicatore.
Grazie
//@version=6
indicator(“Blackflag FTS”, overlay = true)// inputs
trailType = input.string(“modified”, title = “Trailtype”, options = [“modified”, “unmodified”])
ATRPeriod = input.int(28, title = “ATR Period”)
ATRFactor = input.int(12, title = “ATR Factor”)
show_fib_entries = input.bool(true, title = “Show Fib Entries?”)norm_o = request.security(syminfo.tickerid, timeframe.period, open)
norm_h = request.security(syminfo.tickerid, timeframe.period, high)
norm_l = request.security(syminfo.tickerid, timeframe.period, low)
norm_c = request.security(syminfo.tickerid, timeframe.period, close)//////// FUNCTIONS //////////////
Wild_ma(_src, _malength) =>
var _wild = 0.0
_wild := na(_wild[1]) ? _src : _wild[1] + (_src – _wild[1]) / _malength/////////// TRUE RANGE CALCULATIONS /////////////////
HiLo = math.min(norm_h – norm_l, 1.5 * ta.sma((norm_h – norm_l), ATRPeriod))HRef = norm_l <= norm_h[1] ?
norm_h – norm_c[1] :
(norm_h – norm_c[1]) – 0.5 * (norm_l – norm_h[1])LRef = norm_h >= norm_l[1] ?
norm_c[1] – norm_l :
(norm_c[1] – norm_l) – 0.5 * (norm_l[1] – norm_h)trueRange =
trailType == “modified” ? math.max(HiLo, HRef, LRef) :
math.max(norm_h – norm_l, math.abs(norm_h – norm_c[1]), math.abs(norm_l – norm_c[1]))/////////// TRADE LOGIC ////////////////////////
loss = ATRFactor * Wild_ma(trueRange, ATRPeriod)Up = norm_c – loss
Dn = norm_c + lossvar TrendUp = Up
var TrendDown = Dn
var Trend = 1 // Initialize Trend as long (1)TrendUp := norm_c[1] > TrendUp[1] ? math.max(Up, TrendUp[1]) : Up
TrendDown := norm_c[1] < TrendDown[1] ? math.min(Dn, TrendDown[1]) : DnTrend := norm_c > TrendDown[1] ? 1 : norm_c < TrendUp[1] ? -1 : Trend[1]
trail = Trend == 1 ? TrendUp : TrendDownex = 0.0
ex :=
ta.crossover(Trend[1], 0) ? norm_h :
ta.crossunder(Trend[1], 0) ? norm_l :
Trend == 1 ? math.max(ex[1], norm_h) :
Trend == -1 ? math.min(ex[1], norm_l) : ex[1]////// FIBONACCI LEVELS ///////////
state = Trend == 1 ? “long” : “short”fib1Level = 61.8
fib2Level = 78.6
fib3Level = 88.6f1 = ex + (trail – ex) * fib1Level / 100
f2 = ex + (trail – ex) * fib2Level / 100
f3 = ex + (trail – ex) * fib3Level / 100
l100 = trail + 0Fib1 = plot(f1, title = “Fib 1”, style = plot.style_line, color = color.black)
Fib2 = plot(f2, title = “Fib 2”, style = plot.style_line, color = color.black)
Fib3 = plot(f3, title = “Fib 3”, style = plot.style_line, color = color.black)
L100 = plot(l100, title = “l100”, style = plot.style_line, color = color.black)fill(Fib1, Fib2, color = state == “long” ? color.green : state == “short” ? color.red : na)
fill(Fib2, Fib3, color = state == “long” ? color.new(color.green, 70) : state == “short” ? color.new(color.red, 70) : na)
fill(Fib3, L100, color = state == “long” ? color.new(color.green, 60) : state == “short” ? color.new(color.red, 60) : na)l1 = state[1] == “long” and ta.crossunder(norm_c, f1[1])
l2 = state[1] == “long” and ta.crossunder(norm_c, f2[1])
l3 = state[1] == “long” and ta.crossunder(norm_c, f3[1])
s1 = state[1] == “short” and ta.crossover(norm_c, f1[1])
s2 = state[1] == “short” and ta.crossover(norm_c, f2[1])
s3 = state[1] == “short” and ta.crossover(norm_c, f3[1])atr = ta.sma(trueRange, 14)
/////////// FIB PLOTS /////////////////
plotshape(show_fib_entries and l1 ? low – atr : na, title = “LS1”, style = shape.triangleup, location = location.belowbar, color = color.yellow, size = size.tiny)
plotshape(show_fib_entries and l2 ? low – 1.5 * atr : na, title = “LS2”, style = shape.triangleup, location = location.belowbar, color = color.yellow, size = size.tiny)
plotshape(show_fib_entries and l3 ? low – 2 * atr : na, title = “LS3”, style = shape.triangleup, location = location.belowbar, color = color.yellow, size = size.tiny)
plotshape(show_fib_entries and s1 ? high + atr : na, title = “SS1”, style = shape.triangledown, location = location.abovebar, color = color.purple, size = size.tiny)
plotshape(show_fib_entries and s3 ? high + 2 * atr : na, title = “SS3″, style = shape.triangledown, location = location.abovebar, color = color.purple, size = size.tiny)/////////// ADDING BUY and SELL INDICATORS ////////////
// Conditions for Trend Change (Green -> Red or Red -> Green)
trendChangeToRed = Trend == -1 and Trend[1] == 1 // Green to Red
trendChangeToGreen = Trend == 1 and Trend[1] == -1 // Red to Green// Plot only the color changes without text
plotshape(trendChangeToRed, title=”Trend Change to Red”, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
plotshape(trendChangeToGreen, title=”Trend Change to Green”, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)// Adding Alerts for Trend Change
alertcondition(trendChangeToRed, title=”Trend Change to Red”, message=”Trend changed from Green to Red.”)
alertcondition(trendChangeToGreen, title=”Trend Change to Green”, message=”Trend changed from Red to Green.”)03/27/2025 at 10:15 AM #245333Ecco
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135//------------------------------------------------////PRC_BlackFlags FTS//version = 0//27.03.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//------------------------------------------------//// Inputs//------------------------------------------------//trailType=1 //modified=1 unmodified=0atrPeriod=28atrFactor=5ShowFibEntries=0//------------------------------------------------//// True Range Calculations//------------------------------------------------//HiLo=min(high-low,1.5*average[atrPeriod](high-low))if low<=high[1] thenHref=high-close[1]elseHref=(high-close[1])-0.5*(low-high[1])endifif high>=low[1] thenLref=close[1]-lowelseLref=(close[1]-low)-0.5*(low[1]-high)endifif trailType=1 thentrueRange=max(HiLo,max(Href,Lref))elsetrueRange=max(high-low,max(abs(high-close[1]),abs(low-close[1])))endif//------------------------------------------------//// Trade Logic//------------------------------------------------//wildMa=WilderAverage[atrPeriod](trueRange)iloss=atrFactor*wildMaup=close-ilossdn=close+ilosstrendUp=uptrendDown=dntrend=1if close[1]>trendUp[1] thenTrendUp=max(Up,TrendUp[1])elseTrendUp=Upendifif close[1]<trendDown[1] thentrendDown=min(Dn,trendDown[1])elsetrendDown=Dnendifif close>trendDown[1] thenTrend=1elsif close<TrendUp[1] thenTrend=-1elseTrend=Trend[1]endifif trend=1 thentrail=TrendUpr=0g=255b=0rex=0gex=230bex=118elsetrail=TrendDownr=255g=0b=0rex=225gex=64bex=251endifex=0if trend crosses over 0 thenex=highelsif trend crosses under 0 thenex=lowelsif trend=1 thenex=max(ex[1],high)elsif trend=-1 thenex=min(ex[1],low)elseex=ex[1]endif//------------------------------------------------//// Fibonacci levels//------------------------------------------------//fib1Level=61.8fib2Level=78.6fib3Level=88.6f1=ex+(trail-ex)*fib1Level/100f2=ex+(trail-ex)*fib2Level/100f3=ex+(trail-ex)*fib3Level/100l100=trailcolorbetween(f1,f2,r,g,b,90)colorbetween(f3,f2,r,g,b,45)colorbetween(f3,l100,r,g,b,23)//------------------------------------------------//// Signals//------------------------------------------------//atr=averagetruerange[14](close)if ShowFibEntries=1 thenif trend=1 and close crosses under f3[1] thendrawtext("▲",barindex,low-2*atr)coloured("orange")elsif trend=1 and close crosses under f2[1] thendrawtext("▲",barindex,low-1.5*atr)coloured("orange")elsif trend=1 and close crosses under f1[1] thendrawtext("▲",barindex,low-1*atr)coloured("orange")elsif trend=-1 and close crosses over f3[1] thendrawtext("▼",barindex,high+2*atr)coloured("purple")elsif trend=-1 and close crosses over f2[1] thendrawtext("▼",barindex,high+1.5*atr)coloured("purple")elsif trend=-1 and close crosses over f1[1] thendrawtext("▼",barindex,high+1*atr)coloured("purple")endifendif//------------------------------------------------//return f1 as "Fib1"style(line,1), f2 as "Fib2"style(line,1),f3 as "Fib3"style(line,1),l100 as "L100"style(line,1),trail as "trailing stop" coloured(r,g,b)style(line,2),ex as "extremun" coloured(rex,gex,bex)style(point,2)03/27/2025 at 9:27 PM #245366 -
AuthorPosts