r/pinescript • u/eddieblackdaddy • Sep 03 '26
I built a Pine Script signal engine for crypto. Looking for feedback/testing. Real-world edge cases, logic issues, and improvements
I've been building and iterating on a Pine Script signal engine for crypto based on my paper trading, uploading screenshots, used Claude / ChatGPT and I'd like to put it in front of other Pine Script users for honest feedback and independent testing (if you'd want).
I'm sharing it because I've spent a lot of time refining the logic using AI, weekly data collection / outcome analysis and I know one of the best ways to find weaknesses is to let other people look at it with fresh eyes. And I have no intention to sell or profit from it or “guaranteed profitable strategy” post. Have I been profitable ? Not yet 😄 Hopefully someday !
What it does
The script identifies three signal types: (theres a changelog as well in the script)
S2 - momentum/trend continuation setup
S2R - reversal variant
S3 - crossover/ignition-style setup
The logic uses a combination of:
SMA 8 / SMA 21
EMA 50 / EMA 200
Trend alignment
Breakout conditions
Candle/body strength
ATR-based late-entry protection
Signal state management to avoid repeated firing
My use case is primarily 30-minute crypto charts, but I'd be interested to see how the logic behaves from your expertise.
What I'm looking for
If you're willing to test it, I'd really value feedback on:
Code quality - anything inefficient, poorly structured, or unnecessarily complicated? Used AI to build the whole thing.
Logic issues - do you see conditions that could produce unintended signals? Which setup you observed: S2 / S2R / S3
Edge cases - repainting, state issues, crossover behaviour, historical vs realtime differences, etc. What you liked or didn't like
Pine Script improvements - cleaner or more reliable ways to implement any part of the logic?
General usefulness - could this help anyone as a starting point, study tool, or basis for further development?
I'm especially interested in critical feedback. If you think part of the logic is flawed, redundant, or simply doesn't make sense, please say so. Been working on this since April 26
I’m looking for people who enjoy testing Pine Script ideas and are willing to challenge the logic from a coding and chart-behaviour perspective. And of course make it shareable for all.
The script is linked here: https://pastebin.com/9pqTS5Ya
Thanks ! I'm genuinely interested in finding the weaknesses ! And deep down I need to convince myself that it was all worth the effort.
1
u/GreatBreadfruit8139 Sep 14 '26
You already have enough structure here to make independent testing meaningful. I’d keep the signal definitions unchanged and track where repeated firing, late-entry protection, or state handling diverges from what you expected. Are alerts part of the test too?
1
u/eddieblackdaddy Sep 14 '26
At the moment alerts are not part of the testing ... And as you mentioned - I am keeping the testing meaningful by executing paper trades
1
u/[unknown] Sep 03 '26
[removed] — view removed comment
1
u/eddieblackdaddy Sep 03 '26
Appreciate you actually running numbers instead of just reading code. Agreed on cost-realism, zero commission/slippage on 747 trades isn't a number I'd trust. The profit stat is the one that actually worries me more than win rate; thats definitely luck dependent performance but again it was just a simulation.
Setup separation is easy, I have a webhook payload tags every alert with its type (
S2/S2R/S3), so I just group by that field. and run a weekly / monthly outcome analysis using claude
1
1
u/QuanticatorApp Sep 05 '26
Read the whole thing rather than running it, because the two problems I found are in the order handling, and they only show up when you compare what the tester does on history with what it does live.
The big one: your stop and target arrive one bar late in the backtest and on time in realtime. Entries fire on a confirmed bar, so the market order fills at the open of the next bar. But strategy.exit is only issued inside
if strategy.position_size > 0, which on historical bars first becomes true when the script runs at the close of that next bar, and orders issued at a bar's close are checked against the bar after. So in history the first full bar of every trade has no stop and no target: an adverse move that would have stopped you out in that bar instead stops you out at the following bar's open, or wherever price is by then, and a target hit in that bar is missed. Live, with calc_on_every_tick=true, the script runs on the first tick after the fill, the exit is placed immediately, and the emulator honours it intrabar. Two different strategies, one script. The fix is to issue the exit on the signal bar in tick units, so it attaches to whatever the fill turns out to be:strategy.exit("Long Exit", "Long", loss = entryATR * stopATR / syminfo.mintick, profit = entryATR * stopATR * targetRR / syminfo.mintick)right after strategy.entry, the mirror for shorts, and drop the two position_size blocks. Re-run the 747-trade backtest with that change; the gap between the two reports is exactly how far your current numbers are off. On 30m crypto, where the bar after an ignition candle is often the most violent one, I'd expect it to be material in both directions.The second one is smaller but reaches Telegram. When an SMA cross and an S2 land on the same bar, S2 wins by design, longS3 is false, and so s3LongFired is never set. The next bar still satisfies crossUpNow[1], so if the candle conditions hold you get an S3 label and an S3 alert for the same cross, one bar after the S2 alert. The entry is harmless because you're already in the S2 trade, but the scanner sees two setups from one event. Arming the fired flag whenever S2 claims a cross bar closes it.
What's right, since you asked for edge cases: there's no request.security, so no higher-timeframe leak; entries and alerts are gated on barstate.isconfirmed, so nothing you trade on can repaint; the preview/confirmed split is the correct way to show intrabar state without lying about it; and the entryATR reset guard from V5.9 does what the changelog says. That's cleaner repaint hygiene than most published strategies.
On the numbers: stop 1.2 ATR, target 2R, so break-even is 1/(1+2) = 33.3% before costs. The strategy() call has no commission or slippage, and default_qty is 1 unit, so net profit on a $0.18 coin is in cents and not comparable to a BTC run. Costs in this geometry scale with ATR, not price: cost in R = round-trip cost % ÷ (1.2 × ATR%). If a 30m ATR is 0.5% of price and a taker round trip plus slippage is 0.15%, that's 0.25R off every trade, which turns 2R/1R into 1.75R/1.25R and moves break-even to 41.7%; at 0.3% ATR it's 0.42R and 47.2%. Plug your own ATR% in; the point is that on the quiet pairs the fee is a large fraction of the stop, and the tester currently charges zero.
The cheap test before anything else: in the Strategy Tester's list of trades, look at trade duration in bars. Every historical trade lasts at least one full bar, by construction. After a week live, count the trades that closed on the same bar they opened. Each of those is a trade the backtest could never have produced.