Skip to content

Parse Method

Parse

Summary

It parses a string and if it matched to a timeframe name it returns that time frame otherwise it throws FormatException

Signature

1
public static TimeFrame Parse(string value)

Parameters

Name Type Description
value string Timeframe name

Return Value

TimeFrame

Declaring Type

cAlgo.API.TimeFrame

Examples

1
2
 if (TimeFrame  < TimeFrame.Daily)
     Print("Intraday Trading");
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 using cAlgo.API;
 namespace cAlgo
 {
     // This sample indicator shows how to get a time frame from user via parameters and the get that time frame bars
     // Also you can use the pre-defined time frames
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class TimeFrameSample : Indicator
     {
         // Getting time frame via a parameter from user
         [Parameter("Time Frame", DefaultValue = "Daily")]
         public TimeFrame UserSelectedTimeFrame { get; set; }
         protected override void Initialize()
         {
             Print("Name: ", UserSelectedTimeFrame.Name, " | Short Name: ", UserSelectedTimeFrame.ShortName);
             // Getting another time frame bars data, using user selected time frame
             var barsBasedOnUserSelectedTimeFrame = MarketData.GetBars(UserSelectedTimeFrame);
             // Getting another time frame bars data, using pre-defined TimeFrames
             var barsBasedOnOtherTimeFrame = MarketData.GetBars(TimeFrame.Day2);
         }
         public override void Calculate(int index)
         {
         }
     }
 }

Last update: June 26, 2022

Comments