LocalStorage.SetString
method · LocalStorage · cAlgo.API
DesktopCLICloud
Saves a string value to local storage. The storage scope is LocalStorageScope.Instance.
Environment behaviour
Cloud — works differently. Values are kept in memory for the current run only; nothing is saved to or read from disk, and auto-flush is off.
Overloads
| Signature | Description |
|---|---|
SetString(string key, string value) | Saves a string value to local storage. The storage scope is LocalStorageScope.Instance. |
SetString(string key, string value, LocalStorageScope localStorageScope) | Saves a string value to local storage. |
SetString(string key, string value)
Saves a string value to local storage. The storage scope is LocalStorageScope.Instance.
void SetString(string key, string value)
api.LocalStorage.SetString(key: str, value: str) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
key | string | str | The key of the element to add, max length for keys is 50 characters, and only alphanumeric and space characters are allowed, you can only use space in the middle of key not at the start or end |
value | string | str | The value of the element to add |
Examples
LocalStorage.SetString("Last Signal", "Buy EURUSD");
Print("Stored signal: {0}", LocalStorage.GetString("Last Signal"));
api.LocalStorage.SetString("Last Signal", "Buy EURUSD")
api.Print(f"Stored signal: {api.LocalStorage.GetString('Last Signal')}")
SetString(string key, string value, LocalStorageScope localStorageScope)
Saves a string value to local storage.
void SetString(string key, string value, LocalStorageScope localStorageScope)
api.LocalStorage.SetString(key: str, value: str, localStorageScope: LocalStorageScope) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
key | string | str | The key of the element to add, max length for keys is 50 characters, and only alphanumeric and space characters are allowed, you can only use space in the middle of key not at the start or end |
value | string | str | The value of the element to add |
localStorageScope | LocalStorageScope | LocalStorageScope | The storage scope of the element |
Examples
LocalStorage.SetString("Last Signal", "Buy EURUSD", LocalStorageScope.Type);
Print("Shared with all instances: {0}", LocalStorage.GetString("Last Signal", LocalStorageScope.Type));
api.LocalStorage.SetString("Last Signal", "Buy EURUSD", LocalStorageScope.Type)
api.Print(f"Shared with all instances: {api.LocalStorage.GetString('Last Signal', LocalStorageScope.Type)}")