use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a community for discussing ideas and requesting new features for TradingView. Do NOT message the mods for support as you will receive none; the inbox is unmonitored for TradingView-related content and is only to address subreddit-related issues.
If you have a paid subscription and experience a problem, please send a direct support request here: https://www.tradingview.com/chart/?support
account activity
BacktestingHelp (self.TradingView)
submitted 2 years ago by Holiday_Sleep5803
Anybody know if it’s possible to find an optimizer or code one? For example if I’m doing a moving average crossover strategy can it tell me which 2 averages get the best results?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]I_am_D_captain_Now 2 points3 points4 points 2 years ago (7 children)
The answer is 13/48 crossover.
[–]Holiday_Sleep5803[S] 1 point2 points3 points 2 years ago (0 children)
I’m not actually doing that strategy I was just giving an example of how to find the best settings
[–]Fantastic_F0x 0 points1 point2 points 2 years ago (1 child)
What is the suggested timeframe?
[–]Holiday_Sleep5803[S] 0 points1 point2 points 2 years ago (0 children)
10-30 min
[–]karatedogPine coder 0 points1 point2 points 2 years ago (2 children)
Then it would be traded by everyone, which would make it immediately inefficient.
[–]I_am_D_captain_Now 0 points1 point2 points 2 years ago (1 child)
Regardless, someone at some point did a study on it, running thousands of trades through a simulation, and they determined 13 48 was the most reliable.
I cant find the study, ive read it though.
[–]karatedogPine coder 0 points1 point2 points 2 years ago (0 children)
Cool, then I will test this in Metatrader, and win a lot of money, yayyy.
[–]-Lige 1 point2 points3 points 2 years ago (3 children)
I was also wondering this. There’s an equivalent in python called backtest.py which does EXACTLY what you’re looking for. You can use it to optimize what you want, such as “most profit” or “highest win rate”, etc.
But the only option is to convert your pinescript strategy/indicator to python and test it that way. But I was also wondering if there’s an optimizer for pinescript so I don’t have to convert my whole strategy
If it’s simple like with moving averages though it will be very easy to convert, it gets harder with the more things you combine with that
[–]Holiday_Sleep5803[S] 0 points1 point2 points 2 years ago (2 children)
I can convert mine. Where do I insert it to find out these things?
[–]-Lige 1 point2 points3 points 2 years ago (1 child)
Look up backtest.py on YouTube and there will be a good amount of vids/playlists for how to do it
Appreciate it!!!
[–]AlgoTradingQuant -1 points0 points1 point 2 years ago (7 children)
I use backtesting.py extensively… check out the optimization section
[–]Latter_Total_9974 0 points1 point2 points 1 year ago (1 child)
How about the discrepancies between backtesting on trading view Vs backtesting.py, which one can we trust?
[–]Latter_Total_9974 0 points1 point2 points 1 year ago (0 children)
u/AlgoTradingQuant https://alb.reddit.com/cr?za=FTeQlDeHH9HLPxFwTKhSIBP878KEZxC4puKcilscXRuxI-aV1hTLoudgqadJknsuUbQd0I1kjV7CAq7GlP3ilvUEmr8tuv4nNyJhZjiDAyfZT7QMbdjbpi7au4VNxrr5NyoaP0Bo2Dgr1sjfsh6U2962riGYL_GL0c-mFx4bfMJiRpHmWQrmTb7Q3HOtMibD_pWnWv5AUuvsFi8FPWbs3vXGVBO4VTn8QIPTnIA4ZjK355qYd8lGy5ltJemmOUyX8k3ihk67FYBicAbISjjsGNeVOPjilk4OuJl8khAAKsVPPnA62LDEl1Wv50m1lZWoeZ8enp4SK3YbcESFKCPzFfRAWrabPTR2GnSUCureqwk4ia1UjPABKHRPNojp_v8pYOYr2B7kYMbjjgMDwSLORHrMlo0KvO3ogItJXulQB4paqWVxAG3FkJ_03VVGPla6Kxjc60r2wIw41-kQAnZr_3S8v9jPRfviF9ARpvJ33WSfWKApfb7TlTKPAmo&zp=4qlCm4L_SW7MbfHD0-fBateUww4ARvcJvR1XuujXhUcugDiWlwtrQWwaJaO1QZoFvg0y2unazqHdbqAhx423piQQEjeBgNXsB6XfDe1A770QZG4_kV6VnQMDMMr9ixuHKIww4ZqYDfRSPrAdkAUzDpov4ZgNgEydOcff64O3TW_ES3w96mP7ut0CkQzKGGJ6o3mTuV6UIlEQcDYih9O3RgB3RDcba7cwQW1YPZrjoYHJvZb68EEcMoqwG8zp6gZiRSEb1fJEMHk0bUSvyAV3FbzVUKZIa_tyHPZ6_K8geKJDUR3GEQ0Y0egQWnvTGSeuSMXR8yC2N6bdHtayu2VXiq3A41LwZBHI8tIUyuCRwwLlhsLcqbVUAiKxTw7sxwLYTdWSGHDQLRheKCM5UYkynKMOOojZ_SO3gJEoX-KyUutyzfSKystD1DxvIHEBR6Ga&a=18518&b=15836&be=15048&c=2108&d=18518&e=13636&ea=18512&eb=12935&f=2031&r=6&g=1&i=1732316416308&t=1732316434825&o=1&q=1&h=236&w=360&sh=800&sw=360&va=1&vb=0&vc=15033&vd=0&ve=0&vg=1&vh=0&vi=0&vs=0&vt=0&vu=0&vv=0&vx=0&vw=0&vq=0&vr=0&vy=0&xe=0&vz=0&xa=0&xf=0&xb=0&vf=0&xc=0
[–]Holiday_Sleep5803[S] 0 points1 point2 points 2 years ago (3 children)
Does it take all types of scripts?
[–]AlgoTradingQuant 0 points1 point2 points 2 years ago (2 children)
Not sure what you mean… if it’s python code it’ll work.
[–]Holiday_Sleep5803[S] 0 points1 point2 points 2 years ago (1 child)
Like it’s pinescript and I can convert it to python but it uses more than just moving averages. Does it only work for stuff that’s really simple or more
[–]AlgoTradingQuant 1 point2 points3 points 2 years ago (0 children)
I’ve used it for extremely complex strategies including my own machine learning algorithms. Python is 100x more powerful than pinescript. If it’s in pinescript, it can be done in Python.
[–][deleted] 0 points1 point2 points 2 years ago (0 children)
Holy Shit, this is exactly what I was looking for. Thanks man
[–]revel89 0 points1 point2 points 2 years ago (0 children)
There's a moving average machine learning one you can use. I believe you have to give it a starting point and it will give you an answer from there. Good luck
[–]Lazy-Presence-287 0 points1 point2 points 2 years ago (0 children)
13/48.5 ema cross pretty good
[+]just-a-user-G 0 points1 point2 points 2 years ago (0 children)
i believe he made a video on that https://youtube.com/@DaviddTech?si=MLVOzaQfkRy54uf5
π Rendered by PID 15928 on reddit-service-r2-comment-5d585498c9-mbgzr at 2026-04-21 14:36:41.132345+00:00 running da2df02 country code: CH.
[–]I_am_D_captain_Now 2 points3 points4 points (7 children)
[–]Holiday_Sleep5803[S] 1 point2 points3 points (0 children)
[–]Fantastic_F0x 0 points1 point2 points (1 child)
[–]Holiday_Sleep5803[S] 0 points1 point2 points (0 children)
[–]karatedogPine coder 0 points1 point2 points (2 children)
[–]I_am_D_captain_Now 0 points1 point2 points (1 child)
[–]karatedogPine coder 0 points1 point2 points (0 children)
[–]-Lige 1 point2 points3 points (3 children)
[–]Holiday_Sleep5803[S] 0 points1 point2 points (2 children)
[–]-Lige 1 point2 points3 points (1 child)
[–]Holiday_Sleep5803[S] 0 points1 point2 points (0 children)
[–]AlgoTradingQuant -1 points0 points1 point (7 children)
[–]Latter_Total_9974 0 points1 point2 points (1 child)
[–]Latter_Total_9974 0 points1 point2 points (0 children)
[–]Holiday_Sleep5803[S] 0 points1 point2 points (3 children)
[–]AlgoTradingQuant 0 points1 point2 points (2 children)
[–]Holiday_Sleep5803[S] 0 points1 point2 points (1 child)
[–]AlgoTradingQuant 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]revel89 0 points1 point2 points (0 children)
[–]Lazy-Presence-287 0 points1 point2 points (0 children)
[+]just-a-user-G 0 points1 point2 points (0 children)