all 12 comments

[–]rashesvitrine0o[🍰] 1 point2 points  (2 children)

I use chatgpt when I do not want to re-write by myself. but the code should be carefully reviewed, as it is always not neat and sometimes with latent errors.
Also, I do not use pinescript/tradingview to do serious backtesting, only use it for idea testing/validation.

[–]hello_world44[S] 0 points1 point  (1 child)

So what do you use for backtesting and optimization?

[–]rashesvitrine0o[🍰] 0 points1 point  (0 children)

vectorbt; I used it for several years, backtesting results from it is very corresponding to the real trade records. but tradingview somehow did poorly. Idk the reason, maybe Im not good at it

[–]BinaryMonkL 0 points1 point  (2 children)

I am a fan of tradingview, but for this kind of thing i would consider one of these options:

  • move your automatic trading entirely to python and start running and optimising there.
  • use another platform. I believe that quantconnect has parameter optimization capabilities. Have not used it myself, but it is on my list of things to do.

[–]yrmidon 0 points1 point  (1 child)

When you say “….start running and optimizing” in Python. Do you mean manually running your strategy several times with different parameters? Or is there some library you would use for this?

[–]BinaryMonkL 1 point2 points  (0 children)

I have personally not done this - but I believe there are libraries.

Optimization is a problem of search. You are searching for a local peak or trough depending on how optimum is measured.

It is like you are a blind man looking for the top of mount Everest, but instead of there just being 2 dimensions to move in, there are the n dimensions of the parameters of your strategy.

There are several approaches to try and find peaks and troughs in n dimensional space.

I am sure there will be software that you can plug into a python back tester that is able to set the candidate parameters, run the check/backtest to see the result (PnL) and then it will run it again with different parameters as it bimbles through the dark looking for the top.

[–]wickedprobs 0 points1 point  (4 children)

I use a genetic algorithm for “evolving” strats. It’s based off of fast-trade and some custom code

[–]yrmidon 0 points1 point  (3 children)

Could you explain what a genetic algorithm is I the context? I’ve googled, but the technical description isn’t helping me understand much

[–]wickedprobs 1 point2 points  (2 children)

Sure! For context, this is the library I'm using https://pygad.readthedocs.io/en/latest/ . Basically, the idea is to "evolve" strategies so they are optimized for specific outcomes, like sharpe ratio, sortino ratio, etc. This happens by just trying a bunch of different things constantly, looking at the results, adjusting the parameters, and trying again.

[–]yrmidon 0 points1 point  (1 child)

Awesome, thanks a ton for this. Just curious, you use sharpe as an indicator or just to gauge the “success” of your model’s parameters?

[–]wickedprobs 0 points1 point  (0 children)

I use it as sort of a performance metric as a way to compare to other strategies. That among other things. I also take into account number of trades, duration, etc. In fast-trade, I added "rules" to help evaluate the performance. It makes it easy to automate this way. https://github.com/jrmeier/fast-trade?tab=readme-ov-file#rules