DeepSeek AI helped me convert the Q‑Trend indicator from TradingView to a ProOrder strategy (ProRealTime). The code compiles and runs, but I’m not a programmer. I would really appreciate it if someone with ProRealTime expertise could review the logic and suggest improvements.
About the strategy
- Based on: Q‑Trend indicator – strong buy / strong sell signals only (open in outer 1/8 of the range over the last 5 bars).
- Timeframes used:
- 10‑minute confirmation (
timeframe(10 minutes, updateonclose)) - 5‑minute confirmation (
timeframe(5 minutes, updateonclose)) - Chart requirement: The strategy must be run on a 1‑minute chart because the code references higher timeframes inside
timeframe() blocks. The base chart resolution must be the lowest timeframe used. - Entry: Only when both the 10‑min and 5‑min timeframes generate a strong buy (or strong sell) signal simultaneously.
- Order accumulation:
DEFPARAM CumulateOrders = true – the strategy can add contracts if multiple signals occur (but a cooldown is applied to prevent excessive stacking). - Exit: Currently exits when the opposite strong signal appears on both timeframes. No stop loss or profit target – pure signal‑based flip.
- Filters included:
- Cooldown – 10 bars between same‑direction entries (
barindex - lastLongBar >= 10). - Zero‑bar exit protection – exits only when
barindex > entryBar (prevents exit on the same bar as entry).
What I’d like help with
- Logic correctness – Does this code correctly replicate the original Q‑Trend strong signals from TradingView?
- Exit strategies – The current exit (opposite strong signal) often exits too late. Are there better exits (e.g., trailing stop, ATR target, or exiting when the trend line changes direction –
changeUp / changeDown)? - Cumulative orders vs. flipping – Should I keep
CumulateOrders = true or switch to false (flip positions) to reduce risk? - Parameter optimisation – Recommended values for
p, atrp, mult, and cooldown when running on a 1‑minute chart with 10/5 min confirmations. - Potential bugs – I sometimes see multiple entries on the same bar even with the cooldown. Is there a cleaner way to prevent this?
The full ProRealTime code is below. Any feedback, improved version, or optimisation advice would be greatly appreciated.
Thank you in advance!
JSParticipant
Veteran
Hi,
The translated version of the Q-Trend indicator can be found in the library:
https://www.prorealcode.com/prorealtime-indicators/q-trend/
Hi, thanks for the reply,
I did looked into that code before, there is lot of difference between these codes, hence started a new thread hoping to improve . Any inputs will be appreciated.
Thanks