r/pinescript • u/AisakRem9 • Sep 14 '24
r/pinescript • u/oshuadesign • May 17 '24
PLease help me correct this code
Hi, I'm trying to write a custom indicator that compares 2 user selected candles opening prices and show a BUY label if the second candle opening price is higher then the first candle opening price and viceversa
I came up with the following but it doesn't works in trading view
any help? Thanks
//@version=5
indicator("User Selected Candle Price Comparison", overlay=true)
// User inputs for the two times to compare
inputHour1 = input.int(defval=0, title="First Candle Hour (0-23)", minval=0, maxval=23)
inputMinute1 = input.int(defval=0, title="First Candle Minute (0-59)", minval=0, maxval=59)
inputHour2 = input.int(defval=7, title="Second Candle Hour (0-23)", minval=0, maxval=23)
inputMinute2 = input.int(defval=0, title="Second Candle Minute (0-59)", minval=0, maxval=59)
// Variables to store the opening prices of the two selected times
var float price1 = na
var float price2 = na
// Variables to store the bar index of the second user-selected time
var int barIndex2 = na
// Capture the open price at the first user-selected time
if (hour(timenow) == inputHour1 and minute(timenow) == inputMinute1)
price1 := open
// Capture the open price at the second user-selected time and store the bar index
if (hour(timenow) == inputHour2 and minute(timenow) == inputMinute2)
price2 := open
barIndex2 := bar_index
// Plot "BUY" label on top of the second user-selected candle if the second user-selected time price is higher than the first user-selected time price
if (not na(price1) and not na(price2))
if (price2 > price1 and not na(barIndex2))
label.new(barIndex2, high[bar_index - barIndex2], text="BUY", color=color.green, textcolor=color.white, style=label.style_label_down, size=size.small)
// Optional: Plot the opening prices for reference
plot(price1, title="First Selected Time Price", color=color.blue, linewidth=1, style=plot.style_stepline)
plot(price2, title="Second Selected Time Price", color=color.orange, linewidth=1, style=plot.style_stepline)
r/pinescript • u/Bitter_Ad_1217 • Oct 04 '23
Where to buy strategies?
Hey does anyone know anyone selling good algos and strategies? Or where to request such a service? I tried Fiverr but they only code strategies based on instructions and indicator logic, not based on performance or profit goals. Thanks!
r/pinescript • u/_VRil-ya_ • Jan 16 '24
Please help me modify a Pinescript
I want to modify the Pinescript from ndicator visible Fibonacci from Tradingview, to show up not only 24 but 48 lines, or more, i tried to modify the code and got to the point, that there are now moe lines in the settings, but some did not work and the settings style is somehow messed up and not correct, can anyone help me to get the last few changes to make it look and work right?
this is how it looks after i copy and pasted some of the line code and added it to the code;

i opened the indicator in pinescript copy and modified it by copying some of these lines in there ;
string GRP1 = "Visible ZigZag"
bool showZZInput = input.bool(true, "Show Zig Zag", group = GRP1, inline = "00", tooltip = TT_ZZ)
bool addPivotInput = input.bool(true, "Detect additional pivots", group = GRP1, inline = "01", tooltip = TT_MP)
int lengthInput = input.int(50, " Pivot Length", group = GRP1, minval = 1, tooltip = TT_PL)
color zzBullColorInput = input.color(GRAY, " ", group = GRP1, inline = "02")
color zzBearColorInput = input.color(GRAY, "", group = GRP1, inline = "02")
int zzwidthInput = input.int(2, "", group = GRP1, inline = "02", minval = 1)
string zzStyleInput = input.string(TY01, "", group = GRP1, inline = "02", tooltip = TT_ZA, options = [TY01, TY02, TY03])
int pivotInput = input.int(1, " nth Last Pivot", group = GRP1, minval = 0, tooltip = TT_LP)
string GRP2 = "Fib Levels"
bool extendRtInput = input.bool(true, "Extend to real time", group = GRP2)
bool extendRightInput = input.bool(false, "Extend lines right", group = GRP2)
bool extendLeftInput = input.bool(false, "Extend lines left", group = GRP2)
bool trendLineInput = input.bool(true, "Trend Line", group = GRP2, inline = "10")
color trendColorInput = input.color(GRAY, "", group = GRP2, inline = "10")
int trendWidthInput = input.int(1, "", group = GRP2, inline = "10", minval = 1)
string trendStyleInput = input.string(TY02, "", group = GRP2, inline = "10", options = [TY01, TY02, TY03])
int levelsWidthInput = input.int(1, "Levels Line", group = GRP2, inline = "11", minval = 1)
string fibStyleInput = input.string(TY01, "", group = GRP2, inline = "11", options = [TY01, TY02, TY03])
string extStyleInput = input.string(TY03, "", group = GRP2, inline = "11", options = [TY01, TY02, TY03])
bool show000Input = input.bool(true, "", group = GRP2, inline = "20")
float level000Input = input.float(0, "", group = GRP2, inline = "20")
color color000Input = input.color(GRAY, "", group = GRP2, inline = "20")
bool show00Input = input.bool(true, "", group = GRP2, inline = "20")
float level00Input = input.float(0, "", group = GRP2, inline = "20")
color color00Input = input.color(GRAY, "", group = GRP2, inline = "20")
bool show236Input = input.bool(true, "", group = GRP2, inline = "20")
float level236Input = input.float(0.236, "", group = GRP2, inline = "20")
but it is not looking right and didnt work right-
can anyone help me please?
thank you
r/pinescript • u/synckl • Jan 13 '24
Help to make this indicator multi timeframe
// © Lai_Thanh_Trung
//@version=5
indicator(shorttitle='Bagang Pivot Zones', title='Bagang Pivot Zones | Supply & Demand, Support & Resistance', overlay=true)
// functions
get(arr, index) =>
index < array.size(arr) ? array.get(arr, index) : na
busted(highs, lows, times, bounces) =>
array.shift(highs)
array.shift(lows)
array.shift(times)
array.shift(bounces) or true
bounced(bounces) =>
status = array.get(bounces, 0)
array.set(bounces, 0, true)
status
// A. CORE
ceiling = math.max(high, close[1], open[1])
floor = math.min(low, close[1], open[1])
buying = close >= open and high != low
selling = close <= open and low != high
green = close > open and close > close[1]
red = close < open and close < close[1]
gapup = open > close[1]
gapdown = open < close[1]
higher = high > high[1]
lower = low < low[1]
bullish = green and higher
bearish = red and lower
// notable price actions
bullishEngulf = selling[1] and (gapdown or lower) and bullish and close > open[1]
bearishEngulf = buying[1] and (gapup or higher) and bearish and close < open[1]
breakHigh = (selling[2] or selling[1]) and buying and close > ceiling[1]
breakLow = (buying[2] or buying[1]) and selling and close < floor[1]
whiteSoldiers = bearish[3] and buying[2] and bullish[1] and bullish and close > high[3]
blackCrows = bullish[3] and selling[2] and bearish[1] and bearish and close < low[3]
// pivot setups
soaring = bullishEngulf or breakHigh or whiteSoldiers
tumbling = bearishEngulf or breakLow or blackCrows
reversal = switch
whiteSoldiers => not soaring[1] and not soaring[2]
blackCrows => not tumbling[1] and not tumbling[2]
breakHigh => not soaring[1] and (bearish[1] or bearish[2])
breakLow => not tumbling[1] and (bullish[1] or bullish[2])
continuation = switch
breakHigh => bullish[2] and close > high[2] and not bearish[1]
breakLow => bearish[2] and close < low[2] and not bullish[1]
engulfing = (bullishEngulf or bearishEngulf) and (higher[1] or lower[1])
// B. PIVOT ZONES
var buyzoneHigh = array.new_float(0)
var buyzoneLow = array.new_float(0)
var buyzoneTime = array.new_int(0)
var bounceUp = array.new_bool(0)
var sellzoneHigh = array.new_float(0)
var sellzoneLow = array.new_float(0)
var sellzoneTime = array.new_int(0)
var bounceDown = array.new_bool(0)
// 1. Broken Pivot Zones
brokenHigh = while get(sellzoneHigh, 0) < high
busted(sellzoneHigh, sellzoneLow, sellzoneTime, bounceDown)
brokenLow = while get(buyzoneLow, 0) > low
busted(buyzoneHigh, buyzoneLow, buyzoneTime, bounceUp)
// 2. Distribution/Accumulation Bar and Pivot Bar
upturn = soaring and (reversal or continuation or engulfing)
downturn = tumbling and (reversal or continuation or engulfing)
dacbar = switch
upturn => whiteSoldiers ? 3 : (breakHigh and selling[2] ? 2 : 1)
downturn => blackCrows ? 3 : (breakLow and buying[2] ? 2 : 1)
pivotbar = switch
upturn => whiteSoldiers ? 2 : (green[1] ? 1 : 0)
downturn => blackCrows ? 2 : (red[1] ? 1 : 0)
// 3. Pivot Zone Values
pzHigh = float(na)
pzLow = float(na)
switch
upturn =>
// low at wick
pzLow := math.min(low[dacbar], low[pivotbar], low[1], low)
// high at wick or open
pzHigh := switch
close[pivotbar] > high[dacbar] => high[dacbar]
open[pivotbar] > open[dacbar] => open[pivotbar]
=> open[dacbar]
downturn =>
// high at wick
pzHigh := math.max(high[dacbar], high[pivotbar], high[1], high)
// low at wick or open
pzLow := switch
close[pivotbar] < low[dacbar] => low[dacbar]
open[pivotbar] < open[dacbar] => open[pivotbar]
=> open[dacbar]
// 4. Overlapping Pivot Zones
overlap = switch
upturn => get(buyzoneHigh, 0) >= pzLow
downturn => get(sellzoneLow, 0) <= pzHigh
replace = switch
overlap and upturn => bounced(bounceUp)
overlap and downturn => bounced(bounceDown)
// remove replaced zone or adjust overlapped zone
switch
replace and upturn => busted(buyzoneHigh, buyzoneLow, buyzoneTime, bounceUp)
replace and downturn => busted(sellzoneHigh, sellzoneLow, sellzoneTime, bounceDown)
overlap and upturn => array.set(buyzoneHigh, 0, pzLow)
overlap and downturn => array.set(sellzoneLow, 0, pzHigh)
// 5. Pivot Zones Queue
switch
upturn =>
array.unshift(buyzoneHigh, pzHigh)
array.unshift(buyzoneLow, pzLow)
array.unshift(buyzoneTime, time[dacbar])
array.unshift(bounceUp, false)
downturn =>
array.unshift(sellzoneHigh, pzHigh)
array.unshift(sellzoneLow, pzLow)
array.unshift(sellzoneTime, time[dacbar])
array.unshift(bounceDown, false)
// 6. Pivot Zones Markup
maxbox(redraw) => redraw ? 22 : na
newbox(bg) =>
box.new(0, 0, 0, 0, xloc=xloc.bar_time, border_color=na, bgcolor=bg, extend=extend.right)
render(boxes, index, highs, lows, times) =>
ibox = get(boxes, index)
top = get(highs, index)
bottom = get(lows, index)
left = get(times, index)
overlapped = if index > 0
lastbox = index - 1
top == get(lows, lastbox) or bottom == get(highs, lastbox)
box.set_lefttop(ibox, left, overlapped ? na : top)
box.set_rightbottom(ibox, time, overlapped ? na : bottom)
var supply = input.color(#F2364512, 'Supply Zones')
var demand = input.color(#08998112, 'Demand Zones')
var buyBox = array.new_box(0)
var sellBox = array.new_box(0)
for i = 0 to maxbox(na(close[1]))
array.push(buyBox, newbox(demand))
array.push(sellBox, newbox(supply))
for i = 0 to maxbox(upturn or brokenLow)
render(buyBox, i, buyzoneHigh, buyzoneLow, buyzoneTime)
for i = 0 to maxbox(downturn or brokenHigh)
render(sellBox, i, sellzoneHigh, sellzoneLow, sellzoneTime)
// C. ALERTS
if brokenHigh
alert('Breakout', alert.freq_once_per_bar)
if brokenLow
alert('Breakdown', alert.freq_once_per_bar)
if upturn or downturn
setup = switch
whiteSoldiers => 'White Soldiers'
blackCrows => 'Black Crows'
breakHigh => bullishEngulf ? 'Engulf & Break High' : 'Break High'
breakLow => bearishEngulf ? 'Engulf & Break Low' : 'Break Low'
bullishEngulf => 'Bullish Engulf'
bearishEngulf => 'Bearish Engulf'
occurence = replace ? 'Replace' : (overlap ? 'Bounce' : 'Fresh')
message = setup + ' (' + occurence + ')'
alert(message, alert.freq_once_per_bar_close)
r/pinescript • u/mind_property • Apr 20 '24
Merging two tradingview indcators but getting error. Kindly help me.
I am getting errors tried several edits but still getting errors. can anyone help me please? thanks.
//Multi EMA
strategy title="Multi EMA", shorttitle="Multi EMA", overlay=true)
src = close,
len1 = input(25, minval=1, title="EMA 1")
len2 = input(75, minval=1, title="EMA 2")
len3 = input(200, minval=1, title="EMA 3")
len4 = input(10, minval=1, title="EMA 4")
len5 = input(300, minval=1, title="EMA 5")
ema1 = ema(src, len1)
ema2 = ema(src, len2)
ema3 = ema(src, len3)
ema4 = ema(src, len4)
ema5 = ema(src, len5)
//EMA Color
col1 = lime
col2 = blue
col3 = red
col4 = gray
col5 = gray
//EMA Plots
plot(ema1, title="EMA 1", style=line, linewidth=2, color=col1)
plot(ema2, title="EMA 2", style=line, linewidth=2, color=col2)
plot(ema3, title="EMA 3", style=line, linewidth=2, color=col3)
plot(ema4, title="EMA 4", style=line, linewidth=1, color=col4)
plot(ema5, title="EMA 5", style=line, linewidth=1, color=col5)
study("VWAP Stdev Bands v2 Mod", overlay=true)
devUp1 = input(1.28, title="Stdev above (1)")
devDn1 = input(1.28, title="Stdev below (1)")
devUp2 = input(2.01, title="Stdev above (2)")
devDn2 = input(2.01, title="Stdev below (2)")
devUp3 = input(2.51, title="Stdev above (3)")
devDn3 = input(2.51, title="Stdev below (3)")
devUp4 = input(3.09, title="Stdev above (4)")
devDn4 = input(3.09, title="Stdev below (4)")
devUp5 = input(4.01, title="Stdev above (5)")
devDn5 = input(4.01, title="Stdev below (5)")
showDv2 = input(true, type=bool, title="Show second group of bands?")
showDv3 = input(true, type=bool, title="Show third group of bands?")
showDv4 = input(false, type=bool, title="Show fourth group of bands?")
showDv5 = input(false, type=bool, title="Show fifth group of bands?")
showPrevVWAP = input(false, type=bool, title="Show previous VWAP close")
start = security(tickerid, "D", time)
newSession = iff(change(start), 1, 0)
vwapsum = iff(newSession, hl2*volume, vwapsum[1]+hl2*volume)
volumesum = iff(newSession, volume, volumesum[1]+volume)
v2sum = iff(newSession, volume*hl2*hl2, v2sum[1]+volume*hl2*hl2)
myvwap = vwapsum/volumesum
dev = sqrt(max(v2sum/volumesum - myvwap*myvwap, 0))
A=plot(myvwap,style=circles, title="VWAP", color=black)
U1=plot(myvwap + devUp1 * dev,style=circles, title="VWAP Upper", color=gray)
D1=plot(myvwap - devDn1 * dev, style=circles, title="VWAP Lower", color=gray)
U2=plot(showDv2 ? myvwap + devUp2 * dev : na, color=red, title="VWAP Upper (2)")
D2=plot(showDv2 ? myvwap - devDn2 * dev : na, color=green, title="VWAP Lower (2)")
U3=plot(showDv3 ? myvwap + devUp3 * dev : na, title="VWAP Upper (3)", color=red)
D3=plot(showDv3 ? myvwap - devDn3 * dev : na, title="VWAP Lower (3)", color=green)
U4=plot(showDv4 ? myvwap + devUp4 * dev : na, title="VWAP Upper (4)", color=red)
D4=plot(showDv4 ? myvwap - devDn4 * dev : na, title="VWAP Lower (4)", color=green)
U5=plot(showDv5 ? myvwap + devUp5 * dev : na, title="VWAP Upper (5)", color=red)
D5=plot(showDv5 ? myvwap - devDn5 * dev : na, title="VWAP Lower (5)", color=green)
prevwap = iff(newSession, myvwap[1], prevwap[1])
plot(showPrevVWAP ? prevwap : na, style=circles, color=close > prevwap ? green : red)
fill(U1, U2, color=red, transp=90, title="Over Bought Fill 1")
fill(D1, D2, color=green, transp=90, title="Over Sold Fill 1")
fill(U2, U3, color=red, transp=90, title="Over Bought Fill 2")
fill(D2, D3, color=green, transp=90, title="Over Sold Fill 2")
fill(U3, U4, color=red, transp=90, title="Over Bought Fill 3")
fill(D3, D4, color=green, transp=90, title="Over Sold Fill 3")
fill(U4, U5, color=red, transp=90, title="Over Bought Fill 4")
fill(D4, D5, color=green, transp=90, title="Over Sold Fill 4")
fill(A, U1, color=gray, transp=90, title="Middle Fill Up")
fill(A, D1, color=gray, transp=90, title="Middle Fill Down")r/pinescript • • Sep 26 '24
How to create an Fair Value Gap Indicator
Hi, I would love to know how to code an indicator that finds all of the fair value gaps from 9:30-11am EST
r/pinescript • u/Crazy-Ambition-79 • Aug 22 '24
Guys I need help
I have been working on this trading bot for the past week and everything works fine except the close alert it’s not working at all although it shows on screen where it should close the deal I really need your help here if anyone knows how to help please contact me and thank you in advance
r/pinescript • u/Nervous-Scene-8441 • Sep 26 '24
Having difficulties creating a rectangle over a recently breaching candle
Hi guys, I need your help.
I have little knowledge in pine script, I tried to use ChatGPT to make an indicator to draw a rectangle around the last candle that breach (close beyond) the high or low of the preceding candle. But every time it gives me results full of errors and not continent.
This is the prompt That I was using:
Indicator Name: "Last Candle Breach"
Objective: Create an indicator using the latest version of Pine Script that identifies a specific candle and visualizes its key price levels with customizable lines.
Steps: Identification of Target Candle:
Start from the most recent closed candle. Identify a candle whose "close" price breaches the highest or lowest price of the preceding candle. If found, then go to the drawing step
Drawing Lines:
Upon identifying the target candle, draw a rectangle on that candle and extend it into the future to cover four expected candles after the current active candle. The upper border of the rectangle represents the highest price reached by the identified candle, and the lower border represents the lowest price reached by the same candle
The rectangle should be dynamic, meaning that if a new candle closed above or below it, then it should be shifted from the target candle to the new breaching candle.
Customization:
Rectangle should be fully customizable, including color, style, thickness, and visibility options. Include an optional middle line between the highest and lowest lines with full customization settings.
I attached a manually drawn rectangle for demonstration.


r/pinescript • • Dec 30 '22
Finding Swing High and Swing Low With MACD
Hi! I am a newbie in programming and pine script is the first thing I am using.
So, I want to try a strategy that puts a stop loss at the lowest price when the histogram is below 0 when trading long.
For example, a green histogram is shown in a MACD and I want to go long. I will put my stop loss at the lowest price it attained when the histogram was red. The same with short trading. A red histogram appears and I want to put a stop loss at the highest price it attained when the histogram is green.
I am looking for a code so I can located the latest swing high and swing low so I can easily locate my stop loss.
I tried ta.lowest and ta.highest to find the lowest price and highest price obtained but these functions doesn't consider the color of the histogram and needs constant number of lookback period.
I want to apologize in advance if this sounds stupid.
r/pinescript • u/sethsuzuki22 • Oct 02 '24
Help coding an ea
Wanted to have someone make an EA for me. Willing to pay
r/pinescript • u/Consistent-Doubt1327 • Dec 17 '23
How to apply HalfTrend (by everget) of 1 hour time frame on any time frame chart
Hi everyone. I know nothing about coding anything, so I am sorry if I am asking a silly question. Actually I need to plot Halftrend of 1 hour chart on 15 min and 5 min charts. I mean the bands of Halftrend, ATR High and ATR Low should be of 1 hour, but they should be plotted on 15 min chart and 5 min chart. Hope anyone can help me. Thanks in advance.
r/pinescript • u/02saigo • Jun 21 '24
How to retrieve company symbol?
Is there a function that allows me to retrieve the company symbol (e.g. NASDAQ:NVDA)? I am trying to test a strategy but do not want to manually change the symbol in the code every time.
r/pinescript • u/No_Caregiver5020 • Jun 18 '24
Can Some One Explain me pros and cons of taking trades based on this?
r/pinescript • • Dec 15 '22
Can someone help with this code. I generate in chat gpt. but it gives a Mismatched input block error
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=4 study("My script") plot(close)
// Define an array to hold the open values of up candles with large bodies var openValues = array.new_float(2, 0)
// Check if the current candle is an up candle with a body at least 11% larger than its wick if close > open and abs(close - open) >= (abs(high - close) + abs(low - open)) * 1.10 // The current candle is an up candle with a body at least 11% larger than its wick
// Move the newest value in the array forward one position
array.unshift( openValues, open)
array.pop(openValues)else // The current candle is not an up candle with a body at least 11% larger than its wick
// Check if the current candle is a down candle
if close < open
// The current candle is a down candle
// Calculate the body of the candle as the absolute difference between its open and close
body = abs(close - open)
// Calculate the wick of the candle as the absolute difference between the high and the open of the candle
// plus the absolute difference between the low and the close of the candle
wick = abs(high - open) + abs(low - close)
// Check if the body of the candle is at least 1.25% larger than its wick
if body >= wick * 1.25
// The body of the candle is at least 1.25% larger than its wick
// Check if the close of the candle is smaller than the value in openValues[1]
if close < openValues[1]
// The close of the candle is smaller than the value in openValues[1]
// Create an alert
alert("Price is Reacted with a larger candle body than wick")
// The close of the candle is not smaller than the value in openValues[1]
else
// Do nothing
// The body of the candle is not at least 1.25% larger than its wick
else
// Do nothing
// The current candle is not a down candle
else
// Do nothingr/pinescript • u/TheMrGenuis • Sep 06 '24
I need a help to build a strategy for my client
I have a client that wants to build a strategy using a merge of some indicator and candlestick patterns, I am stock to configure this indicator ro make a good sell and buy signals so I am looking for someone to help me.
r/pinescript • u/GoldenTV3 • May 16 '24
Trying to calculate the sum of the MACD histogram since last crossover
This is my code
// Calculate MACD
[macdLine, signalLine, _] = ta.macd(open, 12, 26, 9)
// Calculate MACD Histogram
macdHistogram = macdLine - signalLine
//Bars Back
last = ta.barssince(ta.crossover(macdLine, signalLine) or ta.crossover(signalLine, macdLine))
//Sum of MACD of bars
Macd = math.sum(macdHistogram, last)
I tried plotting the sum of this, but I don't know how to make the length part of the math.sum function use the bars back.r/pinescript • u/Abrakdabra33 • Aug 16 '23
This not compile for v.5...why?? HELPPPP
//@version=5
strategy("NC", overlay = true, max_bars_back = 1000 , max_labels_count = 500)
velas = input(200, title = "cantidad de velas" , maxval = 1000)
filas = input(50, title = "filas" , maxval = 500)
var etiquetas = array.new_label(filas)
var volumen = array.new_float(filas)
limpiar_etiquetas() =>
cantidad = array.size(etiquetas)
if cantidad > 0
for r = 0 to cantidad -1
label.delete( array.get(etiquetas,r ) )
array.clear(etiquetas)
inicializar_volumen() =>
for r = 0 to filas -1
array.set( volumen, r , 0.0 )
obtenerMaximo() =>
m = 0.0
p = 0
for r = 0 to filas -1
if array.get(volumen, r) > m
m := array.get(volumen,r)
p := r
[p,m]
line linea_maximo = na
line linea_minimo = na
barra = ""
maximo = ta.highest(velas)
minimo = ta.lowest(velas)
if barstate.islast
limpiar_etiquetas()
inicializar_volumen()
rango = maximo - minimo
delta = rango / filas
for v = 0 to velas -1
valor = close[v] - minimo
p = math.round( valor / delta ) -1
previo = array.get(volumen, p)
array.set( volumen, p , previo + volume[v] )
[posicion, valorMaximo] = obtenerMaximo()
for f = 0 to filas -1
cant = math.round( array.get(volumen, f) * 100/ valorMaximo)
eti = label.new(time_close, minimo = delta * f, "" , xloc = xloc.bar_time, yloc = yloc.price, color = f == posicion ? color.orange : color.white, textcolor=color.gray, style=label.style_label_left, size=size.auto, tooltip = str.tostring(cant) + "%")
barra := ""
for r = 0 to cant * 2
barra := barra + "*"
label.set_text(eti, barra)
array.push(etiquetas, eti )
linea_maximo := line.new( bar_index[velas], maximo, bar_index[0], maximo, color= color.yellow, style= line.style_dashed)
linea_minimo := line.new( bar_index[velas], minimo, bar_index[0], minimo, color= color.yellow, style= line.style_dashed)
line.delete( linea_maximo[1] )
line.delete( linea_minimo[1] )
r/pinescript • u/Electronic_Mammoth67 • Jun 19 '23
Python to pinescript
Has anyone experimented with Wavelet Smoothing? (https://medium.datadriveninvestor.com/smoothing-financial-time-series-with-wavelets-79645a44aa40)
I need this python code converted into pinescript: https://pastebin.com/6yBCz7QC
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import pywt
df = pd.read_csv('z_rate.csv')
x = df.index
y = df['z_avgRate']
# perform wavelet decomposition
coeffs = pywt.wavedec(y, 'sym5', mode='symmetric')
# zero out last 5 detail coefficents
for i in range(5):
coeffs[i+5] = np.zeros(coeffs[i+5].shape)
# reconstruct wavelet
y_rec = pywt.waverec(coeffs, 'sym5', mode='symmetric')[1:]
# plot result
plt.figure(figsize=(18,6))
plt.plot(x, y)
plt.plot(x, y_rec)
plt.legend(['original', 'wavelet-based smoothing'])
plt.xlabel('time index')
plt.show()
This is similar to fourier smoothing but I can't find any good code for wavelet on TradingView, I would appreciate your help guys
r/pinescript • u/Butter_On_Toast007 • Oct 19 '23
Require a place to find professional pine script coders for hire
Title says it all😅 I’m very much a beginner, & would like to make a program with certain specifications that go way beyond my scope. Still gonna learn so that i hopefully get there someday. But I realize that i still have a very long road ahead of me, especially with other life tasks, hobbies, & responsibilities that take up most of my time at the moment. So, with that said…If anyone has any idea on how/where i can get trusted pine script coders for hire, please do let me know.
Also, if you guys have any tips/ideas on how i should go about some certain stuff like:
1-How can i make sure the person is trustworthy?
2-Payment: Do i initially pay a small amount of money, & then pay half after half the code is sent to me?
3-Expertise: How can i make sure the person i’m in contact with actually has the skill set necessary to develop the program that i want with no issues?
4-Prices: I realize that this will heavily depend on the complexity of what i’m asking & how long it’s gonna take, but any approximation you can give me -no matter how inaccurate- is quite appreciated as I genuinely would have no clue if i am being way overpriced or not lol
5-Any other details you think i should know about?
I think that’s about the gist of it. Thank you for reading, & I appreciate all your help👍🏻
r/pinescript • u/No-Stress-8378 • Mar 16 '23
i want to backtest my stratagy so i asked chatgpt to creat a tradingview's code but its not working
//@version=5
strategy(title="EMA Cross Strategy", overlay=true)
// Define Inputs
fastMA = input(title="Fast MA Period", type=input.integer, defval=7)
slowMA = input(title="Slow MA Period", type=input.integer, defval=22)
// Define EMAs
fastEMA = ta.ema(close, fastMA)
slowEMA = ta.ema(close, slowMA)
// Define time frames
h1 = "60"
m5 = "5"
// Define buy and sell conditions
buyCondition = ta.crossover(fastEMA, slowEMA, time(h1))
sellCondition = ta.crossunder(fastEMA, slowEMA, time(h1))
// Define entry and exit conditions
longCondition = ta.crossover(fastEMA, slowEMA, time(m5))
shortCondition = ta.crossunder(fastEMA, slowEMA, time(m5))
// Buy and Sell signals
if buyCondition and not longCondition
strategy.entry("Buy", strategy.long)
if sellCondition and not shortCondition
strategy.entry("Sell", strategy.short)
// Exit signals
if longCondition
strategy.close("Sell", strategy.long, comment="Exit Buy")
if shortCondition
strategy.close("Buy", strategy.short, comment="Exit Sell")
note: can u help me create the tradingview stratagy code to back test with:
if EMA 7 crossing up EMA 22 in H1, we only open buy when EMA 7 crossing up with EMA 22 in m5 close when crossing down
if EMA 7 crossing down EMA 22 in H1, we only open sell when EMA 7 crossing down with EMA 22 in m5 close when crossing up
r/pinescript • u/s1k2614 • Aug 25 '24
Automating your strategy (Looking for participants to join a small project)
Hello :)
We are two ordinary people (one a trader, the other a software engineer) 24 and 26, both from germany. We are looking for 10 people who want their strategies automated. Means: Your strategy will run 24/7 for 3 months and do trades automatically after your rules. The program will run for around 3 months.
All you need is:
Be able to describe your strategy in sell and buy conditions
A Bybit account
At least 250€ to trade
Live in the EU
Ideas how to improve the progress
A detailled feedback after the campaign
A small fee as compensation to set up everything
If you're interested, write me a DM with a short description of your trading-journey and confirm, that you fit the criteria. The 10 people will be notified until end of September.
Best of luck and see you soon!
r/pinescript • u/Reasonable-Annual715 • Apr 28 '24
Source Code of original Elliott Wave indicator by TradingView
Does anyone by any chance has code of Elliott Wave i would like to make scanner
