TimeFrame.TryParse
method · TimeFrame · cAlgo.API
DesktopCLICloud
It parses a string and if it matched to a timeframe name it sets it to the passed timeFrame parameter
Definition
public static bool TryParse(string value, TimeFrame& timeFrame)
TimeFrame.TryParse(value: str, timeFrame: TimeFrame) -> bool
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
value | string | str | The timeframe name |
timeFrame | TimeFrame& | TimeFrame | The storage variable for the matching timeframe |
Returns bool — True if a matching timeframe found otherwise False
Examples
if (TimeFrame.TryParse("h1", out var timeFrame))
Print("Parsed time frame: {0}", timeFrame.Name);
else
Print("Unknown time frame name");
success, timeFrame = TimeFrame.TryParse("h1", None)
if success:
api.Print(f"Parsed time frame: {timeFrame.Name}")
else:
api.Print("Unknown time frame name")