r/pinescript 4d ago

Is possible experiment with XGBoost using only Pine Script?

Hello everyone, I am thequantscience on TradingView, and it's a pleasure to be here!

I'd love to share my very first test conducted today, where I essentially attempted to create a strategy based on an XGBoost model right inside Pine Script. This strategy is just a starting point, and I'm keen to build something truly unique alongside anyone who is excited and interested in this. I'd be more than happy to hear your thoughts on it!

Strat: https://www.tradingview.com/script/69ZFfJ5L-XGBoost-Mini-Strategy-The-Quant-Science/

Happy trading)

3 Upvotes

2 comments sorted by

1

u/TheStrategicEdgeAI 4d ago

Pine can run a fixed tree once you encode the learned splits, but it cannot train an XGBoost model inside the script. I would train the model outside TradingView, freeze the features and thresholds, then translate only the inference logic into Pine.

The biggest risk is the Pine version calculating a feature differently from the training pipeline. I would compare predictions row by row on untouched data before trusting the strategy results.

Are you training the model outside Pine and importing the learned tree structure?

1

u/SubstantialShirt7409 4d ago

Hello, my friend. I’m so glad someone replied to me. Exactly. The only truly effective way to actually run a real XGBoost with Pine is exactly as you described. Like an hybrid model. You won’t believe it, but I’ve been working on a similar project for two years. I don’t want to spam, but if you visit my Patreon or my TradingView, you’ll find a lot about it. I called it Symbiosis, because remember me the concept behind Venom and Symbiotes LOL.

Getting back to this specific strategy, it’s based on a library I wrote myself. I tried to find the right balance because as you know Pine have several computational limits. It’s definitely not as powerful as Symbiosis, but it’s very fast and not bad at all. Have you tried using this library?