NexusFi: Find Your Edge


Home Menu

 





Multiple Timeframes in One Chart/Strategy


Discussion in MultiCharts

Updated
    1. trending_up 57 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
ReneRose1971
Syke/Niedersachsen
 
Posts: 2 since Jan 2025
Thanks Given: 0
Thanks Received: 0

I have been working with MultiCharts.Net/VB.Net for a few weeks now. Slowly, I am getting familiar with the workflows and technical details of the software. One important topic is accessing a higher timeframe from a lower timeframe. I have prepared an analysis on this and would appreciate friendly comments on the content.

The question is which period of a smaller timeframe corresponds to the respective period of the higher timeframe. The chart setup consists of Instrument(1) = Datanumber1 - 15 minutes, and Instrument(2) = Datanumber2 - 1 hour. This configuration is used in trading systems that operate on the smaller timeframe but incorporate information from the higher timeframe into the trading logic.



On Instrument(1), the lower timeframe, an indicator runs that generates text output in the output window. The indicator has the CalcEveryTick(False) attribute, which ensures that the evaluation occurs only once, at the closing tick of the period.

Access to the timestamps of the instruments is done using index 0 on the Time() property. Index 0 reads the current timestamp of the data series, while index 1 would read the timestamp of the previous period, as the series properties of the instrument are sorted in reverse order. Additionally, along with the timestamp, the period’s closing price Close(0) is also read and included in the text output.

 
Code
      Protected Overrides Sub StartCalc()
			output.WriteLine("Instrument 1: " & Bars.Info.Name)
			Output.WriteLine( "Size: {0}, Type: {1}", Bars.Info.Resolution.Size, Bars.Info.Resolution.Type)
			
			htfInstrument = BarsOfData(2)
			
			output.WriteLine("Instrument 2: " & htfInstrument.Info.Name)
			Output.WriteLine( "Size: {0}, Type: {1}", htfInstrument.Info.Resolution.Size, htfInstrument.Info.Resolution.Type)
		End Sub

		Protected Overrides Sub CalcBar()
			Dim ltfTime As Date = Bars.Time(0)
			Dim ltfPrice As Double = Bars.Close(0)

			Dim htfTime As Date = htfInstrument.Time(0)
			Dim htfPrice As Double = htfInstrument.Close(0)

			Dim message As String = ltfTime.ToString & " (" & ltfPrice.ToString & ") - " & htfTime.ToString & " (" & htfPrice.ToString & ")"
			Output.WriteLine(message)
		 End Sub
CalcBar is called once per 15-minute period at the closing tick. In htfInstrument, the hourly instrument is read. The text output includes the timestamp of the current 15-minute period, the timestamp of the corresponding hourly period, and the closing prices of both periods.

 
Code
08.01.2025 19:45:00 (20468) - 08.01.2025 19:00:00 (20440)
08.01.2025 20:00:00 (20446) - 08.01.2025 20:00:00 (20446)
08.01.2025 20:15:00 (20455) - 08.01.2025 20:00:00 (20446)
08.01.2025 20:30:00 (20487) - 08.01.2025 20:00:00 (20446)
08.01.2025 20:45:00 (20461) - 08.01.2025 20:00:00 (20446)
08.01.2025 21:00:00 (20466) - 08.01.2025 21:00:00 (20466)
08.01.2025 21:15:00 (20457) - 08.01.2025 21:00:00 (20466)
08.01.2025 21:30:00 (20474) - 08.01.2025 21:00:00 (20466)
08.01.2025 21:45:00 (20473) - 08.01.2025 21:00:00 (20466)
08.01.2025 22:00:00 (20484) - 08.01.2025 22:00:00 (20484)
09.01.2025 08:15:00 (20456) - 08.01.2025 22:00:00 (20484)
09.01.2025 08:30:00 (20437) - 08.01.2025 22:00:00 (20484)
09.01.2025 08:45:00 (20433) - 08.01.2025 22:00:00 (20484)
09.01.2025 09:00:00 (20401) - 09.01.2025 09:00:00 (20401)
I interpret the output to mean that the currently running smaller period is automatically assigned the most recently closed higher period. The 22:00 15-minute period is the last period within the 22:00 hourly period. Therefore, the 22:00 hourly period is assigned to the 22:00 15-minute period. During the following periods at 08:15, 08:30, and 08:45, the 22:00 hourly period is still considered the current hourly period. From 09:00 in the 15-minute timeframe, the 09:00 hourly period is assigned.

The question of whether I can access the period BarsOfData(2).Time(0) at the closing tick of the period Bars.Time(0) without my trading system accidentally evaluating future data can be answered with yes.

Reply With Quote




Last Updated on January 30, 2025


© 2025 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Sitemap - Downloads - Top
no new posts