Questions tagged [pine-script-v5]

This tag should be used for questions relating to scripts and code built specifically on version 5 of Trading View's Pine Script language.

2372 questions
0
votes
0 answers

Detect uptrend/downtrend with Close and Moving Averages

I would like to achieve the following: Check last fully closed 5min candle and compare "close" value with multiple SMA values at that time. Check last 1min candle from the fully closed 5min candle and compare "close" value with multiple SMA values…
Adrihin
  • 23
  • 5
0
votes
1 answer

How to get a price at a specific date within a function?

I need to get a price (in my case the first opening price) after a specifig date. I've got the timestamp, let's say I need the first opening price after 15.05.2019. The function is called on the last bar on the chart, so I really need to get a…
TSC
  • 1
0
votes
0 answers

PINE SCRIPT how to backtest on only the first candle of the day

I need some advice. I have been searching the web for a long time without any lock. Short story: I have been waking up at 00:00 UTC every single day for the past 5 years to execute my trades and a month ago I came up with an idea I have a problem…
0
votes
1 answer

Strategy to sell after X amount of bars

I am trying to add to a strategy, something very simple - to sell after X amount of bars when the trigger has been reached. I tried this code recommended online, but it doesn't seem to work: if sellFb == true and buyFb == false …
makat
  • 154
  • 1
  • 3
  • 14
0
votes
0 answers

How can i store and display lines and mitigated lines in arrays?

//@version=5 indicator("test V/TWAP + Close", overlay = true) //string tfInput = input.timeframe("W", "Timeframe") tf1 = input.timeframe('W', '1st T/Vwap timeframe') bool showVwaps = input.bool(true, 'Show VWAP and TWAP') bool showClose =…
0
votes
1 answer

Loop array Alert only showing array 0

i have written a pinescript using array ( with parts borrowed from others). Once i put it up on tradingview and ran it is working but the problem is that when i get an alert, it sends the alert for the first symbol in the array and not the actual…
Juz
  • 17
  • 3
0
votes
1 answer

PineScript time pause from orders since last strategy exit order

i want to make an 1 hour delay after my strategy hit stop loss or take profit. Here is an example that is not working, would you explain me why or figure it out? PineScript v5 on tradingview xSMA = ta.sma(close, Length) xHighBand = xSMA + (xSMA *…
0
votes
0 answers

PINE SCRIPT How to customize open / close time on daily candle

Can anyone guide me on what code I can use in PineEditor to change the time the daily candle opens and close in TradingView? Instead of my trades being executed and backtested on candle close that is closed in standard 00:00 UTC I want my daily…
0
votes
1 answer

Freezing the timeframe for multiple lines code

I have the following indicator that I defined. I would like to fix the timeframe so it always show me the output/results of the 1D timeframe no matter what timeframe I am in. I tried to wrap in a func, but I failed. I also tried to fixed the…
sey eeet
  • 229
  • 2
  • 8
0
votes
1 answer

Pine script runs long strategy but not the corresponding short strategy on tester

I am trying to run a strategy for short positions. I have the corresponding strategy running perfectly for the long positions, but for some reason I am blind to i do not see why it doesnt work. I have made sure the tp/sl make sense but cannot figure…
0
votes
0 answers

Chart shows where alert is supposed to fire but it doesn't, TradingView Pine Script

On my chart I have a visual representation of a condition that becomes true and then plots an arrow, in the block of code that this condition becomes true I have an alert set up. Sometimes the condition becomes true and I see the visual confirmation…
Secof
  • 1
  • 2
0
votes
1 answer

How to avoid same direction alert?

I am creating an indicator pinescript. And the strategy will exit on the reverse direction. For example : 20:00 : Long (Entry) 20:30 : Short (Exit and Entry Short) But, I found it's trigger multipler alert on Indicator. I know we can check the last…
0
votes
1 answer

opening of hedging position using pinescript

i am finding that the instrument that i trade in (nifty options and bank nifty options) provide huge swings at specific times on a regular basis (say at 1200 IST, 1500 IST, and 1345 IST), mostly corresponding to opening of London and NASDAQ. i want…
0
votes
0 answers

Background to cover both candle

I'm trying to get the background color to cover both candle, but I've been struggling to do this. Does anyone have a clue? If you look at the below image, I am looking for the blue background to cover both candle of the IB and OB and yellow for OB…
Philo
  • 5
  • 2
0
votes
1 answer

Pine script store one specific candle data in variable

I want to store one specific candle of the day, say O=H or O=L in variable and it will be valid until next such candle form, Once I get candle, need to get OHLC data of this candle, How can I store this candle?
rjcode
  • 1,193
  • 1
  • 25
  • 56