Template Library Parameters
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:

| Variable Name in Strategy Code | Parameter Name Displayed on Strategy Interface | Type | Default Value |
|---|---|---|---|
| param1 | Template Parameter 1 | Number | 99 |
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
param1parameter.javascript$.SetParam1 = function(p1) { param1 = p1 } $.GetParam1 = function() { Log("param1:", param1) return param1 }pythondef 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
param1through the exported functions.javascriptfunction main () { Log("Calling $.GetParam1:", $.GetParam1()) Log("Calling $.SetParam1:", "#FF0000") $.SetParam1(20) Log("Calling $.GetParam1:", $.GetParam1()) }pythondef main(): Log("Calling ext.GetParam1:", ext.GetParam1()) Log("Calling ext.SetParam1:", "#FF0000") ext.SetParam1(20) Log("Calling ext.GetParam1:", ext.GetParam1())