0% found this document useful (0 votes)
325 views3 pages

gg2 indicator

This document contains a TradingView Pine Script for an indicator called 'GG Shot - Decoded' which utilizes various trading strategies including Ichimoku and ATR for determining long and short positions. It includes customizable inputs for periods, multipliers, and conditions for take profit and stop loss. The script plots signals for long and short entries, take profits, and stop losses on the price chart.

Uploaded by

Atul
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)
325 views3 pages

gg2 indicator

This document contains a TradingView Pine Script for an indicator called 'GG Shot - Decoded' which utilizes various trading strategies including Ichimoku and ATR for determining long and short positions. It includes customizable inputs for periods, multipliers, and conditions for take profit and stop loss. The script plots signals for long and short entries, take profits, and stop losses on the price chart.

Uploaded by

Atul
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/ 3

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

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

indicator('GG Shot - Decoded', overlay=true)

length = input(title='Period', defval=1)


mult = input.float(title='Multiplier', step=0.1, defval=13)
//ichimoku inputs
conversionPeriods = input.int(9, minval=1, title='Conversion Line Periods')
basePeriods = input.int(26, minval=1, title='Base Line Periods')
laggingSpan2Periods = input.int(52, minval=1, title='Lagging Span 2 Periods')
displacement = input.int(26, minval=1, title='Displacement')

//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)

longStop = hl2 - atr


longStopPrev = nz(longStop[1], longStop)
longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop

shortStop = hl2 + atr


shortStopPrev = nz(shortStop[1], shortStop)
shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) :
shortStop

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

// Define long and short conditions


longCond = ta.crossover(close[1], shortStopPrev)
shortCond = ta.crossunder(close[1], longStopPrev)

var float sectionLongs = 0


var float sectionShorts = 0

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

// Initialize last open prices properly


var float last_open_longCondition = na
var float last_open_shortCondition = na

last_open_longCondition := longCondition ? open : nz(last_open_longCondition[1])


last_open_shortCondition := shortCondition ? open : nz(last_open_shortCondition[1])

// Check if your last position was a long or a short


var float last_longCondition = na
var float last_shortCondition = na

last_longCondition := longCondition ? time : nz(last_longCondition[1])


last_shortCondition := shortCondition ? time : nz(last_shortCondition[1])

in_longCondition = last_longCondition > last_shortCondition


in_shortCondition = last_shortCondition > last_longCondition

// 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

// Create a single close for all closing conditions


long_close = long_tp or long_sl ? 1 : 0
short_close = short_tp or short_sl ? 1 : 0

// Get the time of the last close


var float last_long_close = na
var float last_short_close = na

last_long_close := long_close ? time : nz(last_long_close[1])


last_short_close := short_close ? time : nz(last_short_close[1])

// 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))

plotshape(dir == 1 and dir[1] == -1 ? longStop : na, title='LONG',


style=shape.triangleup, location=location.belowbar, size=size.small, text='LONG',
textcolor=color.new(color.green, 0), color=color.new(color.green, 0))
plotshape(dir == -1 and dir[1] == 1 ? shortStop : na, title='SHORT',
style=shape.triangledown, location=location.abovebar, size=size.small,
text='SHORT', textcolor=color.new(color.red, 0), color=color.new(color.red, 0))

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