Questions tagged [pine-script]

Pine Script is a domain-specific language for coding custom technical indicators and strategies on TradingView. Use this tag for questions related to programming in Pine Script. Please do not use the [tradingview-api] tag for Pine-related questions.

Pine Script is a domain-specific language for coding custom technical indicators and strategies on TradingView. Use this tag for questions related to programming in Pine Script.

6637 questions
0
votes
0 answers

Why is my close value in my strategy stopped updating every tick after 2 minutes of running?

This is a really simple code but I must figure out the problem in order to work with my real strategy: strategy("My strategy", overlay=true, calc_on_every_tick = true) plot(close) It simply plots the close in the chart, it worked correctly as…
0
votes
0 answers

How to get the cumulative of the series inside an array

con = ta.crossover(ta.rsi(close, 10), 20) ser1 = 0 ser2 = 0 if con[1] ser1 := math.round(math.random(-5, 5)) ser2 := math.round(math.random(-5, 5)) I have two series ser1 & ser2 which are always zero except when condition con[1] is…
bbnm
  • 1,034
  • 1
  • 4
  • 14
0
votes
0 answers

How to plot ema line only if cross over is true in the last candle

I would like to plot ema10 line, only if the ema10>ema20 in the last date(today) Plot(ema10[1]>ema20[1]?ema10:na) plots for the dates where ema10>ema20. But I wanna plot the ema10 for all the dates, if last value of ema10> last value of…
0
votes
1 answer

Does anyone know how to add alerts for anytime the candle in the code shows on the chart in pinescript

I would just like to be able to add alerts for when this type of candle displays on the chart.
0
votes
1 answer

take profit is not working but stop loss is pinescript

hello i'm trying to set a specific take profit amount in pine script code but it is skipping take profit amount and just hitting stop loss amount //@version=5 strategy("Golden cross","GC", overlay = true) ma9 = ta.sma(close,9) ma50 =…
0
votes
1 answer

How to convert Pine Script V2 to V4/V5

I am trying to convert the the following Pine Script V2 Code to V4 or V5. I have tried updating the code automatically using the the 3 dots on upper right side and manually but have no luck. Mostly having issues on converting line 13, 14, 16, 17,…
0
votes
0 answers

In Pinescript, how to save math.min() or array.min() price?

Is there any way to save either math.min() or array.min() price? Every time my algo recognizes a candle pattern and a breakdown from math.min() happens the candle after, that's the only time it goes in the bar after the candle pattern for a trade.…
0
votes
1 answer

I would like plot EMA weekly only on TF Daily, how do i do this?

EmaW = request.security(syminfo.tickerid, "1W", ma1, barmerge.gaps_on, barmerge.lookahead_off) 5W = barstate.islast ? EmaW5 plot(timeframe.isdaily and show_ema_WEEKLY ? print_5:na,"Ema 5 WEEKLY", linewidth=6, color=color.new(color.gray,50)) I…
0
votes
2 answers

Pine Script failed to plot some data

I'm trying to plot some data in pine script, some data failed to plot; here is the script // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © subikshababu //@version=5 indicator("Gain…
0
votes
1 answer

Open a Long position during candle, not at close of candle

Afternoon, I am trying to write a simple strategy to open a long trade intra-candle and not at close. I've tried a few settings that didn't work so stripped the script down to a dummy sample. The code below opens the long at the close of the candle…
user2883072
  • 217
  • 3
  • 12
0
votes
1 answer

Pinescript code not generating tradingview strategy results

The code is below. //@version=4 strategy("52 Weeks High with Trailing Stop", overlay=true) // Define input variables trailStopPercent = input(1.0, "Trailing Stop Percentage") // Calculate the 52-week high high52Weeks = highest(high, 252) //…
0
votes
1 answer

Unadjusted close for pine script tradingview

I'm writing a code which calculates the average volume over a 200 day period multiplied by the average close price over the same period. In the chart, I'm using the dividend adjusted price (this is required for other indicators I'm also running),…
0
votes
0 answers

Triggering entry on Renko chart based on opening of following timeframe

I’m testing a PineScript strategy based on a simple EMA crossing on a Renko chart. One problem I’ve come across is simply that, if in any given timeframe, multiple Renko bricks are printed that cause my EMA crossover to trigger, it will say my entry…
0
votes
1 answer

Pinescript Can't exit with more exits

//I am trying to close a position with more than one exit but multiple exits seem not working. //If I comment the first exit the other works and viceversa. //I can't understand why they don't work together: //Sell Condition 2 and //Sell Condition 3…
0
votes
0 answers

Would It be Possible to calculate the percentage of bars that price closed between two specified values? Pinescript

Basically I want to calculate the percentage of bars that closed between two calculated values. Not even sure if it's possible. I tried ta.barsince, the math.sum function but couldn't get it. I think I'm just barely missing it and just need a push…