SWITCH STATS- MACD 4C

mail@pastecode.io avatar
unknown
plain_text
25 days ago
2.5 kB
1
Indexable
Never
//@version=5
indicator(shorttitle='SWITCH STATS- MACD 4C', title='SWITCH STATS- MACD 4C', overlay=true,timeframe = "")

Mode = input.string('Long-Term', options = ['Long-Term', 'Short-Term','Mid-Term'])

Set_Mode_Fast= 0
Set_Mode_Slow = 0

if Mode == 'Long-Term'
    Set_Mode_Fast := 400
    Set_Mode_Slow := 500
else if Mode == 'Short-Term'
    Set_Mode_Fast := 12
    Set_Mode_Slow := 26
else if Mode == 'Mid-Term'
    Set_Mode_Fast := 50
    Set_Mode_Slow := 100


Buy_And_Sell_Toggle = input(true, title = "Trend Detection")
Bar_Color_Switch = input(true,title = "Color Candles")
Secondary_Entry_Switch = input(false,title = "Possible Entry Candles")

fastMA = Set_Mode_Fast
slowMA = Set_Mode_Slow


[macdLine, signalLine, _] = ta.macd(close, fastMA, slowMA, 9)

plotColor = macdLine > 0 ? macdLine > nz(macdLine[1]) ? color.lime : color.green : macdLine < nz(macdLine[1]) ? color.maroon : color.red


Bullish_Market = macdLine > 0
Bearish_Market = macdLine < 0

Buy_Signal = ta.crossover(macdLine,0)
Sell_Signal = ta.crossunder(macdLine,0)

Possible_Buy_Zone = macdLine > 0 and macdLine > (macdLine[1])
Possible_Sell_Zone = macdLine < 0 and macdLine < (macdLine[1])

Secondary_Buy = macdLine>0 and ta.crossover(macdLine, macdLine[1])
Secondary_Sell = macdLine<0 and ta.crossunder(macdLine, macdLine[1])


barcolor(Bar_Color_Switch and (Bullish_Market and not Possible_Buy_Zone)  ? color.teal : na)
barcolor(Bar_Color_Switch and (Bearish_Market and not Possible_Sell_Zone) ? color.orange : na)
barcolor(Bar_Color_Switch and Possible_Buy_Zone ? color.green :na)
barcolor(Bar_Color_Switch and Possible_Sell_Zone ? color.red :na)


plotshape(Buy_And_Sell_Toggle and Sell_Signal, title="SELL Trend Change",style = shape.labeldown,location = location.abovebar,size = size.small,color = color.red,text="BEARISH 🏦",textcolor=color.black)
plotshape(Buy_And_Sell_Toggle and Buy_Signal,title="BUY Trend Change",style = shape.labelup,location = location.belowbar,size = size.small,color = color.green,text="BULLISH 🏦",textcolor = color.black)

//
plotshape(Secondary_Entry_Switch and Secondary_Buy,title = "Contiuation entry" , text = "🔺",location = location.belowbar,style=shape.labelup,color = color.rgb(255, 82, 82, 100))
plotshape(Secondary_Entry_Switch and Secondary_Sell,title = "Contiuation entry" , text = "🔻",location = location.abovebar,style=shape.labelup,color = color.rgb(255, 82, 82, 100))


Leave a Comment