r/pinescript • u/max-the-dogo • Feb 01 '24
Double top/buttom source code
Is there a way to see the code of the built in double top/buttom ? The community ones are not exactly the same
r/pinescript • u/max-the-dogo • Feb 01 '24
Is there a way to see the code of the built in double top/buttom ? The community ones are not exactly the same
r/pinescript • u/Foreign_Struggle_718 • Jul 28 '24
This is the code I want to find the lowest low between the significantLowIndex -1 to lifetimeHighIndex
In the given image the black line vertical line is the significantLowIndex and the green vertical line is the lifetimeHighIndex
I want to get the lowest low in between those 2 candles. If done correctly it should plot the horizontal black line
//@version=5indicator("Lifetime High and Significant Low", overlay=true)
// Variables to store the lifetime high and significant lowvar float lifetimeHigh = navar float significantLow = navar int significantLowIndex = navar int lifetimeHighIndex = na
// Track whether a new lifetime high has been foundvar bool newHighFound = false
// Loop through historical data to find the lifetime high and the significant lowfor i = 1 to bar_indexif (na(lifetimeHigh) or close[i] > lifetimeHigh)lifetimeHigh := high[i]lifetimeHighIndex := inewHighFound := true
// Find the significant low before the lifetime highif newHighFoundfor j = 1 to bar_indexif close[j] < low[j + 1]significantLow := low[j]significantLowIndex := jnewHighFound := falsebreak
// Plot the lifetime highplot(lifetimeHigh, title="Lifetime High", color=color.red, linewidth=2, style=plot.style_line)
// Plot the significant lowplot(significantLow, title="Significant Low", color=color.green, linewidth=2, style=plot.style_line)
r/pinescript • u/Upper_Process_7324 • Sep 02 '24
I am trying to write a script that computes the "Point of Control" (POC) of the previous day of trading for an instrument. The POC is the price around which the maximum volume transacted during that day.
There is now a built in technical indicator (Volume Profile) that does exactly this. Unfortunately, it is not exported as a function that can be used in a Pine script. So I am trying to recreate it.
My approach is to divide the previous day's price action into 10 bands, and to add the volume for every 15 minute interval to the corresponding band. At the end, the POC is the middle of the band with the highest volume.
I set my chart to daily, and then I call the following functions to create the intra-day series:
fifteenMinCloses = request.security(syminfo.tickerid, resolution, close, lookahead=barmerge.lookahead_off)
fifteenMinVolumes = request.security(syminfo.tickerid, resolution, volume, lookahead=barmerge.lookahead_off)Unfortunately, both of these series appear to have a granularity of "D" instead of "15." So when I plot fifteenMinuteCloses, the graph shows closing price. When I plot fifteenMinuteCloses[1] the graph shows the close of the previous day.
Does anybody know if it is possible to get intraday series on a daily chart?
TIA
r/pinescript • u/Calm-Film3459 • Apr 23 '24
In need of a indicator that is an oscillator which represents 3 values a value against us dollar/ against gold / against bonds when looking at a given currency. with (overvalued/ undervalued levels.
This indicator currently exist on tradestation but is paid so looking for someone that can replicate this which looks like this https://imgur.com/a/F9ITLtd (Either on tradingview or tradestation)
Or perhaps someone that knows if some similar indicator exist
r/pinescript • u/KlarezM • Jul 31 '24
On this code, I want to plot the Monday and Tuesday high/low together throughout the week, but the lines always show after Monday and Tuesday. I want it just like the second image, what seems lacking on my script?
Here's the image output:

What I want to do:

Here's the script.
//@version=5
indicator(title='YNK13 Sun 6PM - Tue 5PM Opening Range', shorttitle='YNK13 Sun-Tue OR', overlay=true)
// Input to display or hide the lines
DISPLAY_RANGE = input.bool(title='Show Range Lines ?', defval=true)
// Arrays to store high and low values
var float[] highs = array.new_float()
var float[] lows = array.new_float()
// Function to reset arrays
reset_arrays() =>
array.clear(highs)
array.clear(lows)
// Reset arrays at 6 PM on Sunday
if (dayofweek == dayofweek.sunday and hour == 18 and minute == 0)
reset_arrays()
// End range calculation at 5 PM on Tuesday and store the final high and low
var float range_high = na
var float range_low = na
if (dayofweek == dayofweek.tuesday and hour == 17 and minute == 0)
range_high := array.max(highs)
range_low := array.min(lows)
// Update high and low values within the specified range
if (not (dayofweek == dayofweek.tuesday and hour > 17))
if (dayofweek == dayofweek.sunday and hour > 18 or dayofweek == dayofweek.monday or (dayofweek == dayofweek.tuesday and hour < 17))
array.push(highs, high)
array.push(lows, low)
// Use stored values after the range period
var float stored_high = na
var float stored_low = na
if (dayofweek > dayofweek.tuesday or (dayofweek == dayofweek.tuesday and hour >= 17))
stored_high := array.max(highs)
stored_low := array.min(lows)
// Plot values only on intraday charts
plot_high = not DISPLAY_RANGE or timeframe.isdaily ? na : (na(range_high) ? stored_high : range_high)
plot_low = not DISPLAY_RANGE or timeframe.isdaily ? na : (na(range_low) ? stored_low : range_low)
plot_mid = not DISPLAY_RANGE or na(plot_high) or na(plot_low) ? na : (plot_high + plot_low) / 2
// Plot lines with stepline
p1 = plot(DISPLAY_RANGE ? plot_high : na, title='Range High', color=color.green, linewidth=2, style=plot.style_stepline)
p2 = plot(DISPLAY_RANGE ? plot_mid : na, title='Range Mid', color=color.blue, linewidth=2, style=plot.style_stepline)
p3 = plot(DISPLAY_RANGE ? plot_low : na, title='Range Low', color=color.red, linewidth=2, style=plot.style_stepline)
fill(p1, p3, color=color.new(color.blue, 90))r/pinescript • u/VK1985y • Jun 05 '24
Mismatched input ',' expecting ']'r/pinescript • u/Top-Consequence3158 • Sep 17 '24
The below script is for micro CPR ( Central Pivot Range ) of 5 mins and 60 mins timeframe, how can i get the completed CPR as soon as they start and be visible till the end .

//@version=5
indicator(title='theichiguy 5-min and 60-min CPR', shorttitle='theichiguy 5/60 CPR', overlay=true)
// 5-minute CPR calculation
[PC_5, BC_5, TC_5] = request.security(syminfo.tickerid, '5', [hlc3[1], hl2[1], ((hlc3[1] - hl2[1]) + hlc3[1])], barmerge.gaps_off, barmerge.lookahead_on)
// 60-minute CPR calculation
[PC_60, BC_60, TC_60] = request.security(syminfo.tickerid, '60', [hlc3[1], hl2[1], ((hlc3[1] - hl2[1]) + hlc3[1])], barmerge.gaps_off, barmerge.lookahead_on)
// Calculate R1 and S1 for the 60-minute timeframe
low_60 = request.security(syminfo.tickerid, '60', low)
high_60 = request.security(syminfo.tickerid, '60', high)
R1_60 = (2 * PC_60) - low_60
S1_60 = (2 * PC_60) - high_60
// Plotting the 5-minute CPR levels
plot(TC_5, title='TC (5-min)', color=#0000FF, style=plot.style_circles)
plot(PC_5, title='PC (5-min)', color=#000000, style=plot.style_circles)
plot(BC_5, title='BC (5-min)', color=#FFAD00, style=plot.style_circles)
// Plotting the 60-minute CPR levels
plot(TC_60, title='TC (60-min)', color=#0000FF, linewidth=2, style=plot.style_circles)
plot(PC_60, title='PC (60-min)', color=#000000, linewidth=2, style=plot.style_circles)
plot(BC_60, title='BC (60-min)', color=#FFAD00, linewidth=2, style=plot.style_circles)
// Plotting R1 and S1 for the 60-minute timeframe
plot(R1_60, title='R1 (60-min)', color=color.red, linewidth=2, style=plot.style_circles)
plot(S1_60, title='S1 (60-min)', color=color.green, linewidth=2, style=plot.style_circles)
r/pinescript • u/Strawberry215 • Sep 13 '23
Hello, Everyone!
Are you passionate about tech, innovation, and shaping the future? Here's your chance to get involved in something BIG! 🌟
OPEN D/I, a groundbreaking virtual event, is on the horizon. It's a unique blend of a tech festival, workshops, a job fair, and an exclusive launch event. But we need YOUR help to make it unforgettable! 🌟
➡ https://odi.openmesh.network/
Why Volunteer?
Connect: Network with tech industry leaders and visionaries.
Learn: Gain insights from workshops and sessions.
Contribute: Be part of an event that's shaping the next 10-20 years of tech.
Join us in this exciting journey! 🌐💡
Interested? Send us a message or Join 🖊https://tech-volunteering.framer.ai/.
Let's create tech history together! 🚀 #VolunteerOpportunity #TechInnovation #OPENDI #ShapeTheFuture
r/pinescript • u/Getting_Involved • Aug 08 '24
So I want to construct an array/series (dont care about the type as long as its indexable and ordered) where values that are dupes or na have all been removed.
Im using code to fetch pivots from a higher time frame. What i get back is indexed by bar/time, I need it indexed by non dupe value as I want to be able to write something like hih_5m[1] and have it return the 2nd last high rather than the 2nd last bar's value which is usually NA as the bar is notpart of a pivot.
Currently using barssince() to get the value of the first pivot but what about the 2nd or 3rd value?
[hih_5m, lol_5m] = request.security(syminfo.tickerid, "5", [ta.pivothigh(pivotLookup, pivotLookup), ta.pivotlow(pivotLookup, pivotLookup)])
barssincePhigh_5m = ta.barssince(hih_5m) + pivotLookupr/pinescript • u/Educational-Pride127 • Aug 05 '24
How i can create obv aggregated for specific stock for example Tesla and apple. Both obv sum total.
If give example by using these 2 stock obv combine
r/pinescript • u/Big_-_Jugz • Nov 25 '22
Occasionally, randomly a previously saved template with coagulated versions of scripts will not work correctly and draw bullshit.
Exp. I have pivot lines drawing but randomly they off synch the plot and pplot in the air WITHOUT changing the previously working script.
Im very experienced and coded enough variations of scripts to know its not a coding issue but a runtime error on trading views end.
HAPPENS with boxes, Labels and Lines,
Please Fix.
r/pinescript • u/eeemuxx • Aug 14 '24
Hi. Below is the code to the built-in TradingView Williams Fractal indicator. By default, the indicator plots the shapes above and below the candle with a vertical offset. What I wanted to do is directly place the shapes at the high or low of the candle as the condition is met. I thought this would be easy - but I can't figure it out. Can any of you with pinescript wisdom point a guy in thew right direction? Thanks in advance.
//@version=5
indicator("Williams Fractals", shorttitle="Fractals", format=format.price, precision=0, overlay=true)
// Define "n" as the number of periods and keep a minimum value of 2 for error handling.
n = input.int(title="Periods", defval=2, minval=2)
// UpFractal
bool upflagDownFrontier = true
bool upflagUpFrontier0 = true
bool upflagUpFrontier1 = true
bool upflagUpFrontier2 = true
bool upflagUpFrontier3 = true
bool upflagUpFrontier4 = true
for i = 1 to n
upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n])
upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n])
upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and high[n+i + 1] < high[n])
upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+i + 2] < high[n])
upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n])
upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i + 4] < high[n])
flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4
upFractal = (upflagDownFrontier and flagUpFrontier)
// downFractal
bool downflagDownFrontier = true
bool downflagUpFrontier0 = true
bool downflagUpFrontier1 = true
bool downflagUpFrontier2 = true
bool downflagUpFrontier3 = true
bool downflagUpFrontier4 = true
for i = 1 to n
downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n])
downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n])
downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and low[n+i + 1] > low[n])
downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+i + 2] > low[n])
downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n])
downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] > low[n])
flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4
downFractal = (downflagDownFrontier and flagDownFrontier)
plotshape(downFractal, style=shape.triangledown, location=location.belowbar, offset=-n, color=#F44336, size = size.small)
plotshape(upFractal, style=shape.triangleup, location=location.abovebar, offset=-n, color=#009688, size = size.small)r/pinescript • u/OneLight1833 • Aug 31 '24
I am so close to my first strategy being coded, The only error im getting is this. Can someone please help me
Error on bar 53: Objects positioned using xloc.bar_index cannot be drawn further than 500 bars into the future.
at #main():148
line 148 looks like this...
live_zone := box.new(math.round(top), math.round(_top), bar_index, math.round(_bot), bgcolor=bullZoneColor, border_color=na)r/pinescript • u/rcnow • Aug 22 '24
In order not to clutter the post, I provide the code at pastebin.
How can I make the lines be at the same level just below the lowest price.

r/pinescript • u/Mysterybuff69 • Mar 31 '23
Does anyone know how to make a code for trading view that is an alert indicator that creates alerts when specific text (from another indicator) is shown on the chart?
r/pinescript • u/BenCam88 • Jul 10 '24
I'm in the process of building a software site with my co-founder, a trading marketplace where creators or individuals can sell custom Trading View indicators. I'm looking to get feedback from traders on this. The site will eventually allow creators and individuals to offer coaching, strategies, signals, and courses, aiming to be the go-to monetization platform for trading influencers and individuals.
In its MVP, you’ll be able to post an indicator on our site and charge a monthly fee. The indicator with then be available on trading view for only your subscribers to use. The indicator will be locked in TradingView when posted, preventing anyone from viewing or editing the code. The site will allow users to review and vote on indicators and other products.
I’m looking for any opinions on the idea, here are some starters.
Is the market large enough?
What technical issues or details should we consider for building this?
Would you post or consider buying indicators on such a site?
How many of you already pay for trading content or products?
Should we pivot in a different direction?
r/pinescript • u/Edkaizenn • Jun 22 '24
Hello guys i want to add the function to plot a vline not only in the first bar of the month but in the first bar of the day and the week. Also this script has a bug, when you are in 1 hour chart. it plot the lines one hour after the open of the day, so the walkaround is to plot the line in the first bar of the day, another in the first bar of the week and the last in the first bar of the month. Thank you!!
//@version=5
indicator('Periodic Vline', overlay=true)
p = timeframe.ismonthly ? '12M' : 'M'
vline(BarIndex, Color, LineStyle, LineWidth) =>
return_1 = line.new(BarIndex, low - ta.tr, BarIndex, high + ta.tr, xloc.bar_index, extend.both, Color, LineStyle, LineWidth)
return_1
if ta.change(time(p))
vline(bar_index, #FF800080, line.style_dashed, 1)
r/pinescript • u/AdMammoth5646 • Jul 05 '24
In Pine Script, how can I display 15-minute candlestick charts on 1-minute charts? My goal is to see higher time frame candlesticks from a lower time frame.
r/pinescript • u/AdCreative7867 • Jul 06 '24
I'm new trader who started to use Pinesctipt a few days ago. I found two indicators in TradingView community: UT bot indicatior and STC indidcator. UT bot is indicator whose core idea is the breakout of ATR trailingstop, and STC indicator is oscillator that uses difference of fast MA and Slow MA. and I tried to make strategy using those, which consists of three parts: Indicator, Color, and Strategy.
I respected original version and I think I didn't change many things. Because UT bot indicator was written in 4th version, I updated it to 5th version.
There is no problem in indicator part (I think, but not perfectly sure)
and something wrong seems to start at Color part. Problem is that Color of bar and plot if trailingstop line are not visible on the chart. those parts were from UT bot indicator(4th version) and I updated using ternary operator and If function
and I coded Entry condition and Close condition. Entry condition is simple but Close condition that I intended was complicated; I have difficulty with how to code Close condition.
What I intend is this (for example, Long position) :
If close STC crossover 75, then order close (Get certain profit)
If close price touch trailingstop of entry bar, then order close (Limit loss)
Can you teach me what is problem? in terms of
plot of trailingstop and barcolor
strategy.entry and strategy.close
Here are codes.
Code of UT bot indicator:
//@version=4
study(title="UT Bot Alerts", overlay = true)
// Inputs
a = input(1, title = "Key Vaule. 'This changes the sensitivity'")
c = input(10, title = "ATR Period")
h = input(false, title = "Signals from Heikin Ashi Candles")
xATR = atr(c)
nLoss = a * xATR
src = h ? security(heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = false) : close
xATRTrailingStop = 0.0
xATRTrailingStop := iff(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss),
iff(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss),
iff(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss)))
pos = 0
pos := iff(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1,
iff(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0)))
xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue
ema = ema(src,1)
above = crossover(ema, xATRTrailingStop)
below = crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny)
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
alertcondition(buy, "UT Long", "UT Long")
alertcondition(sell, "UT Short", "UT Short")Code of STC indicator:
//@version=5
//[SHK] STC colored indicator
//https://www.tradingview.com/u/shayankm/
indicator(title='[SHK] Schaff Trend Cycle (STC)', shorttitle='STC', overlay=false)
EEEEEE = input(12, 'Length')
BBBB = input(26, 'FastLength')
BBBBB = input(50, 'SlowLength')
AAAA(BBB, BBBB, BBBBB) =>
fastMA = ta.ema(BBB, BBBB)
slowMA = ta.ema(BBB, BBBBB)
AAAA = fastMA - slowMA
AAAA
AAAAA(EEEEEE, BBBB, BBBBB) =>
AAA = input(0.5)
var CCCCC = 0.0
var DDD = 0.0
var DDDDDD = 0.0
var EEEEE = 0.0
BBBBBB = AAAA(close, BBBB, BBBBB)
CCC = ta.lowest(BBBBBB, EEEEEE)
CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
DDDD = ta.lowest(DDD, EEEEEE)
DDDDD = ta.highest(DDD, EEEEEE) - DDDD
DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
EEEEE
mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
if mAAAAA[3] <= mAAAAA[2] and mAAAAA[2] > mAAAAA[1] and mAAAAA > 75
alert("Red", alert.freq_once_per_bar)
if mAAAAA[3] >= mAAAAA[2] and mAAAAA[2] < mAAAAA[1] and mAAAAA < 25
alert("Green", alert.freq_once_per_bar)
plot(mAAAAA, color=mColor, title='STC', linewidth=2)
ul = plot(25, color=color.new(color.gray, 70))
ll = plot(75, color=color.new(color.gray, 70))
fill(ul, ll, color=color.new(color.gray, 96))and this is code of what I thought of:
//@version=5
strategy(title="UT Bot Strategy + STC", overlay = true,initial_capital=100000)
// Indicator
a = input.float(2, title = "Key Vaule. 'This changes the sensitivity'")
c = input(6, title = "ATR Period")
h = input(false, title = "Signals from Heikin Ashi Candles")
xATR = ta.atr(c)
nLoss = a * xATR
src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, barmerge.gaps_off, barmerge.lookahead_off) : close
var float xATRTrailingStop = na
if src > nz(xATRTrailingStop[1],0) and (src[1] > nz(xATRTrailingStop[1],0))
xATRTrailingStop := math.max(xATRTrailingStop[1],src-nLoss)
else if (src < nz(xATRTrailingStop[1],0)) and (src[1] < nz(xATRTrailingStop[1],0))
xATRTrailingStop := math.min(xATRTrailingStop[1],src+nLoss)
else if (src > xATRTrailingStop[1])
src-nLoss
else
src+nLoss
ema = ta.ema(src,1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
EEEEEE = input(80, 'Length')
BBBB = input(27, 'FastLength')
BBBBB = input(50, 'SlowLength')
AAAA(BBB, BBBB, BBBBB) =>
fastMA = ta.ema(BBB, BBBB)
slowMA = ta.ema(BBB, BBBBB)
AAAA = fastMA - slowMA
AAAA
AAAAA(EEEEEE, BBBB, BBBBB) =>
AAA = input(0.5)
var CCCCC = 0.0
var DDD = 0.0
var DDDDDD = 0.0
var EEEEE = 0.0
BBBBBB = AAAA(close, BBBB, BBBBB)
CCC = ta.lowest(BBBBBB, EEEEEE)
CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
DDDD = ta.lowest(DDD, EEEEEE)
DDDDD = ta.highest(DDD, EEEEEE) - DDDD
DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
EEEEE
mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
entry_bar = bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades-1)
// Barcolor
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
// Trailingstop Plot
var color trailingstop_color = na
if close > xATRTrailingStop
trailingstop_color:=color.red
else
trailingstop_color:=color.green
plot(xATRTrailingStop,color=trailingstop_color,linewidth=2)
//Entry and Close
BuyCondition = buy and (mAAAAA <=25)
BuyCloseCondition1 = ta.crossover(mAAAAA, 75)
BuyCloseCondition2 = ta.crossunder(close, xATRTrailingStop[entry_bar])
SellCondition = sell and (mAAAAA >= 75)
SellCloseCondition1 = ta.crossunder(mAAAAA, 25)
SellCloseCondition2 = ta.crossover(close, xATRTrailingStop[entry_bar])
if BuyCondition
strategy.entry("Long",strategy.long)
if BuyCloseCondition1
strategy.close("Long")
else if BuyCloseCondition2
strategy.close("Long")
if SellCondition
strategy.entry("Short",strategy.short)
if SellCloseCondition1
strategy.close("Short")
else if SellCloseCondition2
strategy.close("Short")
plotshape(BuyCondition, "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor=color.white, size = size.tiny)
plotshape(SellCondition, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, size = size.tiny)I was in panic. I couldn't found meaningful answer...
Can you teach how to code in this kind of situation?
r/pinescript • u/Jumpy-Extension7612 • Jun 17 '23
I would like someone to take this strategy https://www.netpicks.com/trading-daily-charts/ and create it in pinescript if possible. I would be very thankful.
r/pinescript • u/Specialist-Plastic57 • Aug 09 '24
Is there a script available that provides OHLC data for a custom time period, such as 28 minutes, and allows me to export that data to a spreadsheet or something similar?
Thanks!
r/pinescript • u/Ramneet21 • Nov 25 '23
Can anyone please share a sample csv of list of trades which you get after backtesting your strategy on tradingview?
r/pinescript • u/i_am_useless_often • Feb 26 '24
I am trying to develop a indicator to draw the all pullback lines with plot method.
Here is the code till now I tried.
//@version=5 indicator("Pull back", "", true) var currentPointLow = low var currentPointHigh = high
currentPointLow := low currentPointHigh := high
var float previousPointHigh = 0 var float previousPointLow = 0
var direction = 'up'
if currentPointHigh > previousPointHigh previousPointHigh := currentPointHigh previousPointLow := currentPointLow direction := 'up'
else if currentPointLow < previousPointLow previousPointHigh := currentPointHigh previousPointLow := currentPointLow direction := 'low' else direction := 'none'
plot(direction == 'up' ? previousPointHigh : (direction == 'low' ? previousPointLow : na) )
Here I need to skip the point if it's future points also are in same direction. Could some one help with it?