TIMEFRAME magnitude precedence?
Forums › ProRealTime English forum › ProBuilder support › TIMEFRAME magnitude precedence?
- This topic has 3 replies, 3 voices, and was last updated 3 years ago by essuu.
-
-
03/20/2021 at 4:02 PM #164756
Hello, this is my first posting here so please accept my apologies in advance if I accidentally fluff up any of the forum’s procedures. I’m not sure if this is something “everybody already knows”, or an “undocumented feature”, or just my own dumb coding failure.
I cobbled together some code to test an idea. The idea involves comparing the status of an indicator across two different timeframes, in this case the 15 minute and the 1 hour timeframes. The indicator I’m aiming for would display in the 15 minute timeframe window, so checking that the 15 minute status matches the containing 1 hour status.
Anyway, the code I wrote looks (something) like this:
123456789TIMEFRAME(15 minutes, updateonclose)result15 = somerandomoperation()TIMEFRAME(1 hour, updateonclose)result60 = somerandomoperation()IF result15 > result60 THENDRAWARROWUP(barindex, Close - 8) COLOURED(0,255,10)ENDIFThis seems to work.. except it only puts the up arrow on the first bar of the hour where the condition matches even if the conditions are met on other bars in the same hour. If I reverse the order of the timeframes to look like this:
12345678TIMEFRAME(1 hour, updateonclose)result60 = somerandomoperation()TIMEFRAME(15 minutes, updateonclose)result15 = somerandomoperation()IF result15 > result60 THEN DRAWARROWUP(barindex, Close - 8) COLOURED(0,255,10)ENDIFit will draw up arrows under all the bars that match the required conditions.
The question I have is, is this a “known feature” of PRT code, that you have to reference timeframes in a certain order? Or, that you have to use the current timeframe as the last operation?
I’ve looked in the documentation and can’t find any warning about what order timeframes should be used in, or whether they need to be “reset” to the current working timeframe.Have I missed something or is there some further additional documention about the TIMEFRAME call that explains this sort of thing?
Any advice, or clarification is appreciated.
03/20/2021 at 5:32 PM #164758Your assumption about your first example is wrong, it plots an arrow whenever the condition is met on 15-minute, 5-minute and 1-minute TF’s with the code:
12345678910once N = 76.8TIMEFRAME(15 minutes, updateonclose)result15 = (year * month * day * hour * minute + barindex) mod N//TIMEFRAME(1 hour, updateonclose)result60 = (year * month * day * hour * minute + barindex) mod NIF result15 > result60 THENDRAWARROWUP(barindex, Close - range) COLOURED(0,255,10,255)ENDIFreturnThe same for the second example (with a different output):
12345678910once N = 76.8TIMEFRAME(1 hour, updateonclose)result60 = (year * month * day * hour * minute + barindex) mod N//TIMEFRAME(15 minutes, updateonclose)result15 = (year * month * day * hour * minute + barindex) mod NIF result15 > result60 THENDRAWARROWUP(barindex, Close - range) COLOURED(0,255,10,255)ENDIFreturnThe rule is the the lowest TF (in this case the 15-minute TF) sets the pace.
So every 15 minute the conditions is evaluated, of course the 1-hour TF updates its data at a hour boundary, so it wll remain the same for 4 15-minute units, but evaluation of the condition will be made every 15 minutes.
03/22/2021 at 8:16 AM #16484503/28/2021 at 4:07 PM #165557 -
AuthorPosts
Find exclusive trading pro-tools on