Easy Question And Answer Student Raising Hand

How to protect my pine script code from being copied?

Question

I’m interested in protecting my codes from being copied by TradingView (possibly internally), the brokers offered by TradingView and/or anyone in general.

Student

Answer

I have shared the same concern.

Here’s what I know

Pine Script Admins don’t have access to your code unless you plan to become a vendor. This is outlined in the vendor agreement if you ever find yourself going down that path.

Here’s what Im assuming

Pine Script is not encrypted on the servers, TV doesn’t mention this anywhere and it would increase server resources. That means anyone with server level access can probably see your code if they wanted to. (Probably under 5 people?)

Here’s why I don’t really care about server admins getting access to my scripts

1. There’s millions of scripts. They would have to specifically target me, knowing that I had a great strategy. And it would be pretty hard for them to find out, unless I kept a public portfolio and posted my trading view name. 

2. All this is assuming they care. They’re probably busy on other things. Take me for example. I see tons of strategies from people all the time. Some of them are promising. Some, students/clients claim are making them money. I get excited for them, but I have a strategy of my own that works for me, so I don’t bother myself looking at theirs. I know that kind of sounds nuts, but it’s true. Trading is more about psychology, than the strategy. And I’ve developed my strategy over the years alongside my psychology so it works for me.

Of course, these are reasons why I don’t care about the possibility of server admins seeing my code. But it is still an issue for many. Especially, if the server admin had a conflict of interest. Say they were a vendor as well. They could go and look at a competitors code, maybe even private repositories and then steal it for themselves. Would they do that? I don’t think so, but humans do crazy things sometimes.

A not so simple solution

So protecting your code is a serious issue. There is no simple way to do it with Pine Script unfortunately. 

Your only option is obfuscation. But then this will make it very difficult to work with your code.

So you would need to automate it.

You’d have to create a script in something like python or javascript or whatever language you are comfortable with. Then run your pine script code through and replace all the variables, and function names with hard to read names. You’d have to be careful not to overwrite any builtin names/functions though. Then maybe you could use ‘,’ and put all the code on one line. Think of it as a javacscript/css minifier. 

Summary

TradingView doesn’t encrypt Pine Script on their servers, so you might be worried about someone seeing your valuable information. The risk of someone stealing it is very low, but its still a risk. You can minimize this by using obfuscation. If that’s not good enough for you, then TradingView may not be the place for you.

Leave a Reply