OPEN-SOURCE SCRIPT
Mo Fan Trading Indicator

//version=6
indicator("Mo Fan Trading Indicator", shorttitle="MF Indicator", overlay=false)
// Input parameters
length_A = input.int(34, "Long Period")
length_B = input.int(14, "Short Period")
length_D = input.int(4, "Medium Period")
// Calculate main indicator values
calculateA() =>
hhv_34 = ta.highest(high, 34)
llv_34 = ta.lowest(low, 34)
a_val = -100 * (hhv_34 - close) / (hhv_34 - llv_34)
ta.sma(a_val, 19)
calculateB() =>
hhv_14 = ta.highest(high, 14)
llv_14 = ta.lowest(low, 14)
-100 * (hhv_14 - close) / (hhv_14 - llv_14)
calculateD() =>
hhv_34_d = ta.highest(high, 34)
llv_34_d = ta.lowest(low, 34)
d_val = -100 * (hhv_34_d - close) / (hhv_34_d - llv_34_d)
ta.ema(d_val, 4)
// Calculate indicator lines
A_line = calculateA()
B_line = calculateB()
D_line = calculateD()
longTermLine = A_line + 100
shortTermLine = B_line + 100
mediumTermLine = D_line + 100
// Calculate signal conditions
topSignal = (mediumTermLine[1] > 85 and shortTermLine[1] > 85 and longTermLine[1] > 65) and ta.cross(longTermLine, shortTermLine)
topAreaCondition = (mediumTermLine < mediumTermLine[1] and mediumTermLine[1] > 80) and (shortTermLine[1] > 95 or shortTermLine[2] > 95) and longTermLine > 60 and shortTermLine < 83.5 and shortTermLine < mediumTermLine and shortTermLine < longTermLine + 4
bottomAreaCondition = (longTermLine < 12 and mediumTermLine < 8 and (shortTermLine < 7.2 or shortTermLine[1] < 5) and (mediumTermLine > mediumTermLine[1] or shortTermLine > shortTermLine[1])) or (longTermLine < 8 and mediumTermLine < 7 and shortTermLine < 15 and shortTermLine > shortTermLine[1]) or (longTermLine < 10 and mediumTermLine < 7 and shortTermLine < 1)
lowGoldenCross = longTermLine < 15 and longTermLine[1] < 15 and mediumTermLine < 18 and shortTermLine > shortTermLine[1] and ta.cross(shortTermLine, longTermLine) and shortTermLine > mediumTermLine and (shortTermLine[1] < 5 or shortTermLine[2] < 5) and (mediumTermLine >= longTermLine or shortTermLine[1] < 1)
// Plot main indicator lines
plot(longTermLine, "Long Term Line", color.rgb(153, 0, 255), 2)
plot(shortTermLine, "Short Term Line", color.gray, 1)
plot(mediumTermLine, "Medium Term Line", color.yellow, 2)
// Plot horizontal reference lines
hline(10, "10 Level", color=color.new(#CC6633, 0), linestyle=hline.style_dashed, linewidth=2)
hline(20, "20 Level", color=color.new(color.green, 0))
hline(80, "80 Level", color=color.new(#996699, 0))
hline(90, "90 Level", color=color.new(#9966FF, 0), linestyle=hline.style_dashed, linewidth=2)
// Plot signal markers
plotshape(topSignal, "Top Signal", shape.triangledown, location.top, color.red, size=size.normal)
plotshape(bottomAreaCondition, "Bottom Area", shape.triangleup, location.bottom, color.green, size=size.normal)
plotshape(lowGoldenCross, "Low Golden Cross", shape.circle, location.bottom, color.lime, size=size.normal)
// Mark areas with background color
bgcolor(topSignal or topAreaCondition ? color.new(color.red, 90) : na, title="Top Area Background")
bgcolor(bottomAreaCondition ? color.new(color.green, 90) : na, title="Bottom Area Background")
bgcolor(lowGoldenCross ? color.new(color.lime, 90) : na, title="Golden Cross Background")
// Display value labels on chart
if barstate.islast
var table signal_table = table.new(position.top_right, 2, 4, bgcolor=color.white, border_width=1)
table.cell(signal_table, 0, 0, "Long Line:", text_color=color.black, bgcolor=color.white)
table.cell(signal_table, 1, 0, str.tostring(longTermLine, "#.##"), text_color=color.purple, bgcolor=color.white)
table.cell(signal_table, 0, 1, "Short Line:", text_color=color.black, bgcolor=color.white)
table.cell(signal_table, 1, 1, str.tostring(shortTermLine, "#.##"), text_color=color.gray, bgcolor=color.white)
table.cell(signal_table, 0, 2, "Medium Line:", text_color=color.black, bgcolor=color.white)
table.cell(signal_table, 1, 2, str.tostring(mediumTermLine, "#.##"), text_color=color.orange, bgcolor=color.white)
indicator("Mo Fan Trading Indicator", shorttitle="MF Indicator", overlay=false)
// Input parameters
length_A = input.int(34, "Long Period")
length_B = input.int(14, "Short Period")
length_D = input.int(4, "Medium Period")
// Calculate main indicator values
calculateA() =>
hhv_34 = ta.highest(high, 34)
llv_34 = ta.lowest(low, 34)
a_val = -100 * (hhv_34 - close) / (hhv_34 - llv_34)
ta.sma(a_val, 19)
calculateB() =>
hhv_14 = ta.highest(high, 14)
llv_14 = ta.lowest(low, 14)
-100 * (hhv_14 - close) / (hhv_14 - llv_14)
calculateD() =>
hhv_34_d = ta.highest(high, 34)
llv_34_d = ta.lowest(low, 34)
d_val = -100 * (hhv_34_d - close) / (hhv_34_d - llv_34_d)
ta.ema(d_val, 4)
// Calculate indicator lines
A_line = calculateA()
B_line = calculateB()
D_line = calculateD()
longTermLine = A_line + 100
shortTermLine = B_line + 100
mediumTermLine = D_line + 100
// Calculate signal conditions
topSignal = (mediumTermLine[1] > 85 and shortTermLine[1] > 85 and longTermLine[1] > 65) and ta.cross(longTermLine, shortTermLine)
topAreaCondition = (mediumTermLine < mediumTermLine[1] and mediumTermLine[1] > 80) and (shortTermLine[1] > 95 or shortTermLine[2] > 95) and longTermLine > 60 and shortTermLine < 83.5 and shortTermLine < mediumTermLine and shortTermLine < longTermLine + 4
bottomAreaCondition = (longTermLine < 12 and mediumTermLine < 8 and (shortTermLine < 7.2 or shortTermLine[1] < 5) and (mediumTermLine > mediumTermLine[1] or shortTermLine > shortTermLine[1])) or (longTermLine < 8 and mediumTermLine < 7 and shortTermLine < 15 and shortTermLine > shortTermLine[1]) or (longTermLine < 10 and mediumTermLine < 7 and shortTermLine < 1)
lowGoldenCross = longTermLine < 15 and longTermLine[1] < 15 and mediumTermLine < 18 and shortTermLine > shortTermLine[1] and ta.cross(shortTermLine, longTermLine) and shortTermLine > mediumTermLine and (shortTermLine[1] < 5 or shortTermLine[2] < 5) and (mediumTermLine >= longTermLine or shortTermLine[1] < 1)
// Plot main indicator lines
plot(longTermLine, "Long Term Line", color.rgb(153, 0, 255), 2)
plot(shortTermLine, "Short Term Line", color.gray, 1)
plot(mediumTermLine, "Medium Term Line", color.yellow, 2)
// Plot horizontal reference lines
hline(10, "10 Level", color=color.new(#CC6633, 0), linestyle=hline.style_dashed, linewidth=2)
hline(20, "20 Level", color=color.new(color.green, 0))
hline(80, "80 Level", color=color.new(#996699, 0))
hline(90, "90 Level", color=color.new(#9966FF, 0), linestyle=hline.style_dashed, linewidth=2)
// Plot signal markers
plotshape(topSignal, "Top Signal", shape.triangledown, location.top, color.red, size=size.normal)
plotshape(bottomAreaCondition, "Bottom Area", shape.triangleup, location.bottom, color.green, size=size.normal)
plotshape(lowGoldenCross, "Low Golden Cross", shape.circle, location.bottom, color.lime, size=size.normal)
// Mark areas with background color
bgcolor(topSignal or topAreaCondition ? color.new(color.red, 90) : na, title="Top Area Background")
bgcolor(bottomAreaCondition ? color.new(color.green, 90) : na, title="Bottom Area Background")
bgcolor(lowGoldenCross ? color.new(color.lime, 90) : na, title="Golden Cross Background")
// Display value labels on chart
if barstate.islast
var table signal_table = table.new(position.top_right, 2, 4, bgcolor=color.white, border_width=1)
table.cell(signal_table, 0, 0, "Long Line:", text_color=color.black, bgcolor=color.white)
table.cell(signal_table, 1, 0, str.tostring(longTermLine, "#.##"), text_color=color.purple, bgcolor=color.white)
table.cell(signal_table, 0, 1, "Short Line:", text_color=color.black, bgcolor=color.white)
table.cell(signal_table, 1, 1, str.tostring(shortTermLine, "#.##"), text_color=color.gray, bgcolor=color.white)
table.cell(signal_table, 0, 2, "Medium Line:", text_color=color.black, bgcolor=color.white)
table.cell(signal_table, 1, 2, str.tostring(mediumTermLine, "#.##"), text_color=color.orange, bgcolor=color.white)
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。