Is there a better way to get the timespan of Chart.TimeFrame ?
Created at 27 Jul 2023, 23:55
Is there a better way to get the timespan of Chart.TimeFrame ?
27 Jul 2023, 23:55
Hello,
Is there a better way to get the timespan of Chart.TimeFrame ?
Thanks.
private TimeSpan TimeSpanTimeFrame()
{
if ( Chart.TimeFrame == TimeFrame.Minute ) { return new TimeSpan(0,1,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute2 ) { return new TimeSpan(0,2,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute3 ) { return new TimeSpan(0,3,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute4 ) { return new TimeSpan(0,4,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute5 ) { return new TimeSpan(0,5,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute6 ) { return new TimeSpan(0,6,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute7 ) { return new TimeSpan(0,7,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute8 ) { return new TimeSpan(0,8,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute9 ) { return new TimeSpan(0,9,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute10 ) { return new TimeSpan(0,10,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute15 ) { return new TimeSpan(0,15,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute20 ) { return new TimeSpan(0,20,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute30 ) { return new TimeSpan(0,30,0); }
else if ( Chart.TimeFrame == TimeFrame.Minute45 ) { return new TimeSpan(0,45,0); }
else if ( Chart.TimeFrame == TimeFrame.Hour ) { return new TimeSpan(1,0,0); }
else if ( Chart.TimeFrame == TimeFrame.Hour2 ) { return new TimeSpan(2,0,0); }
else if ( Chart.TimeFrame == TimeFrame.Hour3 ) { return new TimeSpan(3,0,0); }
else if ( Chart.TimeFrame == TimeFrame.Hour4 ) { return new TimeSpan(4,0,0); }
else if ( Chart.TimeFrame == TimeFrame.Hour6 ) { return new TimeSpan(6,0,0); }
else if ( Chart.TimeFrame == TimeFrame.Hour8 ) { return new TimeSpan(8,0,0); }
else if ( Chart.TimeFrame == TimeFrame.Hour12 ) { return new TimeSpan(12,0,0); }
else if ( Chart.TimeFrame == TimeFrame.Daily ) { return new TimeSpan(24,0,0 ); }
else if ( Chart.TimeFrame == TimeFrame.Day2 ) { return new TimeSpan(48,0,0 ); }
else if ( Chart.TimeFrame == TimeFrame.Day3 ) { return new TimeSpan(72,0,0 ); }
else if ( Chart.TimeFrame == TimeFrame.Weekly ) { return new TimeSpan(7,0,0,0,0 ); }
else if ( Chart.TimeFrame == TimeFrame.Monthly ) { return new TimeSpan(30,0,0,0,0); }
else return new TimeSpan(0,0,0);
}
Capt.Z-Fort.Builder
28 Jul 2023, 17:22
Here is a method provided by a fellow (@TheLegitT) in the cTrader official group, though I didn't test, I believe it will work as suppose to be:
@Capt.Z-Fort.Builder