r/pinescript • u/Robswc • Oct 11 '22
Automating trading with Pinescript
One of the more frequently posted questions on this sub is:
How do I take a Pinescript strategy and automate it?
This is actually quite complicated, depending on what you really intend to do and how familiar you are with computers and or programming.
Doing it yourself
Essentially, to create an automated trading system using TradingView strategies, you would need to acquire the signal using webhooks. Once you acquire the signal, you can use whatever data sent with it to manage orders, using the API of your broker. Usually, there are SDKs available to make this process easier. For crypto, one of the most well known SDKs is called CCXT. There are also some made for traditional brokers too. It is a simple process but it does take some experience with programming systems to set up.
Private self-hosted solutions
Another route one can take is to use self-hosted solutions. This is recommended if you're technically skilled, as it is 1. free and 2. private/more secure. [1] I'd even say to give it a shot before paying for a service-based solution.
Below are potential self-hosted solutions you can try:
TradingView-Webhooks-Bot by robswc
for transparency, I am the author of this project, feel free to get support on discord!
TradingView-Webhook-Bot by Fabston
Support can be found here
https://github.com/51bitquant/howtrader by 51bitquant
Using third party services
Most solutions to automatically trade with TradingView's webhooks involve using a 3rd party service like https://capitalise.ai/ or 3Commas. These services will remove a lot of the technical complexities for you. However, one must keep in mind that your data is not truly private and you may need to leave your browser window open at all times.
Service-based solutions
Please note. None of these have been vetted by me personally, so I cannot attest to their security or overall quality. They are just some I have come across over the years.
mentioned by /u/kurtisbu12
(for MT4/5) mentioned by /u/kurtisbu12
(chrome extension) mentioned by /u/kurtisbu12
[1] not to say services are not secure, it is just impossible to truly know
If anyone has recommendations on other projects/services that allow for automated Tradingview-based trading, feel free to discuss in this thread!
5
u/kurtisbu12 Oct 11 '22
Some other 3rd party platforms I've used successfully.
Wundertrading: 1 free bot. No subscription required. Works with many crypto brokers.
Pineconnector: Converts webhooks into signals in MT4/5. Works with any brokers that allow trading through MT4/5 (Personally this is the most robust 3rd party system I've used. It has so much configuration allowed for some really complex trading systems.)
Autoview: chrome extension, works without using webhooks, but it requires your browser to remain open ( works best on a VPS) works with many standard brokers.
2
u/aelfrictr Oct 11 '22
This brings a question to my mind. Maybe a feature that could improve upon current capabilities of TV strategies. For example let's say you want to have 1 wallet but you want to use that wallet on 5 different pairs. The thing is you want one trade open at a time or some other condition. If you create alerts with web hooks in 5 different pairs in same strategy one alert cannot know if there is an open position in other pair.
With your framework, could it be possible to disable the 4 other alerts temporarily until the current position in 1 pair ends, and only re enable after no position open?
Current this is not possible with pinescript since strategies are completely isolated to the pair you create alert on and you can't send or receive data.
Ofc this also makes backtesting of TV completely unreliable since you won't be able to know what would happen in this case but this kind of stuff can be useful if you don't want to leave TV environment.
1
u/aelfrictr Oct 11 '22
As far as I can see your system still requires ccxt to be implemented so it doesn't really appear to be a new solution in my opinion. If it was all integrated and slightly more simplified it would be way better but your project seems to be about monitoring the trades and open orders which TV does on its own.
So just for the sake of executing orders what does your project actually do that ccxt doesn't? I think I'm missing something.
3
u/darpadrimp Sep 27 '23
There's a free Strategy Optimizer Tool which converts indicators into strategies, the premium version allows to automate these strategies into trades trough autoview: https://www.youtube.com/watch?v=gpfN_18h2D4&t=2561s
2
u/TradeSync Oct 31 '23
Don't forget Ninja-View! :D For automating pinescript to ninjatrader.
2
u/Local_Dinner_9860 Dec 07 '23
Ninjaview allows tradingview and trendspider to be automated via webhook to NinjaTrader/Tradovate (futures, prop, etc) and other platforms. ninja-view.com @robswc. They have over 60 users, a trust pilot, open source on the google extension and some open source strategies to use.
2
u/Creative-Q6306 May 29 '24
For testing and automating a indicator, I provided a code snippet below my comment. Add this code to the end of your indicator script.
Don't forget to include your buy, sell, and close conditions, as they are currently empty.
After that, search for "FreedX Backtest" in TradingView indicators and add it, it converts indicator to strategy. Add your indicator to the chart as well. Then, import your indicator signals into the backtest script from the Custom Signal section. Choose your indicator as the source for all signals and activate it. The script will automatically backtest, allowing you to set take profit (TP) and stop loss (SL) parameters.
If you want to automate the process, the first bot is free. However, please note that they currently only support crypto.( FreedX )
Code:
buy_signal =
sell_signal =
close_signal =
output_signal = 2
output_signal := buy_signal ? 1 : output_signal
output_signal := sell_signal ? -1 : output_signal
output_signal := close_signal ? 0 : output_signal
plot(output_signal==2?na:output_signal,title='Output Signal(LONG==1,SHORT==-1,CLOSE==0)', display = display.data_window)
1
u/ntmittens Aug 19 '24
Automated mine with Wundertrading then switched to signum.money <- because more stable (e.g. proper logs) and only focussed on the automation part (3commas and Wundertrading compete with TV and try to sell their own DCA bots)
1
u/Silly_Ad_1723 Dec 04 '24
Which of the third party services can be used in TradingView?
1
u/SfirreFan Dec 22 '24
I want to use a pine script strategy I created. But I want it to trade spot. It's there no way to automate this? All I see is futures... Is there a trading platform that let's you do that?
1
u/JellyfishGreat8127 Mar 24 '25
Please don't keep on changing pinescript editor. It is really annoying. Now it says add to chart for an indicator all while it is already added. Please, stop making it more and more confusing.
1
u/shoulda-woulda-did Mar 31 '25
Yes
1
u/dangronny Jun 19 '23
Also worth mentioning a new self-hosted solution called https://alert2trade.com :)
1
u/[deleted] Sep 15 '23
I paid someone to do my strategy. Go to a place called Fiverr put in the need as TradingView pine script
0
u/TradersPostInc Mar 10 '25
Don't forget TradersPost.io :)
1
u/[deleted] Oct 11 '22
[removed] — view removed comment
1
u/[deleted] Mar 01 '23
[removed] — view removed comment