gg2 indicator
gg2 indicator
0 at
// https://mozilla.org/MPL/2.0/
// © moneymovesalgo
//@version=5
//algo
atr = mult * ta.atr(length)
//kumo
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
dir = 1
dir := nz(dir[1], dir)
dir := dir == -1 and close > shortStopPrev ? 1 : dir == 1 and close <
longStopPrev ? -1 : dir
longColor = color.blue
shortColor = color.blue
if longCond
sectionLongs := sectionLongs + 1
sectionShorts := 0
if shortCond
sectionLongs := 0
sectionShorts := sectionShorts + 1
pyrl = 1
longCondition = longCond and sectionLongs <= pyrl
shortCondition = shortCond and sectionShorts <= pyrl
// Take profit
isTPl = input(true, 'Take Profit Long')
isTPs = input(true, 'Take Profit Short')
tp = input(2, 'Take Profit %')
long_tp = isTPl and ta.crossover(high, (1 + tp / 100) * last_open_longCondition)
and not longCondition and in_longCondition
short_tp = isTPs and ta.crossunder(low, (1 - tp / 100) * last_open_shortCondition)
and not shortCondition and in_shortCondition
// Stop Loss
isSLl = input(false, 'Stop Loss Long')
isSLs = input(false, 'Stop Loss Short')
sl = input.float(3, 'Stop Loss %')
long_sl = isSLl and ta.crossunder(low, (1 - sl / 100) * last_open_longCondition)
and not longCondition and in_longCondition
short_sl = isSLs and ta.crossover(high, (1 + sl / 100) * last_open_shortCondition)
and not shortCondition and in_shortCondition
// Signals
plotchar(long_tp and last_longCondition > nz(last_long_close[1]), text='TP',
title='Take Profit Long', size=size.tiny, location=location.abovebar,
color=color.new(color.green, 0))
plotchar(short_tp and last_shortCondition > nz(last_short_close[1]), text='TP',
title='Take Profit Short', size=size.tiny, location=location.belowbar,
color=color.new(color.red, 0))
plotchar(long_sl and last_longCondition > nz(last_long_close[1]), char='⛔',
text='SL LONG', title='Stop Loss Long', size=size.tiny, location=location.abovebar,
color=color.new(color.red, 0))
plotchar(short_sl and last_shortCondition > nz(last_short_close[1]), char='⛔',
text='SL SHORT', title='Stop Loss Short', size=size.tiny,
location=location.belowbar, color=color.new(color.red, 0))