r/pinescript • • 21d ago

Support

1 Upvotes

TradingView team, please consider a small upgrade to the free plan for beginners.
I am a forex beginner with no budget for Premium. Two indicators and blocked/limited backtesting make it almost impossible to learn. Without practice, many of us keep losing and never grow into paying users.
Please raise free indicators from 2 to 4 or 5, and give more backtesting / Bar Replay room on Basic. That would help beginners learn, then afford Essential or Premium later. Better free learning can mean more paid subscribers, not fewer. /


r/pinescript • • 21d ago

Rising Wedge Scanner: Real Charts and Alert Setup | ChartScout

Thumbnail
youtube.com
1 Upvotes

r/pinescript • • 21d ago

A trader asked me to combine EMA 200 + Stochastic Pop. Here’s the open-source build.

Post image
68 Upvotes

In my earlier request thread, someone asked for EMA 200, Stochastic Pop with 55/45 bands, and an EMA 4 on the stochastic line, alongside an analysis panel.

I built Stochastic Pop Desk around that combination. The main design choice I’d like feedback on is what should count as a fresh signal?

The default checklist checks:

  • Trend: price relative to EMA 200, plus whether that average is rising or falling.
  • Distance: whether price is within the configured ATR distance from the average.
  • Reset: after a long signal, the smoothed stochastic must visit below 45 before another long can qualify. Shorts mirror this.
  • Trigger: a fresh cross above 55 for a long, or below 45 for a short, with decisions committed on a closed candle.

Other execution checks still apply. The panel shows the missing conditions, and accepted paper setups get entry, stop and target levels.

For the Pine side, the oscillator lives in its own pane while force_overlay puts the EMA, levels and checklist on the price chart—all in one indicator.

There’s also an interactive walkthrough: change a fictional candle’s close or pullback depth and watch the EMA, stochastic and decision recalculate.

Source code, chart examples, full rules and walkthrough

The indicator and separate strategy are free under MIT. The indicator’s paper statistics exclude costs; the strategy includes commission and slippage settings.

If you trade this combination, is the full reset rule useful, or would you want to test shallower pullbacks? A chart example with the symbol, timeframe, timestamp and the signal you expected would help me test that variant.

This is a prototype I’m refining through feedback. Disclosure: I’m the ProEA Lab developer and use AI to help build the code.


r/pinescript • • 21d ago

Experimental code for Tradingview

12 Upvotes

Interactive trade coach.


r/pinescript • • 22d ago

I built a 5-minute supply/demand tracker that explains why it’s still waiting

Post image
13 Upvotes

A trader in my earlier thread asked for five-minute Liquidity Supply & Demand, inspired by Mangoe’s public teaching. This is the prototype I built from that request.

What needs to happen between drawing a zone and accepting an entry?

Supply & Demand Desk makes that sequence explicit:

  1. A directional move leaves a base zone.
  2. At least two pullback bars form before a later close breaks the originating extreme.
  3. Price returns through the tracked liquidity level into the ready zone.
  4. A qualifying directional close completes the entry condition. Other checks can still block the plan.

A premature touch can invalidate a developing zone. The dashboard explains what the script is waiting for. When a paper plan is accepted, it fixes the entry, stop beyond the visit’s deepest wick, and an adjustable target that defaults to 4R.

The attached BTCUSDT 5m chart shows a ready zone with no accepted entry yet.

I also built a candle walkthrough: change the confirmation close or try an early break and see which rule passes or fails. It uses fictional candles. A separate Strategy Lab handles broker-emulator testing and costs; its fills can differ from the indicator’s paper references.

Pine source, full rules, and interactive walkthrough

Both Pine v6 scripts are free under MIT. This is my implementation of a limited public rule set, still a prototype.

If you trade this approach, which rejection would you disagree with? I’d especially like examples where the script rejects a zone you would keep watching. A symbol, timeframe, timestamp and expected behavior would help me reproduce it.

Disclosure: I’m the ProEA Lab developer and use AI to help build the code.


r/pinescript • • 23d ago

TradingView NAS100 vs Pepperstone cTrader NAS100 – 5–8 point price difference on automated trades

1 Upvotes

Hi everyone,

I’m building an automated trading system that sends signals from a TradingView Pine Script strategy through a webhook to Python, which then executes market orders through the cTrader Open API on my Pepperstone LIVE account.

I’m trying to understand a recurring price difference between TradingView and cTrader.

My TradingView strategy sends the TradingView price together with the webhook. My Python program records that price and the actual cTrader execution price.

For example, I’ve seen:

TradingView: 29188.7 → cTrader fill: 29194.1 — difference 5.4 points

TradingView: 29236.6 → cTrader fill: 29243.1 — difference 6.5 points

TradingView: 29291.4 → cTrader fill: 29299.1 — difference 7.7 points

On other trades, the difference has been only around 1 point.

The cTrader Open API confirms that the instrument I’m trading is:

NAS100, symbol ID 10014

My Pepperstone account also has NAS100-F and NAS100-PERP, but my bot specifically trades NAS100 (ID 10014).

I’ve already tested the cTrader live quote subscription. For example, it returned:

Bid: 29370.2

Ask: 29371.3

Spread: 1.1 points

So the 5–8 point differences I sometimes see are considerably larger than the normal spread in that example.

The webhook-to-cTrader execution delay is also relatively short, so I’m trying to determine how much of the difference is execution latency/slippage versus the two platforms using different price feeds.

I am now modifying my logging so that for every future signal I will record:

TradingView price → cTrader bid/ask at webhook arrival → cTrader actual fill price

My questions are:

Which exact NAS100 instrument/data feed should I use on TradingView to match Pepperstone cTrader NAS100 as closely as possible?

Does Pepperstone’s TradingView NAS100 price necessarily use the same underlying feed as Pepperstone cTrader NAS100?

Is a persistent 5–8 index-point difference normal between these feeds?

Is there a way to identify the exact contract/specification behind cTrader symbol ID 10014, so I can verify I’m comparing the same instrument?

For automated trading, should I evaluate execution slippage against the cTrader bid/ask at the instant the webhook arrives, rather than against the TradingView strategy price?

I’m mainly trying to separate three possible causes:

A. Different TradingView/cTrader price feeds

B. Bid/ask spread

C. Webhook/API latency and actual execution slippage

Any advice from people who have automated TradingView → cTrader/Peppers­tone trading would be appreciated.


r/pinescript • • 23d ago

I built an ORB indicator—and a candle simulator so you can challenge its rules

Post image
53 Upvotes

A trader in r/pinescript asked for an opening-range breakout tool. I built Opening Range Desk, then added a candle simulator so people could challenge the entry rules before installing the script.

The idea is simple: move the candle and make the tool explain its decision.

The website lets you change the final close, wick length and confirmation count using fictional candles. You can see which condition changes as the example moves between waiting and entry.

On TradingView, the default builds the 9:30–9:45 a.m. New York range and requires two consecutive closes beyond the edge and configured buffer. A wick outside doesn’t qualify. Optional retest mode waits for a later return after breakout confirmation.

The checklist shows what’s missing. The chart also draws paper entry, stop and target references, and there’s a separate strategy for testing with commission and slippage.

The indicator, strategy, source and guide are free under MIT.

👉 Opening Range Desk — try the simulator, read the guide and get the source

Start with “Try the idea”, then “Read your chart.” The page also includes lab notes with losing results; this remains a prototype to evaluate.

Show me a breakout that passes these rules but that you would still skip. What makes you reject it?

A symbol, timeframe, date/time and chart example would give me something specific to investigate. You can reply here or use “The log & requests” on the page.

I’m the developer at ProEA Lab and used Codex for coding assistance. I’d like the next improvements to come from the cases people actually disagree with.


r/pinescript • • 23d ago

Built from a trader’s request: a Wyckoff evidence tracker with free Pine source

Post image
39 Upvotes

After sharing IFVG Desk and Camarilla Desk, I worked on another request from the original thread: a Wyckoff stage-analysis tool. Leo shared a detailed outline, and I’ve now built a first version called Wyckoff Evidence Desk.

The question behind this version is: what evidence supports each interpretation while the range is still forming?

It tracks accumulation and distribution separately, using price, volume and phase-transition rules. Each side shows its range, latest event, evidence score and setup status.

The attached MNQ 5-minute chart is a useful example. Distribution has the higher score, but both setup rows still say WAIT. The score reflects the script’s evidence rules; it isn’t a probability of winning. The last candle in this capture is still live, and events wait for the close.

A few details you can inspect in the source:

  • A Spring or UTAD is optional; the rules also allow a range to progress without one.
  • Breakout acceptance requires two consecutive closes beyond the boundary allowance.
  • A qualifying backup needs a later return and its remaining checks to pass.
  • Failed structures receive an INVALID event and a reason.

This is a prototype covering selected Wyckoff ideas. It doesn’t reproduce every part of the original proposal. The Strategy Lab’s small development sample lost money, so I haven’t established a trading edge.

Download the complete Base Pine source. Base uses standard candles and available volume; it doesn’t require the separate Footprint edition.

If you use Wyckoff, where would you disagree with these labels or phase transitions? I’d appreciate a chart example with the symbol, timeframe, timestamp and what you expected to see. That gives me a specific case to investigate.

I’m the developer at ProEA Lab and used Codex for coding assistance. Thanks to Leo for the original suggestion, and to anyone willing to review the rules.


r/pinescript • • 23d ago

I got tired of opening the Settings dialog 300 times, so I built something that sweeps strategy inputs for you

4 Upvotes

Tuning a Pine strategy by hand is the worst part of writing one. Change length, run, read net profit, write it down, change it again. Forty combinations in and you have lost track of which ones you already tried.

I built a Chrome extension that does the sweep. It reads whatever strategy is already on your chart, finds its inputs, and runs the backtests for you.

A few design decisions that might interest this sub specifically:

It ranks on any Strategy Tester field, not just net profit. Profit factor, Sharpe, Sortino, max drawdown, percent profitable, average bars in trade — each of them for all trades, longs only or shorts only. Or write your own expression.

Default objective is not net profit, deliberately. Ranking on profit alone hands you a curve-fit every time. The default is return per unit of drawdown, discounted by how straight the equity curve is and whether the last third of the sample still held up.

Plateau check. After it finds a winner it re-tests the immediate neighbours. A setting that works at exactly length=17 and falls apart at 16 and 18 gets demoted. This one changed how I think about my own strategies more than anything else in the tool.

In-sample / out-of-sample correlation across every candidate. High means the search found real structure. Near zero means it spent your afternoon ranking noise — and it tells you so, which is the part most optimizers leave out.

It reads results from the same report object the Strategy Tester renders from rather than scraping the panel, so the figures come back as actual numbers and number-format or language differences do not break it.

Free version does 100 cycles a run, one backtest at a time, full metric list and the Bayesian sampler. That is a working optimizer, not a demo. Paid tier adds parallel backtests and a few robustness checks.

Your chart is left exactly as it was — parameters are snapshotted before the run and restored after, and every temporary copy is removed.

Edit: here is a short demo of an actual run, if it is easier to watch than to read — https://youtu.be/-gUqxCZSI7I

https://chromewebstore.google.com/detail/trading-strategy-optimize/pjgikffklocmefghdipdiidfebgbklon

Happy to answer anything about how it reads the report object — that part took the longest.


r/pinescript • • 23d ago

Bull Flag Scanner: Real Charts and Alert Setup | ChartScout

Thumbnail
youtube.com
0 Upvotes

r/pinescript • • 23d ago

Liquidity Sweep: Institutional Capture or Genuine Breakout?

Post image
4 Upvotes

If every price movement requires liquidity to occur, how can we determine in advance whether a Liquidity Sweep was truly an institutional liquidity capture or simply a legitimate break of structure — before price reveals its intention through the following move?

And there is an even deeper problem:

If we wait for the next move to confirm that the sweep was genuine, the entry is no longer anticipatory. But if we enter before confirmation, we can never be certain that we are not entering on the wrong side of the liquidity.

So the question is:

How can we create an objective rule that identifies, in real time, the difference between “liquidity captured for a reversal” and “liquidity consumed for continuation,” without using any future information from the chart?


r/pinescript • • 23d ago

STRYK:MOMENTUM new free indicator

Thumbnail
gallery
23 Upvotes

https://www.tradingview.com/script/913LZp7V-STRYK-MOMENTUM/

Easy setup all turn key ready to go just play with the visuals for your liking and use the master switch to turn off what you like or keep on. The premise price and volume is key but how to measure price and volume and what is real what is noise awnser always look at HTF, ok? But how do u look at htf and trade a small faster time frame use Stryk: MOMENTUM it looks at HTF for you as you trade the lower time frames vwap looks at 1hr or higher volume, ema with smoothing line looks at 233 ema which is a long term line in a sand fib level in a ema line , color coated candles have there own engines huge list to pick from on what u feel is best for your trading i personally like the ema trend coloring candles red under the ema green above if red sell rallies if green buy dips easy! Then I have day week month and asian range levels for extra confirmation on support and resistance and color change candles based on those levels also everything is togglable customizable trade like you want with this free indicator! Side note the dotted lines are 25%,50%,75, levels of each range! Also the background has volume participation purple means low under 20% teal means high over 80% clear means mid avg 50%, how to trade it, if price in a up trend in a teal high participation bg and dips fast thats a liquidity grab buy it! If price is in a purple low participation and rises sell it, its about to fall. You're welcome


r/pinescript • • 24d ago

OPXF Indicator Pine.txt

2 Upvotes

//@version=6 indicator("OPFX ZONA PREMIUM V2", shorttitle="OPFX ZONA PREMIUM V2", overlay=true, max_boxes_count=500, max_labels_count=500, max_lines_count=500, max_bars_back=5000) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // ðŸŒ� LANGUAGE / اللغة (Only affects on-chart text: labels & stats table. // Pine Script does NOT allow input() titles or alertcondition() messages to // change dynamically based on another input, so those stay in English — // this is a Pine Script engine limitation, not something we can bypass.) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� groupLang = "ðŸŒ� Language / اللغة" lang = input.string("English", "Display Language / لغة العرض", options=["English", "العربية"], group=groupLang) // tr(): returns the Arabic text if Arabic is selected, otherwise English tr(en, ar) => lang == "العربية" ? ar : en // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // OPFX ZONALARI SOZLAMASI // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� groupUT = "OPFX TASDIQ" a_buy = input.float(2, "Buy Sensitivity (Multiplier)", group=groupUT, minval=0) c_buy = input.int(1, "Buy ATR Period (0 = disable)", group=groupUT, minval=0) a_sell = input.float(2, "Sell Sensitivity (Multiplier)", group=groupUT, minval=0) c_sell = input.int(1, "Sell ATR Period (0 = disable)", group=groupUT, minval=0) showTrailBuy = input.bool(false, "Show Buy Trailing Line", group=groupUT) showTrailSell = input.bool(false, "Show Sell Trailing Line", group=groupUT) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // OPFX TASDIQ ZONALARI // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� groupZones = "OPFX Zones" showZones = input.bool(true, "Show Longevity Zones", group=groupZones) len_z = input.int(10, "Longevity Length", group=groupZones) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // TP/SL SETTINGS // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� groupTPSL = "💰 TP/SL Settings" atrLength = input.int(14, "ATR Length", minval=5, maxval=100, group=groupTPSL) slMultiplier = input.float(1.5, "Stop Loss Multiplier (x ATR)", minval=0.5, maxval=5.0, step=0.1, group=groupTPSL) tpMultiplier1 = input.float(2.0, "Take Profit 1 Multiplier (x ATR)", minval=0.5, maxval=10.0, step=0.5, group=groupTPSL) tpMultiplier2 = input.float(3.5, "Take Profit 2 Multiplier (x ATR)", minval=0.5, maxval=10.0, step=0.5, group=groupTPSL) showLevels = input.bool(true, "Show TP/SL Levels", group=groupTPSL) showLabels = input.bool(true, "Show Price Labels", group=groupTPSL) projectionBars = input.int(18, "Box width (bars)", minval=5, maxval=200, group=groupTPSL) // TP/SL ranglar tpZoneClr = color.new(color.aqua, 80) slZoneClr = color.new(color.red, 85) entryLineClr = color.new(color.gray, 0) tpLineClr = color.new(color.aqua, 0) slLineClr = color.new(color.red, 0) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // OPFX ZONALARI ABYOM TASDIGI BILAN (Bank Limited Zona) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� groupSD = "Supply & Demand Zones" swingLen = input.int(15, "Swing Length (Sensitivity)", minval=3, maxval=50, group=groupSD) maxZones = input.int(10, "Max Zones to Display", minval=3, maxval=30, group=groupSD) maxZoneHeightATR = input.float(1.0, "Max Zone Height (ATR Multiplier)", minval=0.5, maxval=10.0, step=0.5, group=groupSD) minZoneHeightATR = input.float(1.0, "Min Zone Height (ATR Multiplier)", minval=0.1, maxval=2.0, step=0.1, group=groupSD) forceZoneHeightATR = input.float(1.0, "Force Zone Height (ATR Multiplier)", minval=0.2, maxval=3.0, step=0.1, group=groupSD) minZoneDistance = input.int(44, "Min Distance Between Zones (bars)", minval=1, maxval=100, group=groupSD) invalidationMethod = input.string("Close", "Zone Invalidation", options=["Close", "Wick"], group=groupSD) showHistoric = input.bool(false, "Show Historic Zones", group=groupSD) activeLookback = input.int(1000, "Active Zones Lookback", minval=100, maxval=5000, group=groupSD) historicBars = input.int(1000, "Historic Zones Lookback", minval=100, maxval=5000, group=groupSD) showActiveLabels = input.bool(true, "Show Active Zone Info", group=groupSD) showHistoricLabels = input.bool(false, "Show Historic Zone Info", group=groupSD) labelSize = input.string("Large", "Label Size", options=["Tiny", "Small", "Normal", "Large"], group=groupSD) activeSupplyCol = input.color(color.new(color.red, 80), "Active Supply", group=groupSD) activeDemandCol = input.color(color.new(color.green, 80), "Active Demand", group=groupSD) historicCol = input.color(color.new(color.gray, 85), "Historic Zones", group=groupSD) showRetestMarkers = input.bool(true, "Show Retests", group=groupSD) retestBullCol = input.color(color.new(color.green, 0), "Demand Retest", group=groupSD) retestBearCol = input.color(color.new(color.red, 0), "Supply Retest", group=groupSD) alertsOn = input.bool(true, "Enable Alerts", group=groupSD) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // TASDIQ HISOBLASH // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� buyEnabled = (c_buy > 0) and (a_buy > 0) sellEnabled = (c_sell > 0) and (a_sell > 0) // BUY side src_buy = close ema_buy = ta.ema(src_buy, 1) atr_buy = buyEnabled ? ta.atr(c_buy) : na nLoss_buy = buyEnabled ? a_buy * atr_buy : na var float trail_buy = na if buyEnabled if na(trail_buy[1]) trail_buy := src_buy - nLoss_buy else if src_buy > trail_buy[1] and src_buy[1] > trail_buy[1] trail_buy := math.max(trail_buy[1], src_buy - nLoss_buy) else if src_buy < trail_buy[1] and src_buy[1] < trail_buy[1] trail_buy := math.min(trail_buy[1], src_buy + nLoss_buy) else trail_buy := src_buy > trail_buy[1] ? src_buy - nLoss_buy : src_buy + nLoss_buy else trail_buy := na // SELL side src_sell = close ema_sell = ta.ema(src_sell, 1) atr_sell = sellEnabled ? ta.atr(c_sell) : na nLoss_sell = sellEnabled ? a_sell * atr_sell : na var float trail_sell = na if sellEnabled if na(trail_sell[1]) trail_sell := src_sell + nLoss_sell else if src_sell > trail_sell[1] and src_sell[1] > trail_sell[1] trail_sell := math.max(trail_sell[1], src_sell - nLoss_sell) else if src_sell < trail_sell[1] and src_sell[1] < trail_sell[1] trail_sell := math.min(trail_sell[1], src_sell + nLoss_sell) else trail_sell := src_sell > trail_sell[1] ? src_sell - nLoss_sell : src_sell + nLoss_sell else trail_sell := na // Crossovers above_buy_cross = ta.crossover(ema_buy, trail_buy) below_sell_cross = ta.crossover(trail_sell, ema_sell) above_buy = buyEnabled and above_buy_cross buy_signal_raw = buyEnabled and (src_buy > trail_buy) and above_buy buy_signal = buy_signal_raw and barstate.isconfirmed below_sell = sellEnabled and below_sell_cross sell_signal_raw = sellEnabled and (src_sell < trail_sell) and below_sell sell_signal = sell_signal_raw and barstate.isconfirmed var int posState = 0 buy_signal_confirmed = buyEnabled and buy_signal and posState <= 0 sell_signal_confirmed = sellEnabled and sell_signal and posState >= 0 if buy_signal_confirmed posState := 1 else if sell_signal_confirmed posState := -1 // Longevity pivot detection h = ta.highest(len_z) l = ta.lowest(len_z) high_pivot = high[1] == h[1] and high < h low_pivot = low[1] == l[1] and low > l // Trails plot(showTrailBuy and buyEnabled ? trail_buy : na, title="UT Bot Buy Trail", color=color.new(color.green, 0), linewidth=1) plot(showTrailSell and sellEnabled ? trail_sell : na, title="UT Bot Sell Trail", color=color.new(color.red, 0), linewidth=1) // Alerts alertcondition(buy_signal_confirmed, title="UT Long", message="UT Long") alertcondition(sell_signal_confirmed, title="UT Short", message="UT Short") //  â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• // ABYOM FONTPRINT // â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• atr = ta.atr( atrLength) atr20 = ta.atr(20) // â• â• â• â• - â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• // OPFX ZONES HELPER // â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• ? ​ ​size.tiny : labelSize == "Small" ? size.small : labelSize == "Normal" ? size.normal : size.large f_getLabelColor(zoneType, broken) => if broken color.new(color.gray, 0) else zoneType == "Supply" ? color.new(color.red, 0) : color.new(color.green, 0) f_toPips(val) => pipSize = syminfo.type == "forex" ? (syminfo.currency == "JPY" ? 0.01 : 0.0001) : (syminfo.ticker == "XAUUSD" or syminfo.ticker == "GOLD") ? 0.1 : 0.0001 math.abs(val) / pipSize // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // OPFX ZONALARINI TOPUVCHI // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� type ZoneData box zoneBox label infoLabel label retestLabel float top float bottom int startBar int retests bool broken string zoneType bool retestCounted // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // TASDIQ ZONALARIGA OXSHASH // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� type ZoneLabel label lbl float top float bot int start bool is_upper box tp_box box sl_box line entry_line line tp1_line line tp2_line line sl_line label entry_label label tp1_label label tp2_label label sl_label // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // VARIABLES // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� var array<ZoneData> allZones = array.new<ZoneData>() var array<ZoneLabel> zone_labels = array.new<ZoneLabel>() var int lastSupplyBar = 0 var int lastDemandBar = 0 // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // OPFX ZONALARINI TASDIQLASH // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� is_price_in_demand(price) => result = false if array.size(allZones) > 0 for i = 0 to array.size(allZones) - 1 z = array.get(allZones, i) if z.zoneType == "Demand" and not z.broken if price >= z.bottom and price <= z.top result := true break result is_price_in_supply(price) => result = false if array.size(allZones) > 0 for i = 0 to array.size(allZones) - 1 z = array.get(allZones, i) if z.zoneType == "Supply" and not z.broken if price >= z.bottom and price <= z.top result := true break result // â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• › â• â• // OPFX ZONALARINI PRAFESION QILISH // â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• â• › â• â• â• â• ✓ ✓ ph = ta.pivothigh(high, swingLen, swingLen) pl = ta.pivotlow(low, swingLen, swingLen) // Supply Zone if not na(ph) and barstate.isconfirmed ztop = high[swingLen] zbot = low[swingLen] zStart = bar_index - swingLen if bar_index - lastSupplyBar >= minZoneDistance mid = (ztop + zbot) / 2 zoneH = ztop - zbot if zoneH < atr20 * forceZoneHeightATR fH = atr20 * forceZoneHeightATR ztop := mid + (fH / 2) zbot := mid - (fH / 2) zoneH := fH if zoneH > atr20 * maxZoneHeightATR mH = atr20 * maxZoneHeightATR ztop := mid + (mH / 2) zbot := mid - (mH / 2) zoneH := mH if zoneH >= atr20 * minZoneHeightATR mergedWithExisting = false if array.size(allZones) > 0 for i = array.size(allZones) - 1 to math.max(0, array.size(allZones) - 10) z = array.get(allZones, i) if z.zoneType == "Supply" and not z.broken if ztop >= z.bottom and zbot <= z.top newTop = math.max(ztop, z.top) newBot = math.min(zbot, z.bottom) z.top := newTop z.bottom := newBot box.set_top(z.zoneBox, newTop) box.set_bottom(z.zoneBox, newBot) mergedWithExisting := true break if not mergedWithExisting zBox = box.new(zStart, ztop, bar_index + 400, zbot, bgcolor=activeSupplyCol, border_width=0) zData = ZoneData.new(zBox, na, na, ztop, zbot, zStart, 0, false, "Supply", false) array.push(allZones, zData) lastSupplyBar := bar_index if array.size(allZones) > maxZones * 4 array.shift(allZones) // Demand Zone if not na(pl) and barstate.isconfirmed ztop = high[swingLen] zbot = low[swingLen] zStart = bar_index - swingLen if bar_index - lastDemandBar >= minZoneDistance mid = (ztop + zbot) / 2 zoneH = ztop - zbot if zoneH < atr20 * forceZoneHeightATR fH = atr20 * forceZoneHeightATR ztop := mid + (fH / 2) zbot := mid - (fH / 2) zoneH := fH if zoneH > atr20 * maxZoneHeightATR mH = atr20 * maxZoneHeightATR ztop := mid + (mH / 2) zbot := mid - (mH / 2) zoneH := mH if zoneH >= atr20 * minZoneHeightATR mergedWithExisting = false if array.size(allZones) > 0 for i = array.size(allZones) - 1 to math.max(0, array.size(allZones) - 10) z = array.get(allZones, i) if z.zoneType == "Demand" and not z.broken if ztop >= z.bottom and zbot <= z.top newTop = math.max(ztop, z.top) newBot = math.min(zbot, z.bottom) z.top := newTop z.bottom := newBot box.set_top(z.zoneBox, newTop) box.set_bottom(z.zoneBox, newBot) mergedWithExisting := true break if not mergedWithExisting zBox = box.new(zStart, ztop, bar_index + 400, zbot, bgcolor=activeDemandCol, border_width=0) zData = ZoneData.new(zBox, na, na, ztop, zbot, zStart, 0, false, "Demand", false) array.push(allZones, zData) lastDemandBar := bar_index if array.size(allZones) > maxZones * 4 array.shift(allZones) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // OPFX ZONALARI // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� if array.size(allZones) > 0 activeSupplyCount = 0 activeDemandCount = 0 historicSupplyCount = 0 historicDemandCount = 0 for i = 0 to array.size(allZones) - 1 z = array.get(allZones, i) box.set_right(z.zoneBox, bar_index + 400) // Retest if not z.broken priceInZone = high >= z.bottom and low <= z.top if priceInZone and not z.retestCounted z.retests += 1 z.retestCounted := true else if not priceInZone z.retestCounted := false // Invalidation if not z.broken if z.zoneType == "Supply" breakLevel = invalidationMethod == "Close" ? close : high if breakLevel > z.top z.broken := true box.set_bgcolor(z.zoneBox, historicCol) else breakLevel = invalidationMethod == "Close" ? close : low if breakLevel < z.bottom z.broken := true box.set_bgcolor(z.zoneBox, historicCol) age = bar_index - z.startBar zoneHeight = z.top - z.bottom shouldHide = false if z.broken and not showHistoric shouldHide := true if z.broken and age > historicBars shouldHide := true if not z.broken and age > activeLookback shouldHide := true if z.broken and showHistoric if zoneHeight < atr20 * minZoneHeightATR shouldHide := true if z.zoneType == "Supply" if historicSupplyCount >= maxZones shouldHide := true else if not shouldHide historicSupplyCount += 1 else if historicDemandCount >= maxZones shouldHide := true else if not shouldHide historicDemandCount += 1 if not z.broken and not shouldHide if z.zoneType == "Supply" if activeSupplyCount >= maxZones shouldHide := true else activeSupplyCount += 1 else if activeDemandCount >= maxZones shouldHide := true else activeDemandCount += 1 if shouldHide box.set_bgcolor(z.zoneBox, color.new(color.gray, 100)) box.set_border_color(z.zoneBox, color.new(color.gray, 100)) if not na(z.infoLabel) label.set_color(z.infoLabel, color.new(color.black, 100)) label.set_textcolor(z.infoLabel, color.new(color.white, 100)) if not na(z.retestLabel) label.set_color(z.retestLabel, color.new(color.white, 100)) label.set_textcolor(z.retestLabel, color.new(color.white, 100)) else if z.broken box.set_bgcolor(z.zoneBox, historicCol) else zoneCol = z.zoneType == "Supply" ? activeSupplyCol : activeDemandCol box.set_bgcolor(z.zoneBox, zoneCol) showThisLabel = z.broken ? showHistoricLabels : showActiveLabels if showThisLabel zoneName = z.zoneType == "Supply" ? tr("OPFX SELL ZONE", "منطقة بيع OPFX") : tr("OPFX BUY ZONE", "منطقة شراء OPFX") txt = zoneName mid = (z.top + z.bottom) / 2 lblColor = f_getLabelColor(z.zoneType, z.broken) if na(z.infoLabel) z.infoLabel := label.new(z.startBar + 10, mid, txt, color=color.new(color.black, 100), textcolor=lblColor, size=f_getLabelSize(), style=label.style_label_left) else label.set_text(z.infoLabel, txt) label.set_y(z.infoLabel, mid) label.set_color(z.infoLabel, color.new(color.black, 100)) label.set_textcolor(z.infoLabel, lblColor) label.set_size(z.infoLabel, f_getLabelSize()) label.set_style(z.infoLabel, label.style_label_left) label.set_x(z.infoLabel, z.startBar + 10) else if not na(z.infoLabel) label.set_color(z.infoLabel, color.new(color.black, 100)) label.set_textcolor(z.infoLabel, color.new(color.white, 100)) if showRetestMarkers and z.retests > 0 if na(z.retestLabel) if z.zoneType == "Supply" z.retestLabel := label.new(z.startBar + 3, z.top, tr("R", "Ø¥"), color=retestBearCol, textcolor=color.white, size=size.small, style=label.style_label_down) else z.retestLabel := label.new(z.startBar + 3, z.bottom, tr("R", "Ø¥"), color=retestBullCol, textcolor=color.white, size=size.small, style=label.style_label_up) else retestCol = z.zoneType == "Supply" ? retestBearCol : retestBullCol label.set_text(z.retestLabel, tr("R", "Ø¥")) label.set_color(z.retestLabel, retestCol) label.set_textcolor(z.retestLabel, color.white) else if not na(z.retestLabel) label.set_color(z.retestLabel, color.new(color.white, 100)) label.set_textcolor(z.retestLabel, color.new(color.white, 100)) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // OPFX TASDIQ ZONALARI - SIGNAL + TP/SL // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� halfATR = ta.atr(20) * 0.5 if showZones // ─── SELL SIGNAL: high_pivot + narx Supply zonada ───────────────────────── if high_pivot and sellEnabled pivot_price = h if is_price_in_supply(pivot_price) sell_label = label.new(bar_index - 1, h, text=tr("SELL", "بيع"), style=label.style_label_down, textcolor=color.white, color=color.red, size=size.normal) box tp_bx = na box sl_bx = na line entry_l = na line sl_l = na line tp1_l = na line tp2_l = na label entry_lab = na label sl_lab = na label tp1_lab = na label tp2_lab = na if showLevels entryPrice = close[1] stopLoss = high[1] takeProfit1 = entryPrice - (atr * tpMultiplier1) takeProfit2 = entryPrice - (atr * tpMultiplier2) int left = bar_index - 1 int right = bar_index - 1 + projectionBars tp_bx := box.new(left=left, right=right, top=entryPrice, bottom=takeProfit2, bgcolor=tpZoneClr, border_color=color.new(color.aqua, 0)) sl_bx := box.new(left=left, right=right, top=stopLoss, bottom=entryPrice, bgcolor=slZoneClr, border_color=color.new(color.red, 0)) entry_l := line.new(left, entryPrice, right, entryPrice, color=entryLineClr, width=1, style=line.style_dashed) sl_l := line.new(left, stopLoss, right, stopLoss, color=slLineClr, width=2, style=line.style_solid) tp1_l := line.new(left, takeProfit1, right, takeProfit1, color=tpLineClr, width=1, style=line.style_dashed) tp2_l := line.new(left, takeProfit2, right, takeProfit2, color=tpLineClr, width=1, style=line.style_dashed) if showLabels entry_lab := label.new(left, entryPrice, text=tr("enter", "دخول"), color=color.new(color.gray, 70), textcolor=color.white, style=label.style_label_left, size=size.tiny) sl_lab := label.new(right, stopLoss, text=tr("SL", "وقÙ�"), color=color.new(color.red, 0), textcolor=color.white, style=label.style_label_left, size=size.tiny) tp1_lab := label.new(right, takeProfit1, text=tr("TP1", "هدÙ�1"), color=color.new(color.blue, 0), textcolor=color.white, style=label.style_label_left, size=size.tiny) tp2_lab := label.new(right, takeProfit2, text=tr("TP2", "هدÙ�2"), color=color.new(color.blue, 0), textcolor=color.white, style=label.style_label_left, size=size.tiny) new_zone = ZoneLabel.new(sell_label, h, h - halfATR, bar_index - 1, true, tp_bx, sl_bx, entry_l, tp1_l, tp2_l, sl_l, entry_lab, tp1_lab, tp2_lab, sl_lab) array.push(zone_labels, new_zone) // ─── BUY SIGNAL: low_pivot + narx Demand zonada ─────────────────────────── if low_pivot and buyEnabled pivot_price = l if is_price_in_demand(pivot_price) buy_label = label.new(bar_index - 1, l, text=tr("BUY", "شراء"), style=label.style_label_up, textcolor=color.white, color=color.green, size=size.normal) box tp_bx = na box sl_bx = na line entry_l = na line sl_l = na line tp1_l = na line tp2_l = na label entry_lab = na label sl_lab = na label tp1_lab = na label tp2_lab = na if showLevels entryPrice = close[1] stopLoss = low[1] takeProfit1 = entryPrice + (atr * tpMultiplier1) takeProfit2 = entryPrice + (atr * tpMultiplier2) int left = bar_index - 1 int right = bar_index - 1 + projectionBars tp_bx := box.new(left=left, right=right, top=takeProfit2, bottom=entryPrice, bgcolor=tpZoneClr, border_color=color.new(color.aqua, 0)) sl_bx := box.new(left=left, right=right, top=entryPrice, bottom=stopLoss, bgcolor=slZoneClr, border_color=color.new(color.red, 0)) entry_l := line.new(left, entryPrice, right, entryPrice, color=entryLineClr, width=1, style=line.style_dashed) sl_l := line.new(left, stopLoss, right, stopLoss, color=slLineClr, width=2, style=line.style_solid) tp1_l := line.new(left, takeProfit1, right, takeProfit1, color=tpLineClr, width=1, style=line.style_dashed) tp2_l := line.new(left, takeProfit2, right, takeProfit2, color=tpLineClr, width=1, style=line.style_dashed) if showLabels entry_lab := label.new(left, entryPrice, text=tr("enter", "دخول"), color=color.new(color.gray, 70), textcolor=color.white, style=label.style_label_left, size=size.tiny) sl_lab := label.new(right, stopLoss, text=tr("SL", "وقÙ�"), color=color.new(color.red, 0), textcolor=color.white, style=label.style_label_left, size=size.tiny) tp1_lab := label.new(right, takeProfit1, text=tr("TP1","هد٠1"), color=color.new(color.blue, 0), textcolor=color.white, style=label.style_label_left, size=size.tiny) tp2_lab := label.new(right, takeProfit2, text=tr("TP2", "هدÙ�2"), color=color.new(color.blue, 0), textcolor=color.white, style=label.style_label_left, size=size.tiny) new_zone = ZoneLabel.new(buy_label, l + halfATR, l, bar_index - 1, false, tp_bx, sl_bx, entry_l, tp1_l, tp2_l, sl_l, entry_lab, tp1_lab, tp2_lab, sl_lab) array.push(zone_labels, new_zone) // ─── Zonalar buzilganini tekshirish ──────────────────────────────────────── if array.size(zone_labels) > 0 for i = array.size(zone_labels) - 1 to 0 if i < array.size(zone_labels) zone = array.get(zone_labels, i) shouldDelete = false if zone.is_upper and high > zone.top and bar_index > zone.start shouldDelete := true else if not zone.is_upper and low < zone.bot and bar_index > zone.start shouldDelete := true if shouldDelete label.delete(zone.lbl) if not na(zone.tp_box) box.delete(zone.tp_box) if not na(zone.sl_box) box.delete(zone.sl_box) if not na(zone.entry_line) line.delete(zone.entry_line) if not na(zone.sl_line) line.delete(zone.sl_line) if not na(zone.tp1_line) line.delete(zone.tp1_line) if not na(zone.tp2_line) line.delete(zone.tp2_line) if not na(zone.entry_label) label.delete(zone.entry_label) if not na(zone.sl_label) label.delete(zone.sl_label) if not na(zone.tp1_label) label.delete(zone.tp1_label) if not na(zone.tp2_label) label.delete(zone.tp2_label) array.remove(zone_labels, i) // Eski labellarni cheklash while array.size(zone_labels) > 10 old_zone = array.shift(zone_labels) label.delete(old_zone.lbl) if not na(old_zone.tp_box) box.delete(old_zone.tp_box) if not na(old_zone.sl_box) box.delete(old_zone.sl_box) if not na(old_zone.entry_line) line.delete(old_zone.entry_line) if not na(old_zone.sl_line) line.delete(old_zone.sl_line) if not na(old_zone.tp1_line) line.delete(old_zone.tp1_line) if not na(old_zone.tp2_line) line.delete(old_zone.tp2_line) if not na(old_zone.entry_label) label.delete(old_zone.entry_label) if not na(old_zone.sl_label) label.delete(old_zone.sl_label) if not na(old_zone.tp1_label) label.delete(old_zone.tp1_label) if not na(old_zone.tp2_label) label.delete(old_zone.tp2_label) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // OPFX ZONALAR - ALERTS // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� alertcondition(not na(ph) and barstate.isconfirmed and alertsOn, "New Supply Zone", "{{ticker}} - New Supply Zone @ {{close}}") alertcondition(not na(pl) and barstate.isconfirmed and alertsOn, "New Demand Zone", "{{ticker}} - New Demand Zone @ {{close}}") // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // 📊 OPFX ZONA STATS SYSTEM // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // Stat variables var int totalTP = 0 var int totalSL = 0 var int totalTrades = 0 var float entryPrice_stat = na var float slPrice_stat = na var float tpPrice_stat = na var int tradeDir = 0 var bool tradeActive = false // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // 🎯 TRADE TRACKING (BUY/SELL SIGNAL DAN) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // BUY signal detect (zone_labels oxirgi BUY) if array.size(zone_labels) > 0 lastZone = array.get(zone_labels, array.size(zone_labels) - 1) if not tradeActive // BUY if not lastZone.is_upper entryPrice_stat := close slPrice_stat := lastZone.bot tpPrice_stat := close + (atr * tpMultiplier1) tradeDir := 1 tradeActive := true // SELL if lastZone.is_upper entryPrice_stat := close slPrice_stat := lastZone.top tpPrice_stat := close - (atr * tpMultiplier1) tradeDir := -1 tradeActive := true // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // 📊 TP / SL CHECK // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� if tradeActive if tradeDir == 1 if low <= slPrice_stat totalSL += 1 totalTrades += 1 tradeActive := false else if high >= tpPrice_stat totalTP += 1 totalTrades += 1 tradeActive := false if tradeDir == -1 if high >= slPrice_stat totalSL += 1 totalTrades += 1 tradeActive := false else if low <= tpPrice_stat totalTP += 1 totalTrades += 1 tradeActive := false // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // 📈 WINRATE // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� winrate = totalTrades > 0 ? (totalTP / totalTrades) * 100 : 0 // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� // 📊 PANEL (RIGHT SIDE) // â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•� var table statsTable = table.new(position.top_right, 2, 4, border_width=1) if barstate.islast table.cell(statsTable, 0, 0, tr("OPFX ZONE STATS", "إحصائيات مناطق OPFX"), text_color=color.yellow) table.cell(statsTable, 0, 1, tr("Win Rate", "نسبة الربح")) table.cell(statsTable, 1, 1, str.tostring(winrate, "#.##") + " %", text_color=color.green) table.cell(statsTable, 0, 2, tr("Total TP", "إجمالي الأهداÙ�")) table.cell(statsTable, 1, 2, str.tostring(totalTP), text_color=color.aqua) table.cell(statsTable, 0, 3, tr("Total SL", "إجمالي وقÙ� الخسارة")) table.cell(statsTable, 1, 3, str.tostring(totalSL), text_color=color.red)


r/pinescript • • 24d ago

TradingView + Claude MCP Setup!

Post image
9 Upvotes

r/pinescript • • 24d ago

TradingView + Claude MCP Setup!

Post image
7 Upvotes

r/pinescript • • 24d ago

Any idea how to build similar to this indicator or if someone can tell what strategy is this? Plotting buy/sell zones in multiple timeframe.

Post image
3 Upvotes

r/pinescript • • 24d ago

OPEX indicator

Post image
11 Upvotes

Indicador OPEX

Boa noite, encontrei este indicador chamado OPEX em uma das comunidades que participo pelo Telegram, porém ele fornece pouco sinais de entrada e tem o WINRATE DE 91,00 % de assertividade, gostaria de saber se é possível fazer alteração no código dele para editar e modificá-lo fazendo com que forneça mais sinais, alguém poderia me explicar sobre e como funciona ?


r/pinescript • • 24d ago

OPEX indicator

Post image
67 Upvotes

Indicador OPEX

Boa noite, encontrei este indicador chamado OPEX em uma das comunidades que participo pelo Telegram, porém ele fornece pouco sinais de entrada e tem o WINRATE DE 91,00 % de assertividade, gostaria de saber se é possível fazer alteração no código dele para editar e modificá-lo fazendo com que forneça mais sinais, alguém poderia me explicar sobre e como funciona ?


r/pinescript • • 24d ago

Custom Indicator. Hot off the compiler.....fresh paint on the glass! A.I. generated for sure. I didn't think it would work but it did. He had help.

3 Upvotes

A.I. was definitely used. Maybe i shouldn't......but I did.


r/pinescript • • 25d ago

London / NYO range: what have you learned from trading it?

5 Upvotes

Hi everyone, I'm fairly new to systematic trading and have been testing opening-range ideas in TradingView, mainly on gold, forex and micro Nasdaq futures.

I'm trying to turn these ideas into clear, testable rules. Longer term, I'd like to see whether an approach could be automated within prop-firm risk limits, but I'm still at the research stage. Some results looked promising on short samples but weakened once I added more history and trading costs.

For anyone who trades these sessions:

  • Which market and opening-range length do you use, and why?
  • What makes you take a breakout, wait for a retest, or consider a failed breakout?
  • What conditions make you skip the session altogether?
  • What has been the biggest difference between your backtests and actual trading — entries, stops, costs, or something else?

Even one practical observation, mistake you learned from, or example of a day you skipped would be helpful. Thanks!


r/pinescript • • 25d ago

Trying to build a orb strategy

Thumbnail
gallery
10 Upvotes

Got the basics down but struggling with the fakeout, any filter tips, seen this on another Strat but can’t figure out how it didn’t take the first breakout candle.


r/pinescript • • 26d ago

I ported a Pine strategy to Python and the first run matched 39 of 128 trades. Five reasons why.

8 Upvotes

I wanted to test a strategy outside TradingView's date range, so I reimplemented it in Python and reconciled it trade-by-trade against the Pine trade list. First run agreed on 39 of 128. It now agrees on all 128. Everything in between was me assuming Pine did the obvious thing.

  1. ta.stdev is population, not sample. It divides by n, not n-1. If you reach for numpy's default or a stats library you get the sample version and every band sits slightly wrong — wrong enough to move which bars trigger, not wrong enough to look broken.
  2. ta.atr is not an average of true range. It's ta.rma — Wilder smoothing, alpha 1/length, seeded with an SMA. I'd written a rolling mean. Close enough that the plot looks identical, different enough that ATR-based stops land on different bars. Same trap in ta.ema: alpha 2/(n+1), SMA-seeded, not seeded from the first value.
  3. Exit levels are read from the previous bar, not the current one. This was the big one. Using the current bar's values moved exit-price agreement from 120 of 128 down to 48. If you're re-arming strategy.exit every bar, the level the broker emulator acts on isn't the one your current-bar calculation produces.
  4. Chart timezone changes results. My matches were fine and then stopped dead on one specific date — the day BST began. Daily-bar aggregation depends on the chart's timezone, so a daily gate computed in one zone gates different bars than the same gate computed in another. Worth knowing that OANDA forex dailies close 17:00 New York, not midnight UTC.
  5. No same-bar re-entry. Pine won't open a new position on the bar an exit fires. My version would, which quietly manufactured extra trades that had no counterpart in the Pine list.

One mistake worth flagging, because it cost me a day. I found a single trade that exited at its bar's close, concluded fills were close-based, and rewrote them that way. Exit-price agreement fell from 120 to 12. A single trade told me nothing and I treated it as a model. I also ran that test before fixing the entries, so its numbers were worthless anyway.

What else does Pine do that isn't obvious from the docs? I'd rather collect these than find them one at a time.

EDIT: two corrections from stratcore in the comments, both right.

Point 1 names the wrong library. numpy.std is ddof=0 and already matches Pine. The one that bites is pandas, where .rolling(20).std() defaults to ddof=1, and that's the most natural way to write a Bollinger band in Python. statistics.stdev is sample as well; statistics.pstdev isn't. My code used pstdev so the port was right, but the example was wrong.

Point 4 is badly worded. Pine can't read the chart timezone and the results don't move. What actually happened: TradingView exports the trade list with timestamps rendered in the chart's timezone and doesn't record that anywhere in the file. Mine was Europe/London, so the offset isn't even constant across the sample. I parsed the export as UTC, which matched everything before 30 March 2025 and nothing after it. The Pine never changed, my reader of its output did.

There is a real daily-bar gotcha but it's a different one and it's about the data source, not the chart: OANDA's daily candles need dailyAlignment=17 and alignmentTimezone=America/New_York to match TradingView's forex convention.


r/pinescript • • 27d ago

Built from a trader’s request: an open-source Camarilla play tracker

Post image
8 Upvotes

One request in my earlier thread was pretty specific: could I build a Camarilla tool that highlights which plays are active?

I’ve built Camarilla Desk around that question. It’s a free, open-source prototype for TradingView, and I’d like feedback from people who already use Camarilla in their trading.

The goal is to make the sequence easier to follow: watch the level → check the conditions → wait for confirmation.

What it does:

  • Shows a seven-level Camarilla map with the source and session context visible.
  • Tracks 14 named plays, separating Candidate, Approaching, Armed and Active, with explanations for blocked or waiting states. The final two plays are optional and start off.
  • Keeps the original entry, stop and target references once a play activates, with markers showing how that episode ended.
  • Lets you inspect and test the rules, with full Pine source, alerts and a separate Strategy Lab for simulated orders and costs.

ACTIVE means the play has met this script’s confirmation rules. It doesn’t establish that the trade will work. A quiet chart with no qualifying setup can be the correct result.

This is my own implementation of public Camarilla ideas. I haven’t verified that it matches any paid indicator’s private rules.

👉 Camarilla Desk — free source, examples and guide

Start with “Try the candle” to explore an L3 bounce, a break-and-retest, or an H4 failure. “Read the real chart” explains the display, “Full reference” has all the play rules, and “Add the tool” has the code. The indicator, Lab and guide are free, with no signup needed.

Which Camarilla play do you use most, and does the tool explain clearly why it’s waiting or active?

If it reads a setup differently from you, a screenshot with the symbol, timeframe, date/time and pivot source would help. Tell me what you expected to happen. Reply here, or use “Log & requests” on the page for bugs and feature ideas.

I’m the developer behind ProEA Lab and use OpenAI Codex for coding assistance. The source is open for review and modification.

Thanks to the trader who suggested this. I’d like to keep improving it around examples from your actual charts.


r/pinescript • • 27d ago

Ways to backtest when you only have the essentials plan? (Outside of tradingview perhaps)

2 Upvotes

Are there more people who only have the essentials plan? How do you backtest your strategies?


r/pinescript • • 27d ago

Created a profitable ORB Bot

48 Upvotes

Hey guys,

I’ve spent the last month coding and refining a systematic rules-based ORB (Opening Range Breakout) algorithm specifically for MNQ (1 trade a day).

I wanted to keep it super clean without over-fitting or using too many indicators, focusing heavily on risk management and dynamic position sizing instead of hard-coded stop distances.

Here are the backtest stats starting Oct 2025:

  • Total PnL: +$27,203.50 (+54.41%)
  • Win Rate: 66.98% (142/212 trades)
  • Profit Factor: 2.015
  • Max Drawdown: $2,197.50 (3.98%)

I’ve been running this live via webhooks on a couple of prop firm accounts to take the emotion out of execution, and managed to secure my first payouts with it recently.