OPEN-SOURCE SCRIPT
FX MAN PRO

//version=5
indicator(title="FCB Signals with SMA, Momentum & Stochastic", shorttitle="FCB+AllFilters+Stoch", overlay=true)
// ---------- Inputs ----------
Pattern = input.int(1, "Pattern Length", minval=1)
showSignals = input.bool(true, "Show Buy/Sell Signals")
signalOffset = input.int(0, "Signal Offset", minval=-5, maxval=5)
smaFastLength = input.int(7, "SMA Fast")
smaSlowLength = input.int(21, "SMA Slow")
momentumLength = input.int(10, "Momentum Length")
// ---------- Stochastic Inputs ----------
stochKLength = input.int(14, "Stoch K Length")
stochDLength = input.int(3, "Stoch D Length")
stochSmooth = input.int(3, "Stoch Smooth")
stochOverbought = input.int(80, "Overbought Level")
stochOversold = input.int(20, "Oversold Level")
// ---------- Fractal Functions ----------
fractalUp(pattern) =>
p = high[pattern + 1]
okl = 1
okr = 1
res = 0.0
for i = pattern to 1
okl := high < high[i + 1] and okl == 1 ? 1 : 0
for i = pattern + 2 to pattern * 2 + 1
okr := high < high[i - 1] and okr == 1 ? 1 : 0
res := okl == 1 and okr == 1 ? p : res[1]
res
fractalDn(pattern) =>
p = low[pattern + 1]
okl = 1
okr = 1
res = 0.0
for i = pattern to 1
okl := low > low[i + 1] and okl == 1 ? 1 : 0
for i = pattern + 2 to pattern * 2 + 1
okr := low > low[i - 1] and okr == 1 ? 1 : 0
res := okl == 1 and okr == 1 ? p : res[1]
res
// ---------- Compute ----------
xUpper = fractalUp(Pattern)
xLower = fractalDn(Pattern)
// ---------- Hide FCB ----------
plot(xUpper, color=na, title="FCB Up")
plot(xLower, color=na, title="FCB Down")
// ---------- Candle Analysis ----------
body = math.abs(close - open)
shadowTop = high - math.max(open, close)
shadowBot = math.min(open, close) - low
strongBody = body > (shadowTop + shadowBot)
isGreen = close > open
isRed = close < open
// ---------- SMA ----------
smaFast = ta.sma(close, smaFastLength)
smaSlow = ta.sma(close, smaSlowLength)
// ---------- Momentum ----------
momentumValue = ta.mom(close, momentumLength)
// ---------- Stochastic ----------
kLine = ta.sma(ta.stoch(close, high, low, stochKLength), stochSmooth)
dLine = ta.sma(kLine, stochDLength)
// ---------- Stochastic Direction ----------
kUp = kLine > kLine[1]
dUp = dLine > dLine[1]
kDown = kLine < kLine[1]
dDown = dLine < dLine[1]
// ---------- Check Stochastic Neutral ----------
inNeutral = (kLine < stochOverbought and kLine > stochOversold) and (dLine < stochOverbought and dLine > stochOversold)
// ---------- First Candle Signal Logic ----------
var bool buyActive = false
var bool sellActive = false
buyCond = close > xUpper and strongBody and isGreen and smaFast > smaSlow and momentumValue > momentumValue[1] and kUp and dUp and inNeutral
sellCond = close < xLower and strongBody and isRed and smaFast < smaSlow and momentumValue < momentumValue[1] and kDown and dDown and inNeutral
buySignal = buyCond and not buyActive
sellSignal = sellCond and not sellActive
buyActive := buyCond ? true : not buyCond ? false : buyActive
sellActive := sellCond ? true : not sellCond ? false : sellActive
// ---------- Plot Signals with golden text ----------
plotshape(showSignals and buySignal,
title="Buy Signal",
style=shape.triangleup,
location=location.belowbar,
color=color.green,
size=size.tiny,
text="BUY",
textcolor=color.new(color.yellow, 0), // طلایی
offset=signalOffset)
plotshape(showSignals and sellSignal,
title="Sell Signal",
style=shape.triangledown,
location=location.abovebar,
color=color.red,
size=size.tiny,
text="SELL",
textcolor=color.new(color.yellow, 0), // طلایی
offset=signalOffset)
indicator(title="FCB Signals with SMA, Momentum & Stochastic", shorttitle="FCB+AllFilters+Stoch", overlay=true)
// ---------- Inputs ----------
Pattern = input.int(1, "Pattern Length", minval=1)
showSignals = input.bool(true, "Show Buy/Sell Signals")
signalOffset = input.int(0, "Signal Offset", minval=-5, maxval=5)
smaFastLength = input.int(7, "SMA Fast")
smaSlowLength = input.int(21, "SMA Slow")
momentumLength = input.int(10, "Momentum Length")
// ---------- Stochastic Inputs ----------
stochKLength = input.int(14, "Stoch K Length")
stochDLength = input.int(3, "Stoch D Length")
stochSmooth = input.int(3, "Stoch Smooth")
stochOverbought = input.int(80, "Overbought Level")
stochOversold = input.int(20, "Oversold Level")
// ---------- Fractal Functions ----------
fractalUp(pattern) =>
p = high[pattern + 1]
okl = 1
okr = 1
res = 0.0
for i = pattern to 1
okl := high < high[i + 1] and okl == 1 ? 1 : 0
for i = pattern + 2 to pattern * 2 + 1
okr := high < high[i - 1] and okr == 1 ? 1 : 0
res := okl == 1 and okr == 1 ? p : res[1]
res
fractalDn(pattern) =>
p = low[pattern + 1]
okl = 1
okr = 1
res = 0.0
for i = pattern to 1
okl := low > low[i + 1] and okl == 1 ? 1 : 0
for i = pattern + 2 to pattern * 2 + 1
okr := low > low[i - 1] and okr == 1 ? 1 : 0
res := okl == 1 and okr == 1 ? p : res[1]
res
// ---------- Compute ----------
xUpper = fractalUp(Pattern)
xLower = fractalDn(Pattern)
// ---------- Hide FCB ----------
plot(xUpper, color=na, title="FCB Up")
plot(xLower, color=na, title="FCB Down")
// ---------- Candle Analysis ----------
body = math.abs(close - open)
shadowTop = high - math.max(open, close)
shadowBot = math.min(open, close) - low
strongBody = body > (shadowTop + shadowBot)
isGreen = close > open
isRed = close < open
// ---------- SMA ----------
smaFast = ta.sma(close, smaFastLength)
smaSlow = ta.sma(close, smaSlowLength)
// ---------- Momentum ----------
momentumValue = ta.mom(close, momentumLength)
// ---------- Stochastic ----------
kLine = ta.sma(ta.stoch(close, high, low, stochKLength), stochSmooth)
dLine = ta.sma(kLine, stochDLength)
// ---------- Stochastic Direction ----------
kUp = kLine > kLine[1]
dUp = dLine > dLine[1]
kDown = kLine < kLine[1]
dDown = dLine < dLine[1]
// ---------- Check Stochastic Neutral ----------
inNeutral = (kLine < stochOverbought and kLine > stochOversold) and (dLine < stochOverbought and dLine > stochOversold)
// ---------- First Candle Signal Logic ----------
var bool buyActive = false
var bool sellActive = false
buyCond = close > xUpper and strongBody and isGreen and smaFast > smaSlow and momentumValue > momentumValue[1] and kUp and dUp and inNeutral
sellCond = close < xLower and strongBody and isRed and smaFast < smaSlow and momentumValue < momentumValue[1] and kDown and dDown and inNeutral
buySignal = buyCond and not buyActive
sellSignal = sellCond and not sellActive
buyActive := buyCond ? true : not buyCond ? false : buyActive
sellActive := sellCond ? true : not sellCond ? false : sellActive
// ---------- Plot Signals with golden text ----------
plotshape(showSignals and buySignal,
title="Buy Signal",
style=shape.triangleup,
location=location.belowbar,
color=color.green,
size=size.tiny,
text="BUY",
textcolor=color.new(color.yellow, 0), // طلایی
offset=signalOffset)
plotshape(showSignals and sellSignal,
title="Sell Signal",
style=shape.triangledown,
location=location.abovebar,
color=color.red,
size=size.tiny,
text="SELL",
textcolor=color.new(color.yellow, 0), // طلایی
offset=signalOffset)
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.