커뮤니티

잘 부탁드립니다

프로필 이미지
매치다2
2023-06-21 14:00:45
1892
글번호 169947
답변완료
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // &#169; LeafAlgo //@version=5 indicator("Moving Average Contrarian Indicator", overlay=false) length = input(40, "Moving Average Length") src = close // Calculate moving average ma = ta.sma(src, length) // Calculate distance from price to moving average distance = src - ma // Calculate normalized MACI distance_min = ta.lowest(distance, length) distance_max = ta.highest(distance, length) maci = ((distance - distance_min) / (distance_max - distance_min)) * 100 // Determine barcolor and background color conditions maci_sma = ta.sma(maci, length) barC = maci > maci_sma and maci > 30 ? color.lime : maci < maci_sma and maci < 70 ? color.fuchsia : color.yellow backC = maci > maci_sma and maci > 30 ? color.new(color.lime, 80) : maci < maci_sma and maci < 70 ? color.new(color.fuchsia, 80) : color.new(color.yellow, 80) // Color barcolor(barC) bgcolor(backC, transp=70) // Plotting plot(maci, title="MACI", color=barC, style=plot.style_histogram, linewidth=4) plot(maci_sma, title='MACI SMA', color=color.maroon, linewidth=2) // Overbought and oversold levels hline(70, "Overbought", color=color.fuchsia) hline(30, "Oversold", color=color.lime)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-06-21 18:07:37

안녕하세요 예스스탁입니다. input : length(40); var : src(0),mav(0),distance(0),distance_min(0),distance_max(0),maci(0); var : maci_sma(0),barC(0),backC(0); src = close; mav = ma(src, length); distance = src - mav; distance_min = lowest(distance, length); distance_max = highest(distance, length); maci = ((distance - distance_min) / (distance_max - distance_min)) * 100; maci_sma = ma(maci, length); barC = iff(maci > maci_sma and maci > 30 , lime , iff(maci < maci_sma and maci < 70 , Magenta , yellow)); backC = iff(maci > maci_sma and maci > 30 , lime , iff(maci < maci_sma and maci < 70 , Magenta , yellow)); // Plotting plot1(maci, "MACI",barC); plot2(maci_sma, "MACI SMA",maroon); PlotBaseLine1(70, "Overbought",Magenta); PlotBaseLine2(30, "Oversold",lime); 즐거운 하루되세요 > 매치다2 님이 쓴 글입니다. > 제목 : 잘 부탁드립니다 > // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // &#169; LeafAlgo //@version=5 indicator("Moving Average Contrarian Indicator", overlay=false) length = input(40, "Moving Average Length") src = close // Calculate moving average ma = ta.sma(src, length) // Calculate distance from price to moving average distance = src - ma // Calculate normalized MACI distance_min = ta.lowest(distance, length) distance_max = ta.highest(distance, length) maci = ((distance - distance_min) / (distance_max - distance_min)) * 100 // Determine barcolor and background color conditions maci_sma = ta.sma(maci, length) barC = maci > maci_sma and maci > 30 ? color.lime : maci < maci_sma and maci < 70 ? color.fuchsia : color.yellow backC = maci > maci_sma and maci > 30 ? color.new(color.lime, 80) : maci < maci_sma and maci < 70 ? color.new(color.fuchsia, 80) : color.new(color.yellow, 80) // Color barcolor(barC) bgcolor(backC, transp=70) // Plotting plot(maci, title="MACI", color=barC, style=plot.style_histogram, linewidth=4) plot(maci_sma, title='MACI SMA', color=color.maroon, linewidth=2) // Overbought and oversold levels hline(70, "Overbought", color=color.fuchsia) hline(30, "Oversold", color=color.lime)