Questions tagged [pine-script-v4]

Pine Script is a scripting language designed by TradingView. It allows users to create custom indicators and run them on their servers.

Pine is a lightweight language focused on the specific task of developing indicators and strategies. Most of TradingView’s built-in indicators have been coded in Pine.

See documentation of Pine Script v4

665 questions
1
vote
1 answer

How do trail_points and trail_offset work with Takeprofit and Stoploss

I'm new to Pine Scripts and I'm trying to write a Strategy to test a new Indicator, the below is my code if Up and (downbefore == true) strategy.entry("buy",strategy.long,1000000) strategy.exit("Exit buy", from_entry="buy", profit = 150000,…
1
vote
1 answer

line 39: 'if' cannot be used as a variable or function name

Can anyone please help me understand what is the issue with the code I have written below. My apologies, I am a new coder and I'm finding the debugging process to be difficult. The error I'm getting is in the Title. line 39: 'if' cannot be used as a…
1
vote
1 answer

Boxes for Intraday Sessions are not showing up

This script paints Lines under specific sessions, however, it only allows sessions by the hour. How am I able to modify this to show timeframes such as 8:30 to 11:30? I have not much experience with coding, but so far, this is what I've been trying…
1
vote
1 answer

Stop Loss and revers positions in the strategy

I would like my Stop loss reverse my position. Is it possible to do? When SL Long go to Short and when SL Short go to Long. I was looking for a solution, but unfortunately I did not find it. Thank You! strategy.entry('Long', strategy.long,…
1
vote
1 answer

Is it possible to add multiple trendlines based on different time frames to this Pine Script?

I have been using this pine script recently, but I would like to be able to have multiple iterations of it on the same chart just from different time frames. Is this something that can be easily done? //Fill Arrays with latest LOWS/HIGHS //Get…
1
vote
1 answer

convert older version to version 4

Following code is older version of pine script, i converted into version 4 and result is different. in older version result is correct. pls help me same result in version 4 study(title="CD_Average Daily Range Zones", shorttitle="CD_Daily High/Low…
uTrade
  • 13
  • 3
1
vote
1 answer

How to get a table as user input in PineScript?

I want to be able to turn the table on / off in my chart. I couldn't figure out, how to get a table as user input though.
KarlEs
  • 51
  • 5
1
vote
1 answer

How to convert input.session (local time) to exchange time

Requirement: I am working on a pine strategy where the strategy need to avoid taking any new trades during multiple time range. And this restriction should be applicable only for today/current_tradingday. E.g. I have taken 3 input.sessions() as in…
Krish
  • 13
  • 4
1
vote
1 answer

Print the pourcentage of each candle

Is it possible to print on the top or buttom of each candle the value like the % ? Like this one (just the %)
chprot
  • 29
  • 5
1
vote
1 answer

Combine 2 Strategies. Enter only when both in same direction?

I usually combine multiple strategies and test them. When i use the and logic, the strategy enters only when buyCondition (be it ta.crossover OR >/< value type logic) of both strategies align on top of each other, which is not what i want. I want…
1
vote
1 answer

plotshape() with multiple condition (array) and multi-timeframe not working

I'm trying to plotshape() with multiple conditions from 2 or more timeframe and it's not working IF there are 2 or more conditions from the other timeframe which data pulled with request.security(). Please see code with comments on what works and…
Om Nom
  • 169
  • 1
  • 2
  • 11
1
vote
1 answer

How to store a value on PineScript after an entry?

I'm setting a take profit value 1:1 to the risk. It's based on ATR. Once the price closes above/below atr it gives me the entry point and after that, I calculate the distance between the entry price and the ATR. So this distance will be as same as…
1
vote
0 answers

How to implement a Super trend crossover

I am new to pine script. I am trying to create strategy with below condition. if current price is greater than supertrend(5,1) and current price is greater than 20 EMA then "BUY" if current price is less than supertrend(5,1) and current price is…
Tech_Learn
  • 11
  • 1
  • 6
1
vote
1 answer

Alerts with sound

The script below identifies a doji candle and changes it to a yellow colour and works. What command line would trigger a sound alert in TV on a specific timeframe like 5 mins? In TV there are global alert function they have limited choices based on…
1
vote
1 answer

PineScript v2 to v4 conversion, Cant Convert with Self Referencing Variable

I'm trying to convert my Pine script version 2 indicator to version 4 so I publish it, but it uses a self-referencing variable which they got rid of in version 3. To solve it it needs to be wrapped as stated in the reference page I will link at the…
DejaBrew
  • 11
  • 1