Referencing the selected timeframe in code
Forums › ProRealTime English forum › ProBuilder support › Referencing the selected timeframe in code
- This topic has 4 replies, 3 voices, and was last updated 2 years ago by robertogozzi.
Tagged: default, gettimeframe, tf, timeframe
-
-
11/15/2021 at 2:15 PM #181628
I don’t think there is, but is there a way to reference the selected timeframe (default timeframe) so that it can be referred to in hard code?
this isn’t logical code its to portray the logic.
Hope that makes sense.. I did submit it to PRT as a suggestion…. Can’t see an obvious reference to it anywhere but still looking… Cheers
12345678910111213141516171819202122232425262728If timeframe (default)=(3 mins) thentimeframe (3 mins)"hard code"Timeframe (15 mins)"hard code"timeframe (hourly)"hard code"endifIf timeframe (default)=(15 mins)thentimeframe (15 mins)"hard code"Timeframe (1 hour)"hard code"timeframe (4 hours)"hard code"If timeframe (default)=(1 hour) thentimeframe (1 hour)"hard code"Timeframe (8 hour)"hard code"timeframe (daily)"hard code"endiftimeframe (default)return "my selection"11/15/2021 at 3:21 PM #181629I’m currently coding variables for gettimeframe with different called indicators as a possible way around it, but haven’t finished that yet,think it may be feasible, just wondering if there is a snippet of code I don’t know about.. I’m optimistic about the called version
11/18/2021 at 8:25 AM #181767Ok, it wasn’t particualarly logical how PRT allows that to me but it’s sorted now, easy when you know how… reference the “named fields” in the call lines…
08/21/2022 at 9:54 AM #199323Hi. I’ve got exactly the same problem, but can’t figure out a solution. Any chance you could post a code snippet to show how you solved it. Thanks
08/21/2022 at 10:36 AM #199326This is an indicator to display the current TF on the chart. Its purpose is to show how to detect the current default TF:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465/* GetTimeFramereturns the number of seconds in the selected Timeframe:60 = 1 minute300 = 5 minutes3600 = 1 hour14400 = 4 hours86400 = 1 day (24 hours)604800 = 1 week (7 days)2592000 = 1 month (30 days)31536000 = 1 year (365 days)-1 = default TF (or non time-based TF)this indicator returns two values (commented out as it plots text)TF = 0 secondsTF = 1 minutesTF = 2 hoursTF = 3 daysTF = 4 weeksTF = 5 monthsTF = 6 yearsN = number of units*/DEFPARAM DrawOnlastBarOnly = trueShiftText = 1Rge = high + averagetruerange[2](close) / 0.4 / ShiftText / 1//x = GetTimeFrameIF (x MOD 60) <> 0 THENTF = 0 //TF = secondsN = x //N = number of secondsDRAWTEXT("#N# Sec", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)ELSEIF x >= 31536000 THENTF = 6 //TF = yearsN = floor(x / 31536000,0) //N = number of yearsDRAWTEXT("#N# Yrs", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)ELSIF x >= 2592000 THENTF = 5 //TF = monthsN = floor(x / 2592000,0) //N = number of monthsDRAWTEXT("#N# Mth", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)ELSIF x >= 604800 THENTF = 4 //TF = weeksN = floor(x / 604800,0) //N = number of weeksDRAWTEXT("#N# wks", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)ELSIF x >= 86400 THENTF = 3 //TF = daysN = floor(x / 86400,0) //N = number of daysDRAWTEXT("#N# Day", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)ELSIF x >= 3600 THENTF = 2 //TF = hoursN = floor(x / 3600,0) //N = number of hoursDRAWTEXT("#N# hrs", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)ELSETF = 1 //TF = minutesN = floor(x / 60,0) //N = number of minutesDRAWTEXT("#N# Min", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)ENDIFENDIFRETURN// TF AS "TF",N AS "Units"1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on