r/pinescript • u/CalinTheMeme • Nov 01 '26
Trades are very random
So i asked ChatGPT to write me a code and it took a lot of time trying to get it right because it kept making mistakes. Now i have a problem it cant fix for some reason and that is that the trades being taken are either tiny(ranging from one candle to the next) or just simply do not look like my strategy at all. If anyone is bothered enough to read the code ask and i will paste it under your comment.
I attached an example(my strategy is break and retest on 15 min for structure and 5 min for entry, stop loss just before the retest with 1:2 risk to reward, risking 1% per trade only). The first trade taken was a valid break and retest but the next is just a random one.
Also i can only see about 18-24 trades per pair because im using free tradingview so is there any way i can extend past 5000 bars or increase number of trades?
I would really greatly appreciate some help because im really horrible at coding and honestly cant be asked to learn it for this one thing.


2
u/CalinTheMeme Nov 01 '26
nevermind i realised its not random still a kind of valid break and retest but still i wouldn't have taken that trade how can i minimise these small losses affecting winrate
1
u/Th3onib Nov 02 '26
Good luck
1
u/wallneradam Nov 02 '26
If ChatGPT keeps breaking the code while you do this, we're building PyneIDE, a VS Code extension (still in preview) that gives the AI the current Pine v6 docs and lets you stop on a trade's bar (with its full featured debugger) to see why it entered.
1
u/TSDevStuff Nov 02 '26
Two things usually cause exactly this with ChatGPT-written break and retest code:
high[1]with lookahead_on is the usual pattern) so the backtest only knows what you'd have known live.For the trades you wouldn't have taken, turn the reason into a rule, e.g. the level needs at least 2 touches before it counts. And with ~20 trades per pair, run it on a handful of pairs before trusting the numbers, one bad trade swings everything at that sample size.