100% found this document useful (1 vote)
2K views5 pages

Setup Mafia 3.5

This document contains the source code for an indicator that plots Ichimoku signals, moving averages, pivot points, and fractal breakout/breakdown signals on a chart. It includes inputs for time periods, sources, methods, and display options. The code calculates the various indicator values, plots lines and shapes to the chart, and includes alerts that trigger on buy and sell signals.

Uploaded by

Gustavo rc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views5 pages

Setup Mafia 3.5

This document contains the source code for an indicator that plots Ichimoku signals, moving averages, pivot points, and fractal breakout/breakdown signals on a chart. It includes inputs for time periods, sources, methods, and display options. The code calculates the various indicator values, plots lines and shapes to the chart, and includes alerts that trigger on buy and sell signals.

Uploaded by

Gustavo rc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
https://mozilla.org/MPL/2.0/
// © Tio_Buza

//@version=5
indicator(title = "Ichimoku Signals", shorttitle = "Ichimoku +", overlay = true,
max_labels_count=500)

//Ichimoku Inputs
conversionPeriods = input.int(9, minval=1, title="Conversion Line", group="Ichimoku
Cloud")
basePeriods = input.int(26, minval=1, title="Base Line", group="Ichimoku Cloud")
laggingSpan = input.int(52, minval=1, title="Senkou Span B", group="Ichimoku
Cloud")
displacement = input.int(26, minval=1, title="Lagging Span", group="Ichimoku
Cloud")

//Calculate the Periods


donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan)

//Plot to Chart
plot(conversionLine, color=#2196f3, title="Conversion Line")
plot(baseLine, color=#B71C1C, title="Base Line")
plot(close, offset = -displacement + 1, color=#25ec2c, title="Lagging Span",
linewidth=2)
p1 = plot(leadLine1, offset = displacement - 1, color=#4caf50, linewidth = 2,
title="Leading Span A")
p2 = plot(leadLine2, offset = displacement - 1, color=#f23645, linewidth = 2,
title="Leading Span B")
fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 75) :
color.rgb(244, 67, 54, 75))

// Moving Average Inputs


len = input.int(defval=25, minval=1, title="Fast MA", group="Moving Average")
src = input.source(title="Fast MA Source", defval=close, group="Moving Average")
out = ta.sma(src, len)
plot(out, color=close[1] > out and close > out ? #089981 : #ff5252, linewidth=2,
title="Fast MA")

ma(source, length, type) =>


switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA",
"SMMA (RMA)", "WMA", "VWMA"], group="Moving Average")
len1 = input.int(defval=50, minval=1, title="Medium MA", group="Moving Average")
src1 = input.source(title="Medium MA Source", defval=close, group="Moving Average")
out1 = ta.sma(src1, len1)
plot(out1, color=close[1] > out1 and close > out1 ? #089981 : #ff5252, linewidth=2,
title="Medium MA")

ma1(source1, length1, type) =>


switch type
"SMA" => ta.sma(source1, length1)
"EMA" => ta.ema(source1, length1)
"SMMA (RMA)" => ta.rma(source1, length1)
"WMA" => ta.wma(source1, length1)
"VWMA" => ta.vwma(source1, length1)
typeMA1 = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA",
"SMMA (RMA)", "WMA", "VWMA"], group="Moving Average")
len2 = input.int(defval=200, minval=1, title="Slow MA", group="Moving Average")
src2 = input.source(title="Slow MA Source", defval=close, group="Moving Average")
out2 = ta.sma(src2, len2)
plot(out2, color=close[1] > out2 and close > out2 ? #089981 : #ff5252, linewidth=2,
title="Slow MA")
ma2(source2, length2, type) =>
switch type
"SMA" => ta.sma(source2, length2)
"EMA" => ta.ema(source2, length2)
"SMMA (RMA)" => ta.rma(source2, length2)
"WMA" => ta.wma(source2, length2)
"VWMA" => ta.vwma(source2, length2)
typeMA2 = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA",
"SMMA (RMA)", "WMA", "VWMA"], group="Moving Average")

// Heiken Trade
heikinashi_open = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, open)
heikinashi_high = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, high)
heikinashi_low = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, low)
heikinashi_close = request.security(ticker.heikinashi(syminfo.tickerid),
timeframe.period, close)

// Condition Variable
var Bearish = false
var Bullish = false
var Bullish_label = label.new(na, na, "", style=label.style_triangleup,
color=#089981, size=size.tiny, yloc=yloc.belowbar)
var Bearish_label = label.new(na, na, "", style=label.style_triangledown,
color=#ff5252, size=size.tiny, yloc=yloc.abovebar)

// Market Verify Bull ou Bear


Bearish := ta.crossover(heikinashi_open, heikinashi_close) and heikinashi_close
Bullish := ta.crossover(heikinashi_close, heikinashi_open) and heikinashi_close

// Plot Last Signal


if Bullish
label.delete(Bullish_label)
Bullish_label := label.new(bar_index, high, text="",
style=label.style_triangleup, color=#089981, size=size.tiny, yloc=yloc.belowbar)
else if Bearish
label.delete(Bearish_label)
Bearish_label := label.new(bar_index, high, text="",
style=label.style_triangledown, color=#ff5252, size=size.tiny, yloc=yloc.abovebar)

//Pivot Points Inputs HH, LH, LL, HL


gr1="Source / Length Left / Length Right"
srcH = input(high, title="Pivot High", inline="Pivot High", group=gr1)
leftLenH = input.int(title="", defval=5, minval=1, inline="Pivot High",group=gr1)
rightLenH = input.int(title="/", defval=5, minval=1, inline="Pivot High",group=gr1)
colorH = input(title="", defval=color.new(#089981,50), inline="Pivot
High",group=gr1)

srcL = input(low, title="Pivot Low ", inline="Pivot Low", group=gr1)


leftLenL = input.int(title="", defval=5, minval=1, inline="Pivot Low", group=gr1)
rightLenL = input.int(title="/", defval=5, minval=1, inline="Pivot Low",group=gr1)
colorL = input(title="", defval=color.new(#ff5252,50), inline="Pivot
Low",group=gr1)

gr2="Pivot Points Options"


ShowHHLL = input(true, title="Show HH, LL, LH, HL markers on candles",group=gr2)
ShowPrice = input(true, title="Show HH, LL, LH, HL price on candles",group=gr2)
ShowSRLevels = input(true, title="Show S/R Level Extensions",group=gr2)
maxLvlLen = input.int(0, minval=0, title="Maximum S/R Level Extension Length (0 =
Max)",group=gr2)
ShowChannel = input(false, title="Show Levels as a Fractal Chaos
Channel",group=gr2)
ShowFB = input(true, title="Show fractal Break out/down symbols",group=gr2)

// Get High and Low Pivot Points


ph = ta.pivothigh(srcH, leftLenH, rightLenH)
pl = ta.pivotlow(srcL, leftLenL, rightLenL)

// Higher Highs, Lower Highs, Higher Lows, Lower Lows


valuewhen_1 = ta.valuewhen(ph, srcH[rightLenH], 1)
valuewhen_2 = ta.valuewhen(ph, srcH[rightLenH], 0)
higherhigh = na(ph) ? na : valuewhen_1 < valuewhen_2 ? ph : na
valuewhen_3 = ta.valuewhen(ph, srcH[rightLenH], 1)
valuewhen_4 = ta.valuewhen(ph, srcH[rightLenH], 0)
lowerhigh = na(ph) ? na : valuewhen_3 > valuewhen_4 ? ph : na
valuewhen_5 = ta.valuewhen(pl, srcL[rightLenL], 1)
valuewhen_6 = ta.valuewhen(pl, srcL[rightLenL ], 0)
higherlow = na(pl) ? na : valuewhen_5 < valuewhen_6 ? pl : na
valuewhen_7 = ta.valuewhen(pl, srcL[rightLenL], 1)
valuewhen_8 = ta.valuewhen(pl, srcL[rightLenL ], 0)
lowerlow = na(pl) ? na : valuewhen_7 > valuewhen_8 ? pl : na

//Show the Value of Pivot Points


drawLabel(_offset, _pivot, _style, _yloc, _color, _text) =>
if not na(_pivot)
label.new(bar_index[_offset], _pivot, text = _text+str.tostring(_pivot,
format.mintick)+"]", style=_style, yloc=_yloc, color=_color, textcolor=_color)
drawLabel(rightLenH, ShowPrice ? higherhigh : na, label.style_none, yloc.abovebar,
colorH, "[")
drawLabel(rightLenH, ShowPrice ? higherlow : na, label.style_none, yloc.belowbar,
colorL, "[")
drawLabel(rightLenH, ShowPrice ? lowerhigh : na, label.style_none, yloc.abovebar,
colorH, "[")
drawLabel(rightLenH, ShowPrice ? lowerlow : na, label.style_none, yloc.belowbar,
colorL, "[")

//Plot Pivot Points


plotshape(ShowHHLL ? higherhigh : na, title='HH', style=shape.triangledown,
location=location.abovebar, color=colorH, text="HH", textcolor=colorH, offset=-
rightLenH)
plotshape(ShowHHLL ? higherlow : na, title='HL', style=shape.triangleup,
location=location.belowbar, color=colorL, text="HL", textcolor=colorL, offset=-
rightLenH)
plotshape(ShowHHLL ? lowerhigh : na, title='LH', style=shape.triangledown,
location=location.abovebar, color=colorH, text="LH", textcolor=colorH, offset=-
rightLenL)
plotshape(ShowHHLL ? lowerlow : na, title='LL', style=shape.triangleup,
location=location.belowbar, color=colorL, text="LL", textcolor=colorL, offset=-
rightLenL)

//Count How many candles for current Pivot Level, If new reset.
countH = 0
countL = 0
countH := na(ph) ? nz(countH[1]) + 1 : 0
countL := na(pl) ? nz(countL[1]) + 1 : 0

pvtH = 0.0
pvtL = 0.0
pvtH := na(ph) ? pvtH[1] : srcH[rightLenH]
pvtL := na(pl) ? pvtL[1] : srcL[rightLenL]

HpC = pvtH != pvtH[1] ? na : colorH


LpC = pvtL != pvtL[1] ? na : colorL

// Show Levels if Selected


plot(ShowSRLevels and not ShowChannel and (maxLvlLen == 0 or countH < maxLvlLen) ?
pvtH : na, color=HpC, offset=-rightLenH , title="Top Levels
HH,LH",style=plot.style_circles)
plot(ShowSRLevels and not ShowChannel and (maxLvlLen == 0 or countL < maxLvlLen) ?
pvtL : na, color=LpC, offset=-rightLenL , title="Bottom Levels
LL,HL",style=plot.style_circles)

// Show Levels as a Fractal Chaos Channel


plot(ShowSRLevels and ShowChannel ? pvtH : na, color=colorH,
style=plot.style_stepline, title="Top Chaos Channel",offset=-rightLenH)
plot(ShowSRLevels and ShowChannel ? pvtL : na, color=colorL,
style=plot.style_stepline, title="Bottom Chaos Channel", offset=-rightLenL)

// // Add Optional Fractal Break Alerts


buy = false
sell = false
buy := close>pvtH and open<=pvtH
sell := close<pvtL and open>=pvtL

plotshape(ShowFB and buy?1:na, title="Breakout Bar", text="↑",


style=shape.triangleup, location =location.belowbar, color=colorH,
textcolor=colorH, size=size.auto, editable=true)
plotshape(ShowFB and sell?-1:na, title="Breakdown Bar",text="↓",
style=shape.triangledown,location=location.abovebar, color=colorL,
textcolor=colorL, size=size.auto, editable=true)

// Alerts
alertcondition(buy or sell,title="Fractal Break Arrow",message="Alert")
alertcondition(buy,title="Fractal Break Long",message="Long")
alertcondition(sell,title="Fractal Break Short",message="Short")

//RSI Inputs
rsiLength = input.int(14, minval=1, title="RSI Length"), editable = false
rsiSource = input.source(close, "Source")

//RSI
rsiOverbought = input.int(75, title="RSI Overbought Level", group = "RSI Options")
rsiOversold = input.int(28, title="RSI Oversold Level", group = "RSI Options")

// Get RSI Value


rsiValue = ta.rsi(rsiSource, rsiLength)
isRsiOB = rsiValue >= rsiOverbought
isRsiOS = rsiValue <= rsiOversold

//Plot signals to chart


plotshape(isRsiOB, text="Sell", title="Overbought", location=location.abovebar,
color=color.new(#ff5252, 50), style=shape.triangledown, textcolor=#ff5252)
plotshape(isRsiOS, text="Buy", title="Oversold", location=location.belowbar,
color=color.new(#089981, 50), style=shape.triangleup, textcolor=#089981)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy