Bars back to time

Questions about MultiCharts and user contributed studies.
roesm
Posts: 37
Joined: 30 Sep 2011
Has thanked: 10 times
Been thanked: 5 times

Bars back to time

Postby roesm » 11 Nov 2011

When I place an arrow on the chart and I want to use the closing value of the bar (say, 1-minute) under that arrow in a study, I need to calculate the number of bars back from the end of the chart to that arrow. Is there an easy way to do that across days, with different types of futures contracts (e.g. ES & CL)?

Thanks in advance...
roesm

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Bars back to time

Postby TJ » 11 Nov 2011

When I place an arrow on the chart and I want to use the closing value of the bar (say, 1-minute) under that arrow in a study, I need to calculate the number of bars back from the end of the chart to that arrow. Is there an easy way to do that across days, with different types of futures contracts (e.g. ES & CL)?

Thanks in advance...
roesm
can you draw a diagram to illustrate what you want to do?

roesm
Posts: 37
Joined: 30 Sep 2011
Has thanked: 10 times
Been thanked: 5 times

Re: Bars back to time

Postby roesm » 11 Nov 2011

In the attached screen-shot, I am analyzing the relationship between CL and ES over time. I have placed a red arrow at a point of overlap and I would like to retrieve the closing values of the two instruments at that point (in this case, CL=97.35 & ES=1240.15). But as I go back in history, the number of bars changes between them (see differing BarNumber values in the Data Window). I would like to have a function which would tell me the number of bars back to the arrow for data1 and data2. Then I could simply use "Close Data[x]" to get the value.

Is that possible? Should I approach this from a different angle?

Mike
Attachments
CL_ES_Overlay.PNG
(46.31 KiB) Downloaded 536 times

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Bars back to time

Postby TJ » 11 Nov 2011

In the attached screen-shot, I am analyzing the relationship between CL and ES over time. I have placed a red arrow at a point of overlap and I would like to retrieve the closing values of the two instruments at that point (in this case, CL=97.35 & ES=1240.15)...
do you mean manually draw an arrow on the screen?
...But as I go back in history, the number of bars changes between them (see differing BarNumber values in the Data Window). I would like to have a function which would tell me the number of bars back to the arrow for data1 and data2. Then I could simply use "Close Data[x]" to get the value.

Is that possible? Should I approach this from a different angle?

Mike
do you mean the the number of bars from current bar to the bar where you placed the arrow?

roesm
Posts: 37
Joined: 30 Sep 2011
Has thanked: 10 times
Been thanked: 5 times

Re: Bars back to time

Postby roesm » 11 Nov 2011

Correct

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Bars back to time

Postby TJ » 11 Nov 2011

it can be done,
but will take some programming.

You can use ARW_GET series of keywords to find the coordinates of the arrow.

roesm
Posts: 37
Joined: 30 Sep 2011
Has thanked: 10 times
Been thanked: 5 times

Re: Bars back to time

Postby roesm » 11 Nov 2011

That what I figured... I was just hoping that I'd missed something obvious that would make it easy.

Thank you for your prompt attention!

Mike

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Bars back to time

Postby TJ » 11 Nov 2011

That what I figured... I was just hoping that I'd missed something obvious that would make it easy.

Thank you for your prompt attention!

Mike
Well... you can get DATE, TIME, VALUE... COLOR, SIZE...
and just about anything but bar number.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Bars back to time

Postby bowlesj3 » 12 Nov 2011

As TJ said you can Use the Arw_GetDate and Arw_GetTime (or Arw_GetTime_s) then plug that data into the appropriate binary functions found at this link. Use the zip file at the bottom which has the 3 return codes.
viewtopic.php?f=5&t=7749&hilit=binary

The function will return the offset for the [X] where the arrow is located. At that point you can get any information you want (open,high,low,close,RSI, bollinger bands whatever). You can also loop forward and backward away from this [X] offset to get surrounding data. I am about to write something that takes the date and time of an arrow on the 1 minute bars, sends it to GVs which will be picked up in the 10 second bars and marks where these 1 minute bars are in the RSI subchart (the span of 10 second bars) and tells me if there are any RSI lead breaks in the 10 second bars (between two arrows) and then sends that info back to the arrows in the 1 minute bars and colours them a different colour. An external program will notify me of the lead break with a voice popup. Lots can be done with these binary searches and GVs. I noticed that the download is about 99 so I guess a few people have been finding them useful.

You have to make sure the maxbarsback is set large enough in the study that contains the binary function. If it is too low and the arrow is beyond this distance back it will return a certain negative value. The material at that link should explain this.

It also sounds like you could have a program detect where these data cross over. You could get the data and time and use the binary function to get the offset there. However if you are looping backward with the offset to find these crossovers there would be no need for the binary search.

Of note, there is a sequential search that comes with MC but it is much slower than the binary search.

I have improved these binary functions even more for my own use (mostly cosmetic and debugging speed up when a bad code is returned). I have created a todo reminder to put them out there some day.

Of note, the png picture in this link shows 6 arrows that my study puts out. I move them manually. The binary search is used to find all the arrows. Once found arrow location data and surrounding data is sent out for various uses (I am always adding new uses). This is how I analyse the market and I program the computer to do as much as possible to help me. It is all built off that binary search (tones of binary searches actually).
viewtopic.php?f=1&t=7135&p=44242&hilit=pattern#p44242

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Bars back to time

Postby TJ » 12 Nov 2011

Thanks bowlesj3, you have added a treasure trove this thread. Those are very useful reads.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Bars back to time

Postby bowlesj3 » 13 Nov 2011

Your Welcome TJ. Top down wave analysis is a good way to analyse the market but the downside is fully automatizing it is not easy (I would say impossible). I hope to some day get my approach so all I have to do is move arrows to mark waves and everything else is done by the computer (with some verification responses to go ahead). I am only about 80% there at the moment. The encouraging news is I am much farther than I would have predicted a year ago.

roesm
Posts: 37
Joined: 30 Sep 2011
Has thanked: 10 times
Been thanked: 5 times

Re: Bars back to time

Postby roesm » 14 Nov 2011

Many thanks to both TJ & bowles3 for supporting me here. I modified the binary search routine to handle both data1 & data2 and it's now working great!

Thanks again!

roesm (Mike)


Return to “MultiCharts”