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
1 answer

how to compute the subtract of two arrays?

What is the correct way of computing the difference between two arrays of the same size and give them to a new array. Given array A and B this does not work: float[] C = A-B. e.g.: A = array.new_int(100,-1) B = array.new_int(100,1) how to do A-B
sey eeet
  • 229
  • 2
  • 8
0
votes
0 answers

Repainting script even after using barstate.isconfirmed

Below script is firing multiple alerts and I have tried using barstate.isconfirmed but still firing sometimes up to 6 alerts together. I am a beginner to this. //@version=5 strategy('STG1', overlay=true, calc_on_order_fills = true) start =…
0
votes
0 answers

replace all the elements in an array with a new value

I have two arrays of the same size, A and B. What would be the fastest way to replace all elements in A that have value equal to y to change and be become equal to z? The arrays are not small in terms of size. I can think of a simple for loop along…
sey eeet
  • 229
  • 2
  • 8
0
votes
1 answer

How can a label be deleted if the condition becomes false

If my condition is true and plot a label to the chart but it should become false if the next bars high is higher then the high of the bar where the condition is true. the condtion should plot a label if bear is true, but when the next bar is higher…
sammyp
  • 21
  • 2
0
votes
1 answer

Compilation error. Line 6: Mismatched input '(' expecting ID

I dont know what it wants from me, can somebody help me? import("sma") Here is the rest of the code // © Gittiwilo //@version=5 import("sma") //define the variables for the EMA periods, stop loss, and take profit levels: emaShortPeriod =…
Gittiwilo
  • 11
  • 2
0
votes
1 answer

PineScript: How to partial-exit a position without TP/SL?

I want to do a partial exit of my position (50%) on a condition that does NOT imply SL nor TP. How can I do it? As I don't want to close my position, I don't use strategy.close but strategy.exit instead: if condition strategy.exit(id="long…
0
votes
1 answer

Strategies and indicators in one script

When I put the conditional expression of the rsi value in the chart and set ovrylay= true, the strategy and rsi come out together on the chart, making it difficult to see the chart. What function can I use to make the strategy appear above the chart…
김한수
  • 15
  • 3
0
votes
1 answer

Pine script - count number of losses

Trying to count how many streaks of losses I had in a specified timeframe. My code: newLoss = (strategy.losstrades > strategy.losstrades[1]) and (strategy.wintrades == strategy.wintrades[1]) and (strategy.eventrades ==…
0
votes
1 answer

How can I code a function to show/hide QMI indicator on the settings ? PINESCRIPT

`Experts, I wanted to add a function I can hide/unhide this indicator. so far I tried using showzigzaglen(true, "QMI", "inline=01") plot(showzigzaglen ? zigzaglen : na) it's not hiding the indicator from the settings or turning it off, I'm trying…
0
votes
0 answers

Pinescript reset indicator when specific condition is met

I am using ta.supertrend() indicator in my script which is being calculated and drawn from the start of max bars back. Once an order is opened, I would like to reset the indicator so that it starts the calculation at the bar of order entry. Is there…
0
votes
1 answer

Problem with pinescript filling Ugly angles and wrong color placement

So I am trying to achieve something like this. A clean and nice fill, but using my code I get a very ugly filling like in this image Here is my code indicator(title="Stochastic RSI", shorttitle="Stoch RSI", format=format.price, precision=2,…
0
votes
1 answer

Pinescript strategy Max losing streak

Can someone please help me to get Longest losing streak in specific time frame? It should look at all of the trades in a daterange and find the longest loss streak. My code currently only gets the current streak, I can't figure out how to make it…
0
votes
1 answer

how to get time of a bar_index for each bar_index?

Is there a way to get the time of each bar_index? I am doing if peakLow array.push(VarArrayBarIndexLows, bar_index-1) array.push(VarArrayLowsValues, low[1]) I am wondering how I can also add the time of the bar_index-1 to an…
sey eeet
  • 229
  • 2
  • 8
0
votes
1 answer

Pine v5 script - why isn't this percentage conversion working?

I have a TradingView Pine v5 strategy script that buys if the price closes a certain percentage below the set EMA level and sells if the price closes a certain percentage above the same EMA level. Here's the working code for that: // EMA…
bat_cmd
  • 148
  • 6
0
votes
1 answer

how to find the time difference in terms of day or hours?

I was wondering if I can somehow find the time difference between two times in pine script? For example: Can I find the difference between timestamp(2020,12,1,0,0) and time in terms of hours of days?
sey eeet
  • 229
  • 2
  • 8