Type/to search
Getting Started
Platform Basics
Writing Strategies
Strategy Structure
Programming Languages
Strategy Parameters
Interactive Controls
Strategy Frontend
Template Library
Export Functions of Template Libraries
Template Library Parameters
Reference Template Library
Built-in Libraries
UI Text Localization
API Quick Reference
Development Tools
Backtesting System
Advanced Topics
Data and Research
Extended API Interface

Template libraries can also set their own interface parameters. Template library parameters are used as global variables in the template library code (global constants in Rust). For example, a template library with this parameter:

Template Parameter

Variable Name in Strategy CodeParameter Name Displayed on Strategy InterfaceTypeDefault Value
param1Template Parameter 1Number99

In the examples below the template exports functions that read and modify the parameter, and the strategy calls them. Parameters of a Rust template are constants that can only be read, not modified, so in Rust the parameter can only be read:

rust
// template code pub fn GetParam1() -> f64 { Log!("param1:", param1); param1 }
rust
// strategy code fn main() { Log!("Calling ext::GetParam1:", ext::GetParam1()); }

Examples

  • Template library code: export functions that read and modify the param1 parameter.

    javascript
    $.SetParam1 = function(p1) { param1 = p1 } $.GetParam1 = function() { Log("param1:", param1) return param1 }
    python
    def SetParam1(p1): global param1 param1 = p1 def GetParam1(): Log("param1:", param1) return param1 ext.SetParam1 = SetParam1 ext.GetParam1 = GetParam1
  • Strategy code that references the template above: read and modify param1 through the exported functions.

    javascript
    function main () { Log("Calling $.GetParam1:", $.GetParam1()) Log("Calling $.SetParam1:", "#FF0000") $.SetParam1(20) Log("Calling $.GetParam1:", $.GetParam1()) }
    python
    def main(): Log("Calling ext.GetParam1:", ext.GetParam1()) Log("Calling ext.SetParam1:", "#FF0000") ext.SetParam1(20) Log("Calling ext.GetParam1:", ext.GetParam1())