Category "pine-script"

Pine Script Strategy - Position Entry directly after Exit

i want to do a strategy that entries a position at the buy-level (blue Line) and sells after reaching the take-profit-Level (green line) or the stop-level (red

How to make the counting of an event's occurrences started from the occurrence of a(nother) certain event? V5

The function to be used in this case is: cnt = math.sum(cond ? 1 : 0, len) In my (defective) example: NumberOfOccurrencesToBeCounted = math.sum(OccurrencesToBe

Possible to call the "Regression Trend" tool in pine script?

TradingView has this convenient Regression Trend tool in its UI, which can generate the trend channel for a specified period of time. I'm trying to create a pin

Pine Script issue with repeated entries after strategy.exit

I've created a trading strategy in PineScript. I'm using strategy.entry to open longs and shorts (only one position at a time). And I am closing the current pos

Tradingview Pine Script help - how to not duplicate trigger alert

I am having issue with the code below. Apparently this code gives buy/sell plotshapes on the chart, but it gives too many duplicate shapes (multiple buy signals

Tradingview - Pinescript and strategy issues

I'm not a coder but doing my best :) I have made some code for tradingview where I use ema's and hoffman strategy to open and close orders. First it was an indi

How can get version@4 of this scripts with same result of version@2

strategy("P&F scalp strat", shorttitle="MEXlongOnly_strat", overlay=true) timeframe = input('1') box = input('Traditional') boxsize = input(1, type=float) r

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

How to make more than 40 security() calls?

I know the maximum number of security() calls in pinescript is 40 but I came across following workaround from pinecoder.com : The limit for security() calls is

Is there a way to plot values from a google sheets workbook to tradingview pinescript?

I am trying to plot values calculated in an GoogleSheets workbook on a tradingview chart. I cannot do the same calculations in Tradingview because the values co

strategy.exit exiting all orders at arbitrary point even with independent pts/stop losses (pyramiding)

So this is a follow-up from my previous question. I've tried to utilize some arrays to create multiple buy, profit taking and stop orders so that trades can be

History referencing in Pine Script arrays

I have been trying to use array feature, which recently has been introduced in PineScript 4, but it seams that either I'm not aware of its limitations, or , pos

Pinescript - Why does my stoploss trigger upon entry stop?

I'm working strategy based on a MTF Stoch RSI indicator I created. In the strategy, based on Stoch RSI higher and medium timeframe direction and entry timeframe

How to convert strategy to study pinescript V5

I need to figure out how to turn my strategy into a study for V5 Pinescript. I cannot seem to find any info about it online. Im pretty sure for v3 you have to c

Difference between := and = operator in pine script

I'm super new to TradingView Pine Script and I didn't find a proper reference for understanding the difference between the := and = operators. Does anyone have

Get Value of MACD on different TimeFrame

How can you get the value of the Macd Line and Signal Line real-time from different timeframe. Like for example I am on a 4HR chart and I want to get the value

Variable not becoming a series of values. Why?

I created this script to detect Swing Highs and Lows and then to determine the High and Low values of these Swings. The code works for the last bar, but I wou

Check if crossover occurred in the period of last 10 candles

I am working on a strategy that requires me to check if there was a certain crossover few candles back in time when I get my signal on current candle close. Rig

Highest high "of the last n days", not "n days ago"

If I want to compare the close of today with the high of the last 4 days, what is the format? I have used _hi = close > high[4] ? 1 : 0 But that only coun

Pinescript duplicate alerts

I have created a very basic script in pinescript. study(title='Renko Strat w/ Alerts', shorttitle='S_EURUSD_5_[MakisMooz]', overlay=true) rc = close buy_entr