OPEN-SOURCE SCRIPT
FMT by C.ball [XAUUSD Version]

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © 2025 Ball Goldricher - For XAUUSD
//version=5
indicator("FMT by C.ball [XAUUSD Version]", shorttitle="FMT-XAU", overlay=true)
// === Moving Averages ===
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
// === Cross Logic ===
crossUp = ta.crossover(close, ema20)
crossDown = ta.crossunder(close, ema20)
// === Persistent Counters ===
var int upCount = 0
var int downCount = 0
// === Count Crosses ===
if crossUp
upCount := upCount + 1
if crossDown
downCount := downCount + 1
// === Entry Signals on 2nd Cross + EMA50 Filter ===
buySignal = crossUp and upCount == 2 and close > ema50
sellSignal = crossDown and downCount == 2 and close < ema50
// === Show Buy/Sell Labels on Chart ===
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// === Reset Counters after Entry ===
if buySignal or sellSignal
upCount := 0
downCount := 0
// === Show EMA Lines for Reference ===
plot(ema20, color=color.orange, title="EMA 20")
plot(ema50, color=color.blue, title="EMA 50")
// © 2025 Ball Goldricher - For XAUUSD
//version=5
indicator("FMT by C.ball [XAUUSD Version]", shorttitle="FMT-XAU", overlay=true)
// === Moving Averages ===
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
// === Cross Logic ===
crossUp = ta.crossover(close, ema20)
crossDown = ta.crossunder(close, ema20)
// === Persistent Counters ===
var int upCount = 0
var int downCount = 0
// === Count Crosses ===
if crossUp
upCount := upCount + 1
if crossDown
downCount := downCount + 1
// === Entry Signals on 2nd Cross + EMA50 Filter ===
buySignal = crossUp and upCount == 2 and close > ema50
sellSignal = crossDown and downCount == 2 and close < ema50
// === Show Buy/Sell Labels on Chart ===
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// === Reset Counters after Entry ===
if buySignal or sellSignal
upCount := 0
downCount := 0
// === Show EMA Lines for Reference ===
plot(ema20, color=color.orange, title="EMA 20")
plot(ema50, color=color.blue, title="EMA 50")
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。