1. 首页
  2. 易语言 - EasyLanguage
  3. 保护EasyLanguage代码 Protecting EasyLanguage Code

保护EasyLanguage代码 Protecting EasyLanguage Code

本文详细介绍两种常见的保存 EasyLanguage 代码的方法,以保证代码安全,无法被别人破解。

To send code to another person without them being able to read the code you need to save your EasyLanguage code in some form of secure format.

There are two ways to do this in TradeStation. You can either ‘password protect’ your EasyLanguage files or you can export them as encrypted ‘locked’ files. ‘Password protected’ files have the full EasyLanguage code available, but you need a password to access it. ‘Locked’ files have no readable EasyLanguage code available. They are in pure binary format. Note that the term ‘protected’ is used quite loosely in TradeStation and can mean either ‘password protected’ or ‘locked’.

You can identify ‘password protected’ and ‘locked’ files by their attributes. Those that are ‘password protected’ have the attributes set to ‘P’ and those that are ‘locked’ have their attributes set to ‘L’.
          

‘Locked’ code

To export code as ‘locked’, from the ‘File’ menu, choose ‘Import/Export EasyLanguage…’

Then choose the ‘Export EasyLanguage Documents file (ELD) protected’ option…

It will then go through the options to select the EasyLanguage indicator/strategy you want exported, and the name and location of the file where you want it exported to. You will end up with a file named ‘myname.ELD’ that contains your indicator/strategy.

Note that when you export EasyLanguage code to an ELD (whether it is protected or unprotected) it also exports the functions associated with that code, except if those functions are ‘read-only’. For example, if you exported a simple indicator:

value1 = Average(Close, 10);
condition1 = LastBarOnChart;

Then the exported ELD would, as well as the indicator, contain the LastBarOnChart function (because it is not ‘read-only’), but would not contain the Average function (because it is ‘read-only’). For more information about read-only functions see the Understanding Functions page.

Saving EasyLanguage code as protected (‘locked’), puts it into a binary format, removes all comments from the code and simplifies the variable names (e.g. ‘MyStartDate’ becomes ‘var1’)

‘Password Protected’ code

To password protect code, when you have your code editor window selected, choose ‘View’ and then ‘Protect Document’
          
You will then need to enter a password twice. Then you need to verify the document.

Password protecting EasyLanguage code leaves it in standard EasyLanguage readable format. Nothing is changed, except you now need a password to open the readable code.

Combining protected and unprotected code in one ELD

It is possible to have an ELD that contains both protected and unprotected code. This is useful if you want to send someone a protected file, but don’t want them overwriting ‘standard’ functions, or if you want to send an open indicator/strategy but want the functions protected. To do this you must know all of the functions that your strategy/indicator uses.

To have a protected indicator/strategy with unprotected functions:

  • First, export your strategy/indicator as protected. This creates an ELD where your strategy/indicator as well as all functions are protected. Then, export the functions (but not the strategy/indicator) as unprotected, saving this into the same file as your protected code. When you click ‘Finish’ you will be prompted to ‘Overwrite’ or ‘Append’. Choose ‘Append’ and then ‘Yes’ to overwrite the current functions. The ELD will then contain a protected strategy/indicator and unprotected functions.

To have protected functions with an unprotected indicator/strategy:

  • First, export your strategy/indicator as unprotected. This creates an ELD where your strategy/indicator as well as all functions are unprotected. Then, export the functions (but not the strategy/indicator) as protected, saving this into the same file as your unprotected code. When you click ‘Finish’ you will be prompted to ‘Overwrite’ or ‘Append’. Choose ‘Append’ and then ‘Yes’ to overwrite the current functions. The ELD will then contain an unprotected strategy/indicator and protected functions.

Common Questions

  1. How secure is a ‘protected’ ELD?
    ‘Protected’ ELDs cannot be read by casual observers. However, there are pay services available that will ‘crack’ ELDs and give you the source code.

  2. Can I import the ELD to test it is protected?
    Yes. But you need to be careful because it will overwrite your unprotected code with the protected version. Make sure you rename your unprotected studies first before you import the protected version.

  3. I’ve lost my original code and only have a ‘protected’ ELD left. Can TradeStation get my code back for me?
    TradeStation will not do this. However, there are services available that will ‘crack’ ELDs and give you the source code.

  4. How do I make sure that when I send a protected ELD to someone it doesn’t overwrite their ‘standard’ functions with protected versions?
    TradeStation recommend that you rename the functions used by your protected strategies/indicators so that there won’t be any conflicts. i.e. copy the code in the LastBarOnChart function to a new function called MyLastBarOnChart and then change all references in your code to MyLastBarOnChart. It is also possible to combine protected and unprotected code into one ELD. See above for instructions on doing this.
更新于 2020年5月15日

这篇文章对您有帮助吗?

相关的话题

留言评论