Current location | Thread information | |
![]() ![]() ![]() ![]() ![]() ![]() |
Last Activity 4/16/2025 3:28 AM 7 replies, 983 viewings |
|
|
Printer friendly version |
^ Top | |||
Boris Lund![]() Regular ![]() ![]() Posts: 59 Joined: 12/9/2021 ![]() |
I am trying to build a Market Profile indicator. I need to look at volume at a lower timeframe so I can see the lower timeframe price and volume distribution. If I look at the one hour timeframe I would look at the underlying 5min intervals. But first I need to be able to address the underlying timeframes correctly. In the simple example it should look at the 30min timeframe while I am on a 60min. The volume of the last 30min plus the 30min before should add up to the current 60min bar volume. But it doesn't... #Indicator dim a,b,d as single a=mt(v,"30m",1) b=mt(v,"30m",1)[1] d=a+b plot("a",a,black) plot("b",b,green) plot("d",d,blue) Return 0 ![]() | ||
^ Top | |||
Barry Cohen![]() Idol ![]() ![]() ![]() ![]() Posts: 2305 Joined: 1/1/1900 ![]() |
Try this. Using the MT function, 1 = dynamic, 2 = previous bar, 3 = previous bar with actual data instead of building the data from the current timeframe. #Indicator dim a,b,d as single a=mt(v,"30m",3) b=mt(v,"30m",3)[1] d=a+b plot("a",a,black) plot("b",b,green) plot("d",d,blue) Return 0 | ||
^ Top | |||
Boris Lund![]() Regular ![]() ![]() Posts: 59 Joined: 12/9/2021 ![]() |
The total vol for the bar should be mt(v,"30m",3)+mt(v,"30m",3)[1] but it still doesn't work. Also the vol is unchanged for several consecutive bars so something else must be wrong. ![]() | ||
^ Top | |||
Boris Lund![]() Regular ![]() ![]() Posts: 59 Joined: 12/9/2021 ![]() |
Sorted the 30min data. But this picture clearly shows that I only get the total 60min volume even addressing the 30min timeframe. a=mt(V,"30m",3) plot("a",a,black) This should give me the last 30min volume. Instead it gives me the whole 60min. It is also clear that the green is one 60min timeframe shifted, and also showing the whole 60min volume. b=mt(V,"30m",3)[1] Shows the volume one hour ago for the the whole hour. [Edited by Boris Lund on 7/10/2022 3:46 PM] ![]() | ||
^ Top | |||
Boris Lund![]() Regular ![]() ![]() Posts: 59 Joined: 12/9/2021 ![]() |
Maybe add this to the manual. Sorted addressing lower timeframes from a higher timeframe perspective. ![]() | ||
^ Top | |||
Barry Cohen![]() Idol ![]() ![]() ![]() ![]() Posts: 2305 Joined: 1/1/1900 ![]() |
Smart! I didn't think of that! | ||
^ Top | |||
Boris Lund![]() Regular ![]() ![]() Posts: 59 Joined: 12/9/2021 ![]() |
Unfortunately that was a fluke from the specific interval I was looking at. On a 15min lower timeframe it is easier to see. a=mt("V","15M",2)[0]. The offset refers to the current timeframe. The second parameter has no influence here since we are referring to a lower timeframe. b=mt("V","15M",2)[1] The offset will point us to the last 60min timeframe and give us the last 15min data. The offset point to the current (60min) timeframe and not the 15min referred lower timeframe. Then I tried a workaround changing the timeframes, since the 15min[1] is equal to 30min minus 15min like this mt("V","30M",2)-mt("V","15M",2) That works. So now I have 15min[0] and 15min[1] the two last 15min component. So now it should only be a matter of adding timeframes of bigger sizes in steps of 15. Thus we need the 45M. Adding that, the 3. 15min timeframe (15min[2]) should be the 45M-30M like this mt("V","45M",2)-mt("V","30M",2) But that doesn't work. Something messes up due to the 45M offset not being a whole fraction of 60M. So I am back to not being able to refer to the individual smaller timeframe offsets. ![]() | ||
^ Top | |||
Steve Johnson![]() New User Posts: 3 Joined: 4/29/2020 Location: Olathe, KS ![]() |
I was researching the MT indicator and ran across your thread. At first I didn't think the indicator worked for smaller timeframes, but I did find that a function like SUM for 3 five min bars while in 15 min timeframe was indeed the same result as adding each of the 5 min bars within that 15 min bar. You are correct that the value returned for OLHCV is the last lower timeframe bar within the larger timeframe. Then it hit me to try this: MT(V[1],"5M",0) to get the previous 5 min bar. Unfortunately, OT didn't like that syntax and wouldn't compile. But wait! Wrap V[1] inside an indicator and maybe... ExtractV.txt #Indicator #Param "Barsback", 0 Dim mydata As single mydata = V[Barsback] Return mydata Then: MT(ExtractV(2),"5M",0) will give you the first 5 min volume bar from the 15 min bar. I tried to build an elegant solution where I could pass in the data type (OLHCV), bars to look back, lower timeframe number (e.g. -1) and # of lower timeframe bars covered by the current timeframe, but the ExtractV indicator would not work using variables in the MT formula. It just would not compile unless I inserted a simple number for the Barsback parameter. My only solution idea is a large select case structure for each data type and bar position. If you want to cover looking at say 5 min bars from a 60 min current timeframe, you need 12 select case statements for each data type you want to cover. Hopefully that gives you enough to continue your original idea. |
|
|
Legend | Action | Notification | |||
Administrator
Forum Moderator |
Registered User
Unregistered User |
![]() |
Toggle e-mail notification |