0% found this document useful (0 votes)
193 views4 pages

UM Mahadev

This document describes an indicator for the Ichimoku trading strategy. It defines inputs to configure signal lines and periods. It then generates the Ichimoku lines, signals when lines are crossed, and identifies breakouts of the cloud. Alerts can be set on any of these signals.

Uploaded by

Nitin Salunke
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
0% found this document useful (0 votes)
193 views4 pages

UM Mahadev

This document describes an indicator for the Ichimoku trading strategy. It defines inputs to configure signal lines and periods. It then generates the Ichimoku lines, signals when lines are crossed, and identifies breakouts of the cloud. Alerts can be set on any of these signals.

Uploaded by

Nitin Salunke
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/ 4

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

0 at
https://mozilla.org/MPL/2.0/
// © Yash
//@version=5

//
===================================================================================
=====================
//
-----------------------------------------------------------------------------------
---------------------
// ----------Description:
------------
// ----------This code indicates all Ichimoku signals!
------------
// ----------you can set alerts to be notified when an ichimoku cloud is broken.
------------
// ----------UM-Yash
------------
//
-----------------------------------------------------------------------------------
---------------------
//
===================================================================================
=====================

indicator(title='Ichimoku signals', shorttitle='Mahadev', overlay=true)


//=========================================== inputs
===========================================
//---------------------------------- inputs group s1
----------------------------------
s1_vis = input.bool(true, '', group='Signal 1', inline='s1')
i1_s1 = input.string('CLine', '', options=['CLine', 'BLine', 'Lead1', 'Lead2',
'Close'], group='Signal 1', inline='s1')
f_s1 = input.string('crossover', '', options=['crossover', 'crossunder', '>', '<'],
group='Signal 1', inline='s1')
i2_s1 = input.string('Base Line', '', options=['Conversion Line', 'Base Line',
'Lead 1', 'Lead 2', 'Close'], group='Signal 1', inline='s1')

//---------------------------------- inputs group s2


----------------------------------
s2_vis = input.bool(true, '', group='Signal 2', inline='s2')
i1_s2 = input.string('Lead 1', '', options=['Conversion Line', 'Base Line', 'Lead
1', 'Lead 2', 'Close'], group='Signal 2', inline='s2')
f_s2 = input.string('crossover', '', options=['crossover', 'crossunder', '>', '<'],
group='Signal 2', inline='s2')
i2_s2 = input.string('Lead 2', '', options=['Conversion Line', 'Base Line', 'Lead
1', 'Lead 2', 'Close'], group='Signal 2', inline='s2')

//---------------------------------- inputs group s3


----------------------------------
s3_vis = input.bool(true, '', group='Signal3', inline='s3')
f_s3 = input.string('break ▲', '', options=['break ▲'], group='Signal3',
inline='s3')
s4_vis = input.bool(true, '', group='Signal4', inline='s4')
f_s4 = input.string('break ▼', '', options=['break ▼'], group='Signal4',
inline='s4')

conversionPeriods = input.int(1, minval=1, title='Conversion Line Length')


basePeriods = input.int(26, minval=1, title='Base Line Length')
laggingSpan2Periods = input.int(52, minval=1, title='Lagging Span 2 Length')
displacement = input.int(1, minval=1, title='Displacement')
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
plot(conversionLine, color=color.new(#0496ff, 0), title='Conversion Line (Tenkan
Sen)', display=display.all)
plot(baseLine, color=color.new(#991515, 0), title='Base Line (Kijun Sen)',
display=display.all)
plot(close, offset=-displacement + 1, color=color.new(#459915, 0), title='Lagging
Span (Chikou Span)', display=display.none)
p1 = plot(leadLine1, offset=displacement - 1, color=color.new(color.green, 0),
title='Lead 1')
p2 = plot(leadLine2, offset=displacement - 1, color=color.new(color.red, 0),
title='Lead 2')
fill(p1, p2, title='Cloud', color=leadLine1 > leadLine2 ? color.green : color.red,
transp=90)
lead1 = leadLine1[displacement - 1]
lead2 = leadLine2[displacement - 1]

// ********************************************** Ichimoku "cross", ">", "<"


signals **********************************************
value(v) =>
if v == 'Conversion Line'
conversionLine
else if v == 'Base Line'
baseLine
else if v == 'Lead 1'
lead1
else if v == 'Lead 2'
lead2
else if v == 'Close'
close
x1 = value(i1_s1)
y1 = value(i2_s1)
x2 = value(i1_s2)
y2 = value(i2_s2)

//-----------------Cross over conversion and base lines -----------------------


signal(x, y, f_s) =>
result = false
if f_s == 'crossover'
result := ta.crossover(x, y)
result
else if f_s == 'crossunder'
result := ta.crossunder(x, y)
result
else if f_s == '>'
result := x > y
result
else if f_s == '<'
result := x < y
result
else
result := false
result

s1 = signal(x1, y1, f_s1)


s2 = signal(x2, y2, f_s2)
_styl1 = f_s1 == 'crossover' or f_s1 == 'crossunder' ? plot.style_circles :
plot.style_linebr
_styl2 = f_s2 == 'crossover' or f_s2 == 'crossunder' ? plot.style_circles :
plot.style_linebr
plot(s1 and s1_vis ? x1 : na, 'signal 1', style=_styl1, linewidth=5,
color=color.new(color.lime, 0))
plot(s2 and s2_vis ? x2 : na, 'signal 2', style=_styl2, linewidth=5,
color=color.new(color.orange, 0))

// ********************************************** Ichimoku Breakout


**********************************************
// -----------------break up red cloud-----------------------
bool breakup = na
bool breakdn = na
crossup = ta.crossover(close, lead2)
green_candle = close > open
if lead2 > lead1 and green_candle
breakup := crossup
breakup
plotshape(breakup and s3_vis ? high : na, 'Signal3 (Break Up)', shape.triangleup,
location.belowbar, color.new(color.green, 0), size=size.small)
bgcolor(breakup and s3_vis ? color.lime : na, title='Break Up Background',
transp=90)

// -----------------break under green cloud-----------------------


crossdn = ta.crossunder(close, lead2)
red_candle = close < open
if lead2 < lead1 and red_candle
breakdn := crossdn
breakdn
plotshape(breakdn and s4_vis ? low : na, 'Signal4 (Break Down)',
shape.triangledown, location.abovebar, color.new(color.red, 0), size=size.small)
bgcolor(breakdn and s4_vis ? color.red : na, title='Break Down Background',
transp=90)

// alerts --------------------------------------------------------
alertcondition(s1 and s1_vis or s2 and s2_vis or breakup and s3_vis or breakdn and
s4_vis, 'signals', 'message')

// VARIABLES
var bool buy = true
var bool sell = true
var bool lineCrossOver = false
var bool lineCrossUnder = false
var bool signalCrossOver = false
var bool signalCrossUnder = false
var int lastSignalIndex = 0
var float lastSignalValue = 0.0

//CONDITIONS
cond1 = signalCrossOver and lineCrossOver
cond2 = signalCrossUnder and lineCrossUnder

// PLOTS
plotshape(cond1 and buy, 'Long', shape.triangleup, location.belowbar,
color.new(color.green, 0), size=size.small)
plotshape(cond2 and sell, 'Short', shape.triangledown, location.abovebar,
color.new(color.red, 0), size=size.small)
alertcondition(cond1 and buy, 'Scalping Ichimoku Long', 'Long')
alertcondition(cond2 and sell, 'Scalping Ichimoku Short', 'Long')

// ONE SIGNAL AT TIME


if cond1 and not cond1[1] and buy
buy := false
sell := true
sell
if cond2 and not cond2[1] and sell
buy := true
sell := false
sell
//@version=4
//study(title="Future Ichimoku Lines", shorttitle="Future Ichimoku Lines",
overlay=true)

TS_D1 = input(9, title="Tenkan-sen")


KS_D1 = input(26, title="Kijun-sen")
//Chikou_Displacement = input(25, input.int(1), title="Chikou-span")
//displacement = input(52, input.int(1), title="Displacement")

//donchian(len) => avg(lowest(len), highest(len))

Tenkan = donchian(TS_D1)
Kijun = donchian(KS_D1)
//KumoA = avg(Tenkan, Kijun)
KumoB = donchian(displacement)

plot(Tenkan, color=#f00f0f, title="Tenkan-sen", linewidth=2, transp=10)


plot(Kijun, color=#0fc7db, title="Kijun-sen", linewidth=3, transp=10)
//plot(close, offset = -Chikou_Displacement, color=#9c27b0, title="Chikou-span",
linewidth=3, transp=10)

You might also like