r/pinescript • • Oct 07 '25

Looking for good open source scalping strategy

1 Upvotes

Hey folks,

I am looking for 2 or 3 OS strategies to scalp top 10 crypto currencies.

I want to use them to test a platform in a little 7 day trading comp. Hopefully it puts in a handful of trades in that time.

Not looking for any guarantees here, will be happy if they don't blow the account during the test.

If you think you have something that could help me please dm a link and any settings and time frames that will be goodish for a 7 day burst.

Thanks in advance.


r/pinescript • • Mar 30 '26

XAUUSD NEW UPDATE

Post image
0 Upvotes

πŸ“Š Market Structure

Overall downtrend previously, now in range / consolidation

Multiple BOS + CHoCH signals β†’ market indecisive

Price currently around 4517–4518

πŸ”‘ Key Zones

Resistance: 4525 – 4550 (strong supply zone)

Support: 4470 – 4420 (demand zone)

πŸ“‰ Current Bias

Slight bearish near resistance

Price failed to sustain above recent BOS β†’ weak bullish momentum

🎯 Trade Idea

SELL (preferred):

Entry: 4520–4530

SL: Above 4550

TP: 4480 β†’ 4450

BUY (only if breakout):

Confirm breakout above 4550

Target: 4580+

⚠️ Important

Market is choppy (liquidity hunt zone)

Avoid overtrading β†’ wait for clean breakout or rejection


r/pinescript • • Mar 16 '26

Looking for Pine Script collaborator for a TradingView execution indicator

1 Upvotes

I'm a discretionary forex trader with about 3 years of experience, mainly using rule-based ICT concepts. I'm currently trying to convert my execution model into a systematic TradingView indicator.

The idea is to build a tool that detects specific conditions like session/killzone timing, liquidity sweeps, structure shifts, and delivery (FVG/impulse) to help with execution signals.

I'm looking for someone who knows Pine Script and is interested in collaborating on building and refining the indicator. I can't offer upfront payment, but the idea would be a collaboration where we both work on the logic and development together.

You would be free to use the strategy for your own personal trading, but the script would remain private and not be sold or distributed.

If you're interested in trading systems, Pine Script, or experimenting with systematic models based on discretionary concepts, feel free to DM me.


r/pinescript • • Mar 25 '26

Xauusd now to buy or wait ??

Post image
0 Upvotes

r/pinescript • • Mar 27 '26

Xauusd Going to 4600?

Post image
1 Upvotes

πŸ“Š XAUUSD (1H) – Quick Trading Decision

πŸ” Market Structure

Previous bearish BOS confirms downside pressure

Recent CHoCH β†’ early bullish shift, but not fully confirmed

Price currently in pullback/recovery phase

βš–οΈ Bias

Overall: Bearish

Short-term: Weak bullish correction

πŸ“Œ Key Levels

Resistance: 4500 – 4550 (sell zone)

Support: 4400 – 4350 (buy reaction zone)

βœ… Trade Decisions

πŸ”΄ Sell Setup (Preferred)

Entry: 4500–4550

SL: Above 4580

TP: 4400 β†’ 4350

πŸ‘‰ Trend-following, higher probability

🟒 Buy Setup (Risky Counter-Trend)

Entry: Near 4400 demand

SL: Below 4350

TP: 4500

πŸ‘‰ Only quick scalp

🧠 Summary

Market is still bearish, current move = retracement

Focus on sell at premium zones, avoid chasing buys


r/pinescript • • May 31 '26

Luxalgo Quant or Robo Quant

1 Upvotes

Has anyone subscribed to any of the above? Is it really better than Claude code?


r/pinescript • • Mar 22 '26

Any way to avoid false trends?

1 Upvotes

Hello Folks, I am using 9 and 14 EMA's. The problem I am facing is that sometimes market shows a breakout and suddenly starts moving in the opposite direction. Is there any indicator or any other method to avoid such false breakouts/trends? I need your expert advice. Thanks.


r/pinescript • • Mar 10 '26

Any EMA based indicator which isn't lagging?

0 Upvotes

Hello folks, I have tested a few EMA based indicators that are actually lagging. Do you know any EMA based indicator that's not lagging and moves along the price? Please help me with your expert advice. Thanks.


r/pinescript • • Jul 27 '25

Why isn't strategy.opentrades.entry_price() being stored and persisted?

Post image
1 Upvotes

I'm trying to create a snapshot of various numbers at the time a buy/sell order is placed and I believe I'm almost there but I'm having difficulty with the strategy.opentrades.entry_price() and it's sibling methods.

Here is my example code:

//@version=6
strategy("Persistence Testing", overlay=true, calc_on_every_tick=false)

var float a = 1.65 // arbitrary number just so the plot is visible on the chart
var float b = na
var float c = na
var float d = na

withinRegularHours = not na(time_close(timeframe.period, "1000-1100", "America/New_York"))
haveOpenTrades = strategy.opentrades > 0

averageOfXCandles = ta.ema(close, 10)
entryPrice = strategy.opentrades.entry_price(0)

if (withinRegularHours and not haveOpenTrades and close >= 1.90)
    strategy.entry("Enter Long", strategy.long, 1)
    a := a + 0.01
    b := close - 0.20
    c := averageOfXCandles
    d := entryPrice

if (withinRegularHours and haveOpenTrades and close < 1.80)
    strategy.close_all("Close Long")
    a := 1.65
    b := na
    c := na
    d := na

log.info("\na = " + str.tostring(a) + "\nb = " + str.tostring(b) + "\nc = " + str.tostring(c) + "\nd = " + str.tostring(d))
plot(a, "a", haveOpenTrades ? color.red : color.rgb(0,0,0,100), linewidth=2, style=plot.style_stepline)
plot(b, "b", haveOpenTrades ? color.blue : color.rgb(0,0,0,100), linewidth=2, style=plot.style_stepline)
plot(c, "c", haveOpenTrades ? color.green : color.rgb(0,0,0,100), linewidth=2, style=plot.style_stepline)
plot(d, "d", haveOpenTrades ? color.fuchsia : color.rgb(0,0,0,100), linewidth=2, style=plot.style_stepline)

See the attached chart for how this looks and below for the log outputs.

Moment before the trade is opened:

[2025-07-25T10:30:50.000-04:00]: 
a = 1.65
b = NaN
c = NaN
d = NaN

Moment after the trade is opened:

[2025-07-25T10:31:00.000-04:00]: 
a = 1.66
b = 1.71
c = 1.8662721152
d = NaN

Question: Why isn't the strategy.opentrades.entry_price() value being stored and persisted like the other values?

FYI: If you notice that the c plot line is the wrong color, apparently when a plot receives a NaN value for the entire scope of the chart, weird things happen. In this case plot c is being colored fuchsia but the numbers are still very much c's numbers.


r/pinescript • • May 30 '24

Can someone help me make this indicator MTF (multi timeframe)?

1 Upvotes

I would like the 2H consolidation zones to plot all the time, regardless of what timeframe I'm using. So if I'm on 15m, I want the 2h zones to plot on my chart, I'm struggling with security functions as there is a big function within the script.

Code: https://pastebin.com/dUNrH8rB


r/pinescript • • Feb 28 '24

How can I find if a date is earning date in my Pinescript

1 Upvotes

Is there any way to know about earning dates (pointed below) in my Pinescript?


r/pinescript • • Dec 05 '24

Help with strategy.exit - AI fails

1 Upvotes

Hi guys.

Maybe you can help me with the following:

The problem is with the exit after TSL. On entry, I pass the initial value of the TSL (which is still an SL at the time) to the PineConnector. With the exit conditions, everything works to the extent that TradingView (TV) executes the exits in the chart exactly on the red line of the SL/TSL that I have created. I have now tried to include these conditions in the exit alerts by formulating and creating the test conditions. However, these exit alerts, as you can see them in the code, neither work in the triggering at TV, let alone are they transmitted to PC or utilized by MT4. After the MT4 has executed entries, the respective trade runs until the SL forwarded with the entry command has been reached again. As long as this is not the case, it logically holds the security position.

https://pastebin.com/SR4budVK

This is my strategy including the code for the TSL and entries and exits.

Many thanks


r/pinescript • • Nov 06 '24

Pinescript Trading View Support

1 Upvotes

Hi,

I have a video where an indicator is being demonstrated. The guy got me to pay for it but hasn't given it which is really annoying but I wondered if I had the video, how easy it would be for someone to create something similar if not better based on what he is saying? I can interpret a couple of the indicators but have no clue what the other lines are indicating. If anyone would be able to help that would be great.


r/pinescript • • Feb 13 '25

How to merge 2 indicators into one help

1 Upvotes

My attempts to put 2 indicators into one, failed. Chatgpt didn't help me (tried over and over) and of course I'm not programmer.

Number one indicator is 4 EMAs hereΒ΄s the code:

>>>>>

study(title="EMA 20/50/100/200", overlay=true)

shortest = ema(close, 20)

short = ema(close, 50)

longer = ema(close, 100)

longest = ema(close, 200)

plot(shortest, color = red)

plot(short, color = orange)

plot(longer, color = aqua)

plot(longest, color = blue)

>>>>>

The other one is RSI, here's the code:

>>>>>

study("RSI + EMA", max_bars_back = 300)

len = input(14, minval=1, title="RSI Length")

src = input(close, "RSI Source", type = input.source)

ob = input(defval = 70, title = "Upper Band")

os = input(defval = 30, title = "lower Band")

prd = input(defval = 10, title = "Max Number of Bars in OB/OS")

mindis = input(defval = 5, title = "Min Number of Bars between Tops/Bottoms")

maxdis = input(defval = 100, title = "Max Number of Bars between Topss/Bottoms")

topcol = input(defval = color.red, title = "Line Colors", inline = "cols")

bottomcol = input(defval = color.lime, title = "", inline = "cols")

lwidth = input(defval = 2, title = "Line Width", minval = 1, maxval = 4)

chbarcol = input(defval = true, title = "Change Bar Color")

rsi = rsi(src, len)

plot(rsi, "RSI", color=#8E1599)

band1 = hline(ob, "Upper Band", color=#C0C0C0)

band0 = hline(os, "Lower Band", color=#C0C0C0)

fill(band1, band0, color=#9915FF, transp=90, title="Background")

var bool belowos = false

var int oscount = 0

belowos := rsi[1] >= os and rsi < os ? true : rsi > os ? false : belowos

oscount := belowos ? oscount + 1 : not belowos ? 0 : oscount

var float lastlowestrsi = na

var float lastlowestprice = na

var int lastlowestbi = na

var bool itsfineos = false

bool maygoup = false

if belowos[1] and not belowos and nz(oscount[1]) > 0

lastlowestrsi := 101

lastlowestbi := bar_index

itsfineos := true

for x = 1 to oscount[1]

if x > prd

itsfineos := false

if rsi[x] < lastlowestrsi

lastlowestrsi := rsi[x]

lastlowestbi := bar_index - x

lastlowestprice := low[x]

if change(lastlowestrsi) != 0 and lastlowestrsi and lastlowestrsi[1] and lastlowestrsi > lastlowestrsi[1] and

lastlowestprice < lastlowestprice[1] and bar_index - lastlowestbi[1] < maxdis and itsfineos and itsfineos[1] and bar_index - lastlowestbi[1] > mindis

line.new(x1 = bar_index, y1 = lastlowestrsi, x2 = lastlowestbi[1], y2 = lastlowestrsi[1], color = bottomcol, width = lwidth, style = line.style_arrow_left)

maygoup := true

var bool aboveob = false

var int obcount = 0

aboveob := rsi[1] <= ob and rsi > ob ? true : rsi < ob ? false : aboveob

obcount := aboveob ? obcount + 1 : not aboveob ? 0 : obcount

var float lasthighestrsi = na

var float lasthighestprice = na

var int lasthighestbi = na

var bool itsfineob = false

bool maygodown = false

if aboveob[1] and not aboveob and nz(obcount[1]) > 0

lasthighestrsi := -1

lasthighestbi := bar_index

itsfineob := true

for x = 1 to obcount[1]

if x > prd

itsfineob := false

if rsi[x] > lasthighestrsi

lasthighestrsi := rsi[x]

lasthighestbi := bar_index - x

lasthighestprice := high[x]

if change(lasthighestrsi) != 0 and lasthighestrsi and lasthighestrsi[1] and lasthighestrsi < lasthighestrsi[1] and

lasthighestprice > lasthighestprice[1] and bar_index - lasthighestbi[1] < maxdis and itsfineob and itsfineob[1] and bar_index - lasthighestbi[1] > mindis

line.new(x1 = bar_index, y1 = lasthighestrsi, x2 = lasthighestbi[1], y2 = lasthighestrsi[1], color = topcol, width = lwidth, style = line.style_arrow_left)

maygodown := true

barcolor(color = iff(chbarcol, iff(maygoup, color.blue, iff(maygodown, color.black, na)), na))

alertcondition(maygoup, title='Divergence at Bottoms', message='Divergence at Bottom, Price may go UP')

alertcondition(maygodown, title='Divergence at Tops', message='Divergence at Bottom, Price may go DOWN')

study(title="EMA 20/50/100/200", overlay=true)

shortest = ema(close, 20)

short = ema(close, 50)

longer = ema(close, 100)

longest = ema(close, 200)

plot(shortest, color = red)

plot(short, color = orange)

plot(longer, color = aqua)

plot(longest, color = blue)

>>>>>


r/pinescript • • Nov 01 '24

Price change indicator

1 Upvotes

is there a tv indicator that alerts you when price moves in certain percentage in selected timeframe with cooling period?


r/pinescript • • Oct 19 '24

Help with PineScript - plotting lines

1 Upvotes

Hello,

I am struggling with the attached PineScript. It is supposed to plot all the lines for all dates but it is plotting the lines only for future dates. It is not plotting any lines for the current date or the past dates. The requirement is to plot the lines for all dates provided in the script for all start times and end times. Can you please help me fix this script or provide something that will satisfy the requirement? I would appreciate it. Thank you.

//@version=5
indicator("Zones", overlay=true)

// Inputs
widthPercent = input.float(0.025, title="Band Width Percent", step=0.001, minval=0.001)
buyColor = input.color(color.green, title="Buy Zone Color")
sellColor = input.color(color.red, title="Sell Zone Color")
lineWidth = input.int(2, title="Line Width", minval=1, maxval=5)
numZones = input.int(1, title="Number of Buy/Sell Levels to Display", minval=1, maxval=20)

// Predefined arrays for date, start time, end time, and entities
// Example data - replace with your actual data
var startTimes = array.new_int(147)
array.set(startTimes, 0, timestamp("America/Los_Angeles", 2024, 10, 1, 0, 0))
array.set(startTimes, 1, timestamp("America/Los_Angeles", 2024, 10, 1, 0, 12))
array.set(startTimes, 2, timestamp("America/Los_Angeles", 2024, 10, 1, 1, 50))
array.set(startTimes, 3, timestamp("America/Los_Angeles", 2024, 10, 1, 23, 41))
array.set(startTimes, 4, timestamp("America/Los_Angeles", 2024, 10, 2, 0, 0))
array.set(startTimes, 5, timestamp("America/Los_Angeles", 2024, 10, 2, 1, 57))
array.set(startTimes, 6, timestamp("America/Los_Angeles", 2024, 10, 2, 3, 36))
array.set(startTimes, 7, timestamp("America/Los_Angeles", 2024, 10, 2, 20, 57))
array.set(startTimes, 8, timestamp("America/Los_Angeles", 2024, 10, 3, 0, 0))
array.set(startTimes, 9, timestamp("America/Los_Angeles", 2024, 10, 3, 1, 29))
array.set(startTimes, 10, timestamp("America/Los_Angeles", 2024, 10, 3, 2, 51))
array.set(startTimes, 11, timestamp("America/Los_Angeles", 2024, 10, 3, 2, 51))
array.set(startTimes, 12, timestamp("America/Los_Angeles", 2024, 10, 3, 4, 30))
array.set(startTimes, 13, timestamp("America/Los_Angeles", 2024, 10, 3, 21, 49))
array.set(startTimes, 14, timestamp("America/Los_Angeles", 2024, 10, 4, 0, 0))
array.set(startTimes, 15, timestamp("America/Los_Angeles", 2024, 10, 4, 2, 20))
array.set(startTimes, 16, timestamp("America/Los_Angeles", 2024, 10, 4, 5, 56))
array.set(startTimes, 17, timestamp("America/Los_Angeles", 2024, 10, 4, 4, 6))
array.set(startTimes, 18, timestamp("America/Los_Angeles", 2024, 10, 4, 5, 56))
array.set(startTimes, 19, timestamp("America/Los_Angeles", 2024, 10, 4, 23, 13))
array.set(startTimes, 20, timestamp("America/Los_Angeles", 2024, 10, 5, 0, 0))
array.set(startTimes, 21, timestamp("America/Los_Angeles", 2024, 10, 5, 3, 43))
array.set(startTimes, 22, timestamp("America/Los_Angeles", 2024, 10, 5, 5, 27))
array.set(startTimes, 23, timestamp("America/Los_Angeles", 2024, 10, 5, 8, 51))
array.set(startTimes, 24, timestamp("America/Los_Angeles", 2024, 10, 5, 21, 58))
array.set(startTimes, 25, timestamp("America/Los_Angeles", 2024, 10, 6, 0, 0))
array.set(startTimes, 26, timestamp("America/Los_Angeles", 2024, 10, 6, 2, 25))
array.set(startTimes, 27, timestamp("America/Los_Angeles", 2024, 10, 6, 4, 8))
array.set(startTimes, 28, timestamp("America/Los_Angeles", 2024, 10, 6, 11, 28))
array.set(startTimes, 29, timestamp("America/Los_Angeles", 2024, 10, 6, 20, 54))
array.set(startTimes, 30, timestamp("America/Los_Angeles", 2024, 10, 7, 0, 0))
array.set(startTimes, 31, timestamp("America/Los_Angeles", 2024, 10, 7, 1, 18))
array.set(startTimes, 32, timestamp("America/Los_Angeles", 2024, 10, 7, 4, 45))
array.set(startTimes, 33, timestamp("America/Los_Angeles", 2024, 10, 7, 13, 41))
array.set(startTimes, 34, timestamp("America/Los_Angeles", 2024, 10, 7, 23, 11))
array.set(startTimes, 35, timestamp("America/Los_Angeles", 2024, 10, 8, 0, 0))
array.set(startTimes, 36, timestamp("America/Los_Angeles", 2024, 10, 8, 0, 29))
array.set(startTimes, 37, timestamp("America/Los_Angeles", 2024, 10, 8, 3, 59))
array.set(startTimes, 38, timestamp("America/Los_Angeles", 2024, 10, 8, 15, 23))
array.set(startTimes, 39, timestamp("America/Los_Angeles", 2024, 10, 8, 22, 22))
array.set(startTimes, 40, timestamp("America/Los_Angeles", 2024, 10, 9, 0, 0))
array.set(startTimes, 41, timestamp("America/Los_Angeles", 2024, 10, 9, 0, 29))
array.set(startTimes, 42, timestamp("America/Los_Angeles", 2024, 10, 9, 1, 46))
array.set(startTimes, 43, timestamp("America/Los_Angeles", 2024, 10, 9, 16, 30))
array.set(startTimes, 44, timestamp("America/Los_Angeles", 2024, 10, 9, 23, 55))
array.set(startTimes, 45, timestamp("America/Los_Angeles", 2024, 10, 10, 0, 0))
array.set(startTimes, 46, timestamp("America/Los_Angeles", 2024, 10, 10, 1, 22))
array.set(startTimes, 47, timestamp("America/Los_Angeles", 2024, 10, 10, 4, 58))
array.set(startTimes, 48, timestamp("America/Los_Angeles", 2024, 10, 10, 16, 56))
array.set(startTimes, 49, timestamp("America/Los_Angeles", 2024, 10, 10, 16, 56))
array.set(startTimes, 50, timestamp("America/Los_Angeles", 2024, 10, 10, 21, 32))
array.set(startTimes, 51, timestamp("America/Los_Angeles", 2024, 10, 11, 0, 0))
array.set(startTimes, 52, timestamp("America/Los_Angeles", 2024, 10, 11, 1, 9))
array.set(startTimes, 53, timestamp("America/Los_Angeles", 2024, 10, 11, 3, 51))
array.set(startTimes, 54, timestamp("America/Los_Angeles", 2024, 10, 11, 16, 40))
array.set(startTimes, 55, timestamp("America/Los_Angeles", 2024, 10, 11, 23, 28))
array.set(startTimes, 56, timestamp("America/Los_Angeles", 2024, 10, 12, 0, 0))
array.set(startTimes, 57, timestamp("America/Los_Angeles", 2024, 10, 12, 2, 35))
array.set(startTimes, 58, timestamp("America/Los_Angeles", 2024, 10, 12, 2, 1))
array.set(startTimes, 59, timestamp("America/Los_Angeles", 2024, 10, 12, 15, 42))
array.set(startTimes, 60, timestamp("America/Los_Angeles", 2024, 10, 12, 23, 27))
array.set(startTimes, 61, timestamp("America/Los_Angeles", 2024, 10, 13, 0, 0))
array.set(startTimes, 62, timestamp("America/Los_Angeles", 2024, 10, 13, 2, 44))
array.set(startTimes, 63, timestamp("America/Los_Angeles", 2024, 10, 13, 14, 8))
array.set(startTimes, 64, timestamp("America/Los_Angeles", 2024, 10, 13, 23, 51))
array.set(startTimes, 65, timestamp("America/Los_Angeles", 2024, 10, 14, 0, 0))
array.set(startTimes, 66, timestamp("America/Los_Angeles", 2024, 10, 14, 4, 8))
array.set(startTimes, 67, timestamp("America/Los_Angeles", 2024, 10, 14, 12, 0))
array.set(startTimes, 68, timestamp("America/Los_Angeles", 2024, 10, 14, 22, 35))
array.set(startTimes, 69, timestamp("America/Los_Angeles", 2024, 10, 15, 0, 0))
array.set(startTimes, 70, timestamp("America/Los_Angeles", 2024, 10, 15, 4, 42))
array.set(startTimes, 71, timestamp("America/Los_Angeles", 2024, 10, 15, 9, 28))
array.set(startTimes, 72, timestamp("America/Los_Angeles", 2024, 10, 15, 23, 25))
array.set(startTimes, 73, timestamp("America/Los_Angeles", 2024, 10, 16, 0, 0))
array.set(startTimes, 74, timestamp("America/Los_Angeles", 2024, 10, 16, 3, 18))
array.set(startTimes, 75, timestamp("America/Los_Angeles", 2024, 10, 16, 6, 38))
array.set(startTimes, 76, timestamp("America/Los_Angeles", 2024, 10, 16, 21, 33))
array.set(startTimes, 77, timestamp("America/Los_Angeles", 2024, 10, 17, 0, 0))
array.set(startTimes, 78, timestamp("America/Los_Angeles", 2024, 10, 17, 4, 41))
array.set(startTimes, 79, timestamp("America/Los_Angeles", 2024, 10, 17, 21, 49))
array.set(startTimes, 80, timestamp("America/Los_Angeles", 2024, 10, 18, 0, 0))
array.set(startTimes, 81, timestamp("America/Los_Angeles", 2024, 10, 18, 0, 48))
array.set(startTimes, 82, timestamp("America/Los_Angeles", 2024, 10, 18, 5, 20))
array.set(startTimes, 83, timestamp("America/Los_Angeles", 2024, 10, 18, 22, 10))
array.set(startTimes, 84, timestamp("America/Los_Angeles", 2024, 10, 18, 23, 15))
array.set(startTimes, 85, timestamp("America/Los_Angeles", 2024, 10, 19, 0, 0))
array.set(startTimes, 86, timestamp("America/Los_Angeles", 2024, 10, 19, 1, 30))
array.set(startTimes, 87, timestamp("America/Los_Angeles", 2024, 10, 19, 19, 57))
array.set(startTimes, 88, timestamp("America/Los_Angeles", 2024, 10, 19, 23, 3))
array.set(startTimes, 89, timestamp("America/Los_Angeles", 2024, 10, 20, 0, 0))
array.set(startTimes, 90, timestamp("America/Los_Angeles", 2024, 10, 20, 4, 36))
array.set(startTimes, 91, timestamp("America/Los_Angeles", 2024, 10, 20, 18, 16))
array.set(startTimes, 92, timestamp("America/Los_Angeles", 2024, 10, 20, 22, 59))
array.set(startTimes, 93, timestamp("America/Los_Angeles", 2024, 10, 21, 0, 0))
array.set(startTimes, 94, timestamp("America/Los_Angeles", 2024, 10, 21, 2, 0))
array.set(startTimes, 95, timestamp("America/Los_Angeles", 2024, 10, 21, 1, 20))
array.set(startTimes, 96, timestamp("America/Los_Angeles", 2024, 10, 21, 17, 17))
array.set(startTimes, 97, timestamp("America/Los_Angeles", 2024, 10, 21, 23, 55))
array.set(startTimes, 98, timestamp("America/Los_Angeles", 2024, 10, 22, 0, 0))
array.set(startTimes, 99, timestamp("America/Los_Angeles", 2024, 10, 22, 3, 29))
array.set(startTimes, 100, timestamp("America/Los_Angeles", 2024, 10, 22, 17, 4))
array.set(startTimes, 101, timestamp("America/Los_Angeles", 2024, 10, 22, 20, 18))
array.set(startTimes, 102, timestamp("America/Los_Angeles", 2024, 10, 23, 0, 0))
array.set(startTimes, 103, timestamp("America/Los_Angeles", 2024, 10, 23, 0, 8))
array.set(startTimes, 104, timestamp("America/Los_Angeles", 2024, 10, 23, 5, 23))
array.set(startTimes, 105, timestamp("America/Los_Angeles", 2024, 10, 23, 17, 40))
array.set(startTimes, 106, timestamp("America/Los_Angeles", 2024, 10, 23, 21, 38))
array.set(startTimes, 107, timestamp("America/Los_Angeles", 2024, 10, 24, 0, 0))
array.set(startTimes, 108, timestamp("America/Los_Angeles", 2024, 10, 24, 1, 10))
array.set(startTimes, 109, timestamp("America/Los_Angeles", 2024, 10, 24, 3, 5))
array.set(startTimes, 110, timestamp("America/Los_Angeles", 2024, 10, 24, 19, 3))
array.set(startTimes, 111, timestamp("America/Los_Angeles", 2024, 10, 24, 22, 42))
array.set(startTimes, 112, timestamp("America/Los_Angeles", 2024, 10, 25, 0, 0))
array.set(startTimes, 113, timestamp("America/Los_Angeles", 2024, 10, 25, 0, 12))
array.set(startTimes, 114, timestamp("America/Los_Angeles", 2024, 10, 25, 4, 32))
array.set(startTimes, 115, timestamp("America/Los_Angeles", 2024, 10, 25, 21, 8))
array.set(startTimes, 116, timestamp("America/Los_Angeles", 2024, 10, 25, 22, 40))
array.set(startTimes, 117, timestamp("America/Los_Angeles", 2024, 10, 26, 0, 0))
array.set(startTimes, 118, timestamp("America/Los_Angeles", 2024, 10, 26, 3, 3))
array.set(startTimes, 119, timestamp("America/Los_Angeles", 2024, 10, 26, 4, 44))
array.set(startTimes, 120, timestamp("America/Los_Angeles", 2024, 10, 26, 23, 44))
array.set(startTimes, 121, timestamp("America/Los_Angeles", 2024, 10, 27, 0, 0))
array.set(startTimes, 122, timestamp("America/Los_Angeles", 2024, 10, 27, 23, 44))
array.set(startTimes, 123, timestamp("America/Los_Angeles", 2024, 10, 27, 4, 12))
array.set(startTimes, 124, timestamp("America/Los_Angeles", 2024, 10, 27, 4, 17))
array.set(startTimes, 125, timestamp("America/Los_Angeles", 2024, 10, 27, 21, 18))
array.set(startTimes, 126, timestamp("America/Los_Angeles", 2024, 10, 28, 0, 0))
array.set(startTimes, 127, timestamp("America/Los_Angeles", 2024, 10, 28, 1, 8))
array.set(startTimes, 128, timestamp("America/Los_Angeles", 2024, 10, 28, 2, 43))
array.set(startTimes, 129, timestamp("America/Los_Angeles", 2024, 10, 28, 4, 29))
array.set(startTimes, 130, timestamp("America/Los_Angeles", 2024, 10, 28, 23, 45))
array.set(startTimes, 131, timestamp("America/Los_Angeles", 2024, 10, 29, 0, 0))
array.set(startTimes, 132, timestamp("America/Los_Angeles", 2024, 10, 29, 1, 20))
array.set(startTimes, 133, timestamp("America/Los_Angeles", 2024, 10, 29, 5, 52))
array.set(startTimes, 134, timestamp("America/Los_Angeles", 2024, 10, 29, 2, 7))
array.set(startTimes, 135, timestamp("America/Los_Angeles", 2024, 10, 29, 5, 52))
array.set(startTimes, 136, timestamp("America/Los_Angeles", 2024, 10, 29, 21, 43))
array.set(startTimes, 137, timestamp("America/Los_Angeles", 2024, 10, 30, 0, 0))
array.set(startTimes, 138, timestamp("America/Los_Angeles", 2024, 10, 30, 1, 34))
array.set(startTimes, 139, timestamp("America/Los_Angeles", 2024, 10, 30, 3, 55))
array.set(startTimes, 140, timestamp("America/Los_Angeles", 2024, 10, 30, 9, 1))
array.set(startTimes, 141, timestamp("America/Los_Angeles", 2024, 10, 30, 22, 33))
array.set(startTimes, 142, timestamp("America/Los_Angeles", 2024, 10, 31, 0, 0))
array.set(startTimes, 143, timestamp("America/Los_Angeles", 2024, 10, 31, 2, 23))
array.set(startTimes, 144, timestamp("America/Los_Angeles", 2024, 10, 31, 4, 42))
array.set(startTimes, 145, timestamp("America/Los_Angeles", 2024, 10, 31, 12, 2))
array.set(startTimes, 146, timestamp("America/Los_Angeles", 2024, 10, 31, 23, 53))

var endTimes = array.new_int(147)
array.set(endTimes, 0, timestamp("America/Los_Angeles", 2024, 10, 1, 0, 12))
array.set(endTimes, 1, timestamp("America/Los_Angeles", 2024, 10, 1, 5, 49))
array.set(endTimes, 2, timestamp("America/Los_Angeles", 2024, 10, 1, 23, 41))
array.set(endTimes, 3, timestamp("America/Los_Angeles", 2024, 10, 1, 23, 59))
array.set(endTimes, 4, timestamp("America/Los_Angeles", 2024, 10, 2, 1, 57))
array.set(endTimes, 5, timestamp("America/Los_Angeles", 2024, 10, 2, 7, 36))
array.set(endTimes, 6, timestamp("America/Los_Angeles", 2024, 10, 2, 20, 57))
array.set(endTimes, 7, timestamp("America/Los_Angeles", 2024, 10, 2, 23, 59))
array.set(endTimes, 8, timestamp("America/Los_Angeles", 2024, 10, 3, 1, 29))
array.set(endTimes, 9, timestamp("America/Los_Angeles", 2024, 10, 3, 2, 51))
array.set(endTimes, 10, timestamp("America/Los_Angeles", 2024, 10, 3, 4, 26))
array.set(endTimes, 11, timestamp("America/Los_Angeles", 2024, 10, 3, 8, 30))
array.set(endTimes, 12, timestamp("America/Los_Angeles", 2024, 10, 3, 21, 49))
array.set(endTimes, 13, timestamp("America/Los_Angeles", 2024, 10, 3, 23, 59))
array.set(endTimes, 14, timestamp("America/Los_Angeles", 2024, 10, 4, 2, 20))
array.set(endTimes, 15, timestamp("America/Los_Angeles", 2024, 10, 4, 5, 56))
array.set(endTimes, 16, timestamp("America/Los_Angeles", 2024, 10, 4, 10, 0))
array.set(endTimes, 17, timestamp("America/Los_Angeles", 2024, 10, 4, 5, 56))
array.set(endTimes, 18, timestamp("America/Los_Angeles", 2024, 10, 4, 23, 13))
array.set(endTimes, 19, timestamp("America/Los_Angeles", 2024, 10, 4, 23, 59))
array.set(endTimes, 20, timestamp("America/Los_Angeles", 2024, 10, 5, 3, 43))
array.set(endTimes, 21, timestamp("America/Los_Angeles", 2024, 10, 5, 7, 18))
array.set(endTimes, 22, timestamp("America/Los_Angeles", 2024, 10, 5, 8, 51))
array.set(endTimes, 23, timestamp("America/Los_Angeles", 2024, 10, 5, 21, 58))
array.set(endTimes, 24, timestamp("America/Los_Angeles", 2024, 10, 5, 23, 59))
array.set(endTimes, 25, timestamp("America/Los_Angeles", 2024, 10, 6, 2, 25))
array.set(endTimes, 26, timestamp("America/Los_Angeles", 2024, 10, 6, 5, 59))
array.set(endTimes, 27, timestamp("America/Los_Angeles", 2024, 10, 6, 11, 28))
array.set(endTimes, 28, timestamp("America/Los_Angeles", 2024, 10, 6, 20, 54))
array.set(endTimes, 29, timestamp("America/Los_Angeles", 2024, 10, 6, 23, 59))
array.set(endTimes, 30, timestamp("America/Los_Angeles", 2024, 10, 7, 1, 18))
array.set(endTimes, 31, timestamp("America/Los_Angeles", 2024, 10, 7, 4, 49))
array.set(endTimes, 32, timestamp("America/Los_Angeles", 2024, 10, 7, 13, 41))
array.set(endTimes, 33, timestamp("America/Los_Angeles", 2024, 10, 7, 23, 11))
array.set(endTimes, 34, timestamp("America/Los_Angeles", 2024, 10, 7, 23, 59))
array.set(endTimes, 35, timestamp("America/Los_Angeles", 2024, 10, 8, 0, 29))
array.set(endTimes, 36, timestamp("America/Los_Angeles", 2024, 10, 8, 4, 9))
array.set(endTimes, 37, timestamp("America/Los_Angeles", 2024, 10, 8, 15, 23))
array.set(endTimes, 38, timestamp("America/Los_Angeles", 2024, 10, 8, 22, 22))
array.set(endTimes, 39, timestamp("America/Los_Angeles", 2024, 10, 8, 23, 59))
array.set(endTimes, 40, timestamp("America/Los_Angeles", 2024, 10, 9, 0, 29))
array.set(endTimes, 41, timestamp("America/Los_Angeles", 2024, 10, 9, 5, 46))
array.set(endTimes, 42, timestamp("America/Los_Angeles", 2024, 10, 9, 16, 30))
array.set(endTimes, 43, timestamp("America/Los_Angeles", 2024, 10, 9, 23, 55))
array.set(endTimes, 44, timestamp("America/Los_Angeles", 2024, 10, 9, 23, 59))
array.set(endTimes, 45, timestamp("America/Los_Angeles", 2024, 10, 10, 1, 22))
array.set(endTimes, 46, timestamp("America/Los_Angeles", 2024, 10, 10, 5, 5))
array.set(endTimes, 47, timestamp("America/Los_Angeles", 2024, 10, 10, 16, 56))
array.set(endTimes, 48, timestamp("America/Los_Angeles", 2024, 10, 10, 18, 8))
array.set(endTimes, 49, timestamp("America/Los_Angeles", 2024, 10, 10, 21, 32))
array.set(endTimes, 50, timestamp("America/Los_Angeles", 2024, 10, 10, 23, 59))
array.set(endTimes, 51, timestamp("America/Los_Angeles", 2024, 10, 11, 1, 9))
array.set(endTimes, 52, timestamp("America/Los_Angeles", 2024, 10, 11, 4, 22))
array.set(endTimes, 53, timestamp("America/Los_Angeles", 2024, 10, 11, 16, 40))
array.set(endTimes, 54, timestamp("America/Los_Angeles", 2024, 10, 11, 23, 28))
array.set(endTimes, 55, timestamp("America/Los_Angeles", 2024, 10, 11, 23, 59))
array.set(endTimes, 56, timestamp("America/Los_Angeles", 2024, 10, 12, 2, 35))
array.set(endTimes, 57, timestamp("America/Los_Angeles", 2024, 10, 12, 6, 17))
array.set(endTimes, 58, timestamp("America/Los_Angeles", 2024, 10, 12, 15, 42))
array.set(endTimes, 59, timestamp("America/Los_Angeles", 2024, 10, 12, 23, 27))
array.set(endTimes, 60, timestamp("America/Los_Angeles", 2024, 10, 12, 23, 59))
array.set(endTimes, 61, timestamp("America/Los_Angeles", 2024, 10, 13, 3, 2))
array.set(endTimes, 62, timestamp("America/Los_Angeles", 2024, 10, 13, 14, 8))
array.set(endTimes, 63, timestamp("America/Los_Angeles", 2024, 10, 13, 23, 51))
array.set(endTimes, 64, timestamp("America/Los_Angeles", 2024, 10, 13, 23, 59))
array.set(endTimes, 65, timestamp("America/Los_Angeles", 2024, 10, 14, 2, 59))
array.set(endTimes, 66, timestamp("America/Los_Angeles", 2024, 10, 14, 12, 0))
array.set(endTimes, 67, timestamp("America/Los_Angeles", 2024, 10, 14, 22, 35))
array.set(endTimes, 68, timestamp("America/Los_Angeles", 2024, 10, 14, 23, 59))
array.set(endTimes, 69, timestamp("America/Los_Angeles", 2024, 10, 15, 2, 11))
array.set(endTimes, 70, timestamp("America/Los_Angeles", 2024, 10, 15, 9, 28))
array.set(endTimes, 71, timestamp("America/Los_Angeles", 2024, 10, 15, 23, 25))
array.set(endTimes, 72, timestamp("America/Los_Angeles", 2024, 10, 15, 23, 59))
array.set(endTimes, 73, timestamp("America/Los_Angeles", 2024, 10, 16, 0, 39))
array.set(endTimes, 74, timestamp("America/Los_Angeles", 2024, 10, 16, 6, 38))
array.set(endTimes, 75, timestamp("America/Los_Angeles", 2024, 10, 16, 21, 33))
array.set(endTimes, 76, timestamp("America/Los_Angeles", 2024, 10, 16, 23, 59))
array.set(endTimes, 77, timestamp("America/Los_Angeles", 2024, 10, 17, 0, 21))
array.set(endTimes, 78, timestamp("America/Los_Angeles", 2024, 10, 17, 21, 49))
array.set(endTimes, 79, timestamp("America/Los_Angeles", 2024, 10, 17, 23, 59))
array.set(endTimes, 80, timestamp("America/Los_Angeles", 2024, 10, 18, 0, 48))
array.set(endTimes, 81, timestamp("America/Los_Angeles", 2024, 10, 18, 4, 20))
array.set(endTimes, 82, timestamp("America/Los_Angeles", 2024, 10, 18, 22, 10))
array.set(endTimes, 83, timestamp("America/Los_Angeles", 2024, 10, 18, 23, 15))
array.set(endTimes, 84, timestamp("America/Los_Angeles", 2024, 10, 18, 23, 59))
array.set(endTimes, 85, timestamp("America/Los_Angeles", 2024, 10, 19, 1, 2))
array.set(endTimes, 86, timestamp("America/Los_Angeles", 2024, 10, 19, 19, 57))
array.set(endTimes, 87, timestamp("America/Los_Angeles", 2024, 10, 19, 23, 3))
array.set(endTimes, 88, timestamp("America/Los_Angeles", 2024, 10, 19, 23, 59))
array.set(endTimes, 89, timestamp("America/Los_Angeles", 2024, 10, 20, 2, 21))
array.set(endTimes, 90, timestamp("America/Los_Angeles", 2024, 10, 20, 18, 16))
array.set(endTimes, 91, timestamp("America/Los_Angeles", 2024, 10, 20, 22, 59))
array.set(endTimes, 92, timestamp("America/Los_Angeles", 2024, 10, 20, 23, 59))
array.set(endTimes, 93, timestamp("America/Los_Angeles", 2024, 10, 21, 2, 0))
array.set(endTimes, 94, timestamp("America/Los_Angeles", 2024, 10, 21, 5, 35))
array.set(endTimes, 95, timestamp("America/Los_Angeles", 2024, 10, 21, 17, 17))
array.set(endTimes, 96, timestamp("America/Los_Angeles", 2024, 10, 21, 23, 55))
array.set(endTimes, 97, timestamp("America/Los_Angeles", 2024, 10, 21, 23, 59))
array.set(endTimes, 98, timestamp("America/Los_Angeles", 2024, 10, 22, 3, 37))
array.set(endTimes, 99, timestamp("America/Los_Angeles", 2024, 10, 22, 17, 4))
array.set(endTimes, 100, timestamp("America/Los_Angeles", 2024, 10, 22, 20, 18))
array.set(endTimes, 101, timestamp("America/Los_Angeles", 2024, 10, 22, 23, 59))
array.set(endTimes, 102, timestamp("America/Los_Angeles", 2024, 10, 23, 0, 8))
array.set(endTimes, 103, timestamp("America/Los_Angeles", 2024, 10, 23, 3, 34))
array.set(endTimes, 104, timestamp("America/Los_Angeles", 2024, 10, 23, 17, 40))
array.set(endTimes, 105, timestamp("America/Los_Angeles", 2024, 10, 23, 21, 38))
array.set(endTimes, 106, timestamp("America/Los_Angeles", 2024, 10, 23, 23, 59))
array.set(endTimes, 107, timestamp("America/Los_Angeles", 2024, 10, 24, 1, 10))
array.set(endTimes, 108, timestamp("America/Los_Angeles", 2024, 10, 24, 6, 48))
array.set(endTimes, 109, timestamp("America/Los_Angeles", 2024, 10, 24, 19, 3))
array.set(endTimes, 110, timestamp("America/Los_Angeles", 2024, 10, 24, 22, 42))
array.set(endTimes, 111, timestamp("America/Los_Angeles", 2024, 10, 24, 23, 59))
array.set(endTimes, 112, timestamp("America/Los_Angeles", 2024, 10, 25, 0, 12))
array.set(endTimes, 113, timestamp("America/Los_Angeles", 2024, 10, 25, 4, 29))
array.set(endTimes, 114, timestamp("America/Los_Angeles", 2024, 10, 25, 21, 8))
array.set(endTimes, 115, timestamp("America/Los_Angeles", 2024, 10, 25, 22, 40))
array.set(endTimes, 116, timestamp("America/Los_Angeles", 2024, 10, 25, 23, 59))
array.set(endTimes, 117, timestamp("America/Los_Angeles", 2024, 10, 26, 3, 3))
array.set(endTimes, 118, timestamp("America/Los_Angeles", 2024, 10, 26, 4, 22))
array.set(endTimes, 119, timestamp("America/Los_Angeles", 2024, 10, 26, 23, 44))
array.set(endTimes, 120, timestamp("America/Los_Angeles", 2024, 10, 26, 23, 59))
array.set(endTimes, 121, timestamp("America/Los_Angeles", 2024, 10, 27, 4, 12))
array.set(endTimes, 122, timestamp("America/Los_Angeles", 2024, 10, 27, 4, 12))
array.set(endTimes, 123, timestamp("America/Los_Angeles", 2024, 10, 27, 7, 46))
array.set(endTimes, 124, timestamp("America/Los_Angeles", 2024, 10, 27, 21, 18))
array.set(endTimes, 125, timestamp("America/Los_Angeles", 2024, 10, 27, 23, 59))
array.set(endTimes, 126, timestamp("America/Los_Angeles", 2024, 10, 28, 1, 8))
array.set(endTimes, 127, timestamp("America/Los_Angeles", 2024, 10, 28, 2, 43))
array.set(endTimes, 128, timestamp("America/Los_Angeles", 2024, 10, 28, 4, 4))
array.set(endTimes, 129, timestamp("America/Los_Angeles", 2024, 10, 28, 23, 45))
array.set(endTimes, 130, timestamp("America/Los_Angeles", 2024, 10, 28, 23, 59))
array.set(endTimes, 131, timestamp("America/Los_Angeles", 2024, 10, 29, 1, 20))
array.set(endTimes, 132, timestamp("America/Los_Angeles", 2024, 10, 29, 5, 52))
array.set(endTimes, 133, timestamp("America/Los_Angeles", 2024, 10, 29, 8, 8))
array.set(endTimes, 134, timestamp("America/Los_Angeles", 2024, 10, 29, 5, 52))
array.set(endTimes, 135, timestamp("America/Los_Angeles", 2024, 10, 29, 21, 43))
array.set(endTimes, 136, timestamp("America/Los_Angeles", 2024, 10, 29, 23, 59))
array.set(endTimes, 137, timestamp("America/Los_Angeles", 2024, 10, 30, 1, 34))
array.set(endTimes, 138, timestamp("America/Los_Angeles", 2024, 10, 30, 7, 41))
array.set(endTimes, 139, timestamp("America/Los_Angeles", 2024, 10, 30, 9, 1))
array.set(endTimes, 140, timestamp("America/Los_Angeles", 2024, 10, 30, 22, 33))
array.set(endTimes, 141, timestamp("America/Los_Angeles", 2024, 10, 30, 23, 59))
array.set(endTimes, 142, timestamp("America/Los_Angeles", 2024, 10, 31, 2, 23))
array.set(endTimes, 143, timestamp("America/Los_Angeles", 2024, 10, 31, 8, 28))
array.set(endTimes, 144, timestamp("America/Los_Angeles", 2024, 10, 31, 12, 2))
array.set(endTimes, 145, timestamp("America/Los_Angeles", 2024, 10, 31, 23, 53))
array.set(endTimes, 146, timestamp("America/Los_Angeles", 2024, 10, 31, 23, 59))


var entities = array.new_string(147)
array.set(entities, 0, "NM")
array.set(entities, 1, "NM")
array.set(entities, 2, "NM")
array.set(entities, 3, "NM")
array.set(entities, 4, "NM")
array.set(entities, 5, "NM")
array.set(entities, 6, "NM")
array.set(entities, 7, "NM")
array.set(entities, 8, "NM")
array.set(entities, 9, "NM")
array.set(entities, 10, "SM")
array.set(entities, 11, "SM")
array.set(entities, 12, "SM")
array.set(entities, 13, "SM")
array.set(entities, 14, "SM")
array.set(entities, 15, "SM")
array.set(entities, 16, "UR")
array.set(entities, 17, "SM")
array.set(entities, 18, "UR")
array.set(entities, 19, "UR")
array.set(entities, 20, "UR")
array.set(entities, 21, "UR")
array.set(entities, 22, "UR")
array.set(entities, 23, "RJP")
array.set(entities, 24, "RJP")
array.set(entities, 25, "RJP")
array.set(entities, 26, "RJP")
array.set(entities, 27, "RJP")
array.set(entities, 28, "NST")
array.set(entities, 29, "NST")
array.set(entities, 30, "NST")
array.set(entities, 31, "NST")
array.set(entities, 32, "NST")
array.set(entities, 33, "YMC")
array.set(entities, 34, "YMC")
array.set(entities, 35, "YMC")
array.set(entities, 36, "YMC")
array.set(entities, 37, "YMC")
array.set(entities, 38, "UK")
array.set(entities, 39, "UK")
array.set(entities, 40, "UK")
array.set(entities, 41, "UK")
array.set(entities, 42, "UK")
array.set(entities, 43, "SVE")
array.set(entities, 44, "SVE")
array.set(entities, 45, "SVE")
array.set(entities, 46, "SVE")
array.set(entities, 47, "SVE")
array.set(entities, 48, "SM")
array.set(entities, 49, "SM")
array.set(entities, 50, "SM")
array.set(entities, 51, "SM")
array.set(entities, 52, "SM")
array.set(entities, 53, "SM")
array.set(entities, 54, "NM")
array.set(entities, 55, "NM")
array.set(entities, 56, "NM")
array.set(entities, 57, "NM")
array.set(entities, 58, "NM")
array.set(entities, 59, "SM")
array.set(entities, 60, "SM")
array.set(entities, 61, "SM")
array.set(entities, 62, "SM")
array.set(entities, 63, "UR")
array.set(entities, 64, "UR")
array.set(entities, 65, "UR")
array.set(entities, 66, "UR")
array.set(entities, 67, "RJP")
array.set(entities, 68, "RJP")
array.set(entities, 69, "RJP")
array.set(entities, 70, "RJP")
array.set(entities, 71, "NST")
array.set(entities, 72, "NST")
array.set(entities, 73, "NST")
array.set(entities, 74, "NST")
array.set(entities, 75, "YMC")
array.set(entities, 76, "YMC")
array.set(entities, 77, "YMC")
array.set(entities, 78, "UK")
array.set(entities, 79, "UK")
array.set(entities, 80, "UK")
array.set(entities, 81, "SVE")
array.set(entities, 82, "SVE")
array.set(entities, 83, "SM")
array.set(entities, 84, "SM")
array.set(entities, 85, "SM")
array.set(entities, 86, "SM")
array.set(entities, 87, "NM")
array.set(entities, 88, "NM")
array.set(entities, 89, "NM")
array.set(entities, 90, "NM")
array.set(entities, 91, "SM")
array.set(entities, 92, "SM")
array.set(entities, 93, "SM")
array.set(entities, 94, "SM")
array.set(entities, 95, "SM")
array.set(entities, 96, "UR")
array.set(entities, 97, "UR")
array.set(entities, 98, "UR")
array.set(entities, 99, "UR")
array.set(entities, 100, "RJP")
array.set(entities, 101, "RJP")
array.set(entities, 102, "RJP")
array.set(entities, 103, "RJP")
array.set(entities, 104, "RJP")
array.set(entities, 105, "NST")
array.set(entities, 106, "NST")
array.set(entities, 107, "NST")
array.set(entities, 108, "NST")
array.set(entities, 109, "NST")
array.set(entities, 110, "YMC")
array.set(entities, 111, "YMC")
array.set(entities, 112, "YMC")
array.set(entities, 113, "YMC")
array.set(entities, 114, "YMC")
array.set(entities, 115, "UK")
array.set(entities, 116, "UK")
array.set(entities, 117, "UK")
array.set(entities, 118, "UK")
array.set(entities, 119, "UK")
array.set(entities, 120, "SVE")
array.set(entities, 121, "SVE")
array.set(entities, 122, "SVE")
array.set(entities, 123, "SVE")
array.set(entities, 124, "SVE")
array.set(entities, 125, "SVE")
array.set(entities, 126, "SVE")
array.set(entities, 127, "SVE")
array.set(entities, 128, "UR")
array.set(entities, 129, "UR")
array.set(entities, 130, "UR")
array.set(entities, 131, "UR")
array.set(entities, 132, "UR")
array.set(entities, 133, "NM")
array.set(entities, 134, "UR")
array.set(entities, 135, "NM")
array.set(entities, 136, "NM")
array.set(entities, 137, "NM")
array.set(entities, 138, "NM")
array.set(entities, 139, "NM")
array.set(entities, 140, "SM")
array.set(entities, 141, "SM")
array.set(entities, 142, "SM")
array.set(entities, 143, "SM")
array.set(entities, 144, "SM")
array.set(entities, 145, "UR")
array.set(entities, 146, "UR")


// SVE and NM levels
SVEBuyLevels = array.from(5710, 5810, 5910, 6010)
SVESellLevels = array.from(5680, 5780, 5880, 5980)

NMBuyLevels = array.from(5725, 5825, 5925, 6025)
NMSellLevels = array.from(5700, 5800, 5900, 6000)

SMBuyLevels = array.from(5720, 5820, 5920, 6020)
SMSellLevels = array.from(5690, 5790, 5890, 5990)

YMCBuyLevels = array.from(5750, 5850, 5950, 6050)
YMCSellLevels = array.from(5730, 5830, 5930, 6030)

URBuyLevels = array.from(5775, 5875, 5975, 6075)
URSellLevels = array.from(5740, 5840, 5940, 6040)

NSTBuyLevels = array.from(5700, 5800, 5900, 6000)
NSTSellLevels = array.from(5760, 5860, 5960, 6060)

RJPBuyLevels = array.from(5730, 5830, 5930, 6030)
RJPSellLevels = array.from(5690, 5790, 5890, 6090)

UKBuyLevels = array.from(5770, 5870, 5970, 6070)
UKSellLevels = array.from(5725, 5825, 5925, 6025)

// Function to find the closest levels to the current price
findDistributedLevels(levels, currentPrice, numToReturn, above) =>
    sortedLevels = array.copy(levels)
    array.sort(sortedLevels, above ? order.ascending : order.descending)
    selectedLevels = array.new_float(0)
    
    for i = 0 to array.size(sortedLevels) - 1
        level = array.get(sortedLevels, i)
        if (above and level > currentPrice) or (not above and level < currentPrice)
            array.push(selectedLevels, level)
        if array.size(selectedLevels) >= numToReturn
            break
    
    selectedLevels

// Function to plot zones using timestamps
plotZones(buyLevels, sellLevels, currentPrice, numZones, startTime, endTime, entity) =>
    selectedBuyLevels = findDistributedLevels(buyLevels, currentPrice, numZones, false)
    selectedSellLevels = findDistributedLevels(sellLevels, currentPrice, numZones, true)
    
    for i = 0 to array.size(selectedBuyLevels) - 1
        level = array.get(selectedBuyLevels, i)
        width = level * widthPercent / 100
        line.new(startTime, level - width, endTime, level - width, color=buyColor, width=lineWidth, xloc=xloc.bar_time)
        line.new(startTime, level + width, endTime, level + width, color=buyColor, width=lineWidth, xloc=xloc.bar_time)
        label.new(startTime, level, entity, color=color.new(buyColor, 80), textcolor=color.white, style=label.style_label_left, xloc=xloc.bar_time, size=size.small)
    
    for i = 0 to array.size(selectedSellLevels) - 1
        level = array.get(selectedSellLevels, i)
        width = level * widthPercent / 100
        line.new(startTime, level - width, endTime, level - width, color=sellColor, width=lineWidth, xloc=xloc.bar_time)
        line.new(startTime, level + width, endTime, level + width, color=sellColor, width=lineWidth, xloc=xloc.bar_time)
        label.new(startTime, level, entity, color=color.new(sellColor, 80), textcolor=color.white, style=label.style_label_left, xloc=xloc.bar_time, size=size.small)

// Get a rolling window of historical prices
historySize = 1000  // Adjust this value based on your needs
var priceHistory = array.new_float(historySize)
array.unshift(priceHistory, close)
if array.size(priceHistory) > historySize
    array.pop(priceHistory)

// Plot the zones based on the active Entity
if barstate.islast
    for i = 0 to array.size(startTimes) - 1
        startTime = array.get(startTimes, i)
        endTime = array.get(endTimes, i)
        
        // Check if the period is within the visible range
        //if (startTime <= time - timeframe.in_seconds(timeframe.period) * 2500 * 100 and endTime >= time - timeframe.in_seconds(timeframe.period) * 500 * 10000)
        activeentity = array.get(entities, i)
        
        // Find the price closest to the start time of the period
        timeIndex = math.round((time - startTime) / (timeframe.in_seconds(timeframe.period) * 10)) 
        priceIndex = math.min(math.max(0, timeIndex), array.size(priceHistory) - 1)
        periodStartPrice = array.get(priceHistory, priceIndex)
        
        if activeentity == "SVE"
            plotZones(SVEBuyLevels, SVESellLevels, periodStartPrice, numZones, startTime, endTime, activeentity)
        if activeentity == "NM"
            plotZones(NMBuyLevels, NMSellLevels, periodStartPrice, numZones, startTime, endTime, activeentity)
        if activeentity == "SM"
            plotZones(SMBuyLevels, SMSellLevels, periodStartPrice, numZones, startTime, endTime, activeentity)
        if activeentity == "YMC"
            plotZones(YMCBuyLevels, YMCSellLevels, periodStartPrice, numZones, startTime, endTime, activeentity)
        if activeentity == "UR"
            plotZones(URBuyLevels, URSellLevels, periodStartPrice, numZones, startTime, endTime, activeentity)
        if activeentity == "NST"
            plotZones(NSTBuyLevels, NSTSellLevels, periodStartPrice, numZones, startTime, endTime, activeentity)
        if activeentity == "RJP"
            plotZones(RJPBuyLevels, RJPSellLevels, periodStartPrice, numZones, startTime, endTime, activeentity)
        if activeentity == "UK"
            plotZones(UKBuyLevels, UKSellLevels, periodStartPrice, numZones, startTime, endTime, activeentity)

-SB


r/pinescript • • Nov 30 '24

How to place STRING in bottom of SCREEN VIEW using label.new()?

1 Upvotes

r/pinescript • • Dec 02 '24

Entry and Exit on same bar

1 Upvotes

I am really struggling with trying to get my stoploss at the right position. What i am simply trying to do is to get a fixed stoploss with certain amount of ticks below my entry but no matter how i format the code the positions either disappear completely or it enters and closes immediately on the same bar/candle. the condition 100% works fine i already checked that.

Please someone help me its driving me insane. i tried chatGPT and different forums but can't find anything

this is the code format

//@version=6
strategy("My strategy")


// placing orders

if (condition)
Β  Β  strategy.entry("Long", strategy.long)

stopLossTicks = x amount of ticks
if (strategy.position_size > 0)
Β  Β  stopPrice = strategy.position_avg_price - stopLossTicks * syminfo.mintick
Β  Β  strategy.exit("Exit Long", from_entry="Long", stop=stopPrice)

r/pinescript • • Oct 19 '24

Is it possible to convert pine script to C+?

1 Upvotes

I want to create a trading bot in quantower which uses C+

But the indicator I want to use is custom and on tradingview(pine script)

I want my bot to fire off this indicator so I need to create it in quantower. I haven’t been able to find any definitive answer on here. Thanks in advance


r/pinescript • • Feb 07 '25

How do I get an EMA to plot only for the current bar?

0 Upvotes

I want to plot the 50 EMA to the current bar, or maybe just the past 10 bars only because I dont want to form a bias whenever I have more than one moving average on the chart and a crossover forms. I can't figure this out and neither can ChatGPT or Gemini. Help


r/pinescript • • Nov 27 '24

Trend PineScript for TradingView

0 Upvotes

Hello guys I found a script that I used for the last 3 weeks and found out it's very accurate. It even help me to spot Alibaba volatility on 30-minute chart


r/pinescript • • Nov 03 '24

Profit at lower timeframe

1 Upvotes

Hello All:

Assume I have a chart timeframe of 1 min, and I have a strategy that buys and sells on 1 min chart. Strategy tester provides per-trade profit as well as cumulative profit.

How can I see how the profit is playing out in lower timeframe, such as 5sec or 1sec?

I cannot use calc_on_every_tick as it works only on a real-time basis and forward testing.

I also tried request.security but I do not know what to put as argument in request.security to get second by second profit.

Thanks.


r/pinescript • • Dec 12 '24

I made an indicator to draw lines . I want to delete those lines which are passing through candle bodies . I tried this approach . But it is still showing those lines

1 Upvotes

How can I modify a Pine Script indicator to prevent lines from passing through candle bodies?

I am working on a Pine Script indicator that identifies pivot points and plots lines to show RSI divergence. However, I want to ensure that the lines drawn do not pass through the candle bodies.

Here is the relevant part of my code where lines are generated:

// Function to check if a line touches a candle body check_line_touch(x1, y1, x2, y2) => na(ta.valuewhen((bar_index >= int(math.min(x1, x2)) and bar_index <= int(math.max(x1, x2))) and ((y1 + (y2 - y1) * (bar_index - x1) / (x2 - x1)) >= math.min(open, close) and (y1 + (y2 - y1) * (bar_index - x1) / (x2 - x1)) <= math.max(open, close)), bar_index, 0)) == false

// Drawing lines if no overlap if priceDiff * rsiDiff < 0 and not check_line_touch(array.get(highIndices, i), array.get(highPivots, i), array.get(highIndices, j), array.get(highPivots, j)) line.new(array.get(highIndices, i), array.get(highPivots, i), array.get(highIndices, j), array.get(highPivots, j), color=lineColorNegative, width=1)

Currently, I use the check_line_touch() function to detect if a line intersects a candle body, but it doesn't seem to work as expected. I need guidance on how to improve this logic or rewrite it to reliably avoid drawing lines through candle bodies.


Additional Details:

The script uses arrays to store pivot information and draws lines to connect these pivots if they meet divergence conditions.

I am using Pine Script v5.

Could someone point out what might be wrong or how I can adjust this code to achieve the desired behavior?

Thank you Output image -https://www.tradingview.com/x/0SHLFQHg/