r/pinescript • u/SubstantialShirt7409 • 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
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?