CloseD, openD functions

Questions about MultiCharts and user contributed studies.
brianhclo
Posts: 31
Joined: 31 Mar 2014
Has thanked: 8 times

CloseD, openD functions

Postby brianhclo » 28 Oct 2015

My setup is the following:
Chart 1: hang seng index futures
Chart 2: hang seng index
Chart 3: s&p500

I have chosen 24/5 as time session.

I would like to call spx close t-1 and t-2, hang seng close t-1 and open t.
However checking in output it seem it is not grabbing the values correctly.

Example, on 28/10 HKTime 930am I would like
Spx close 27/10, 26/10
Hang seng index close 27/10, open 28/10.

Any ideas where things have gone wrong?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: CloseD, openD functions

Postby JoshM » 28 Oct 2015

I would like to call spx close t-1 and t-2, hang seng close t-1 and open t.
However checking in output it seem it is not grabbing the values correctly.

Example, on 28/10 HKTime 930am I would like
Spx close 27/10, 26/10
Hang seng index close 27/10, open 28/10.
I think that you're getting the wrong values because `OpenD` and `CloseD` return the data based on the bar that they're called on. So `OpenD(1)` returns the day open for the previous bar, but a periods ago of 10 (`OpenD(10)`) can still return the same day open if that bar happens on the same day. So in other words, you might need to determine how many bars there are in a day, and then use a multiple of that for the number of periods ago.

But without a code and output example it's hard to say what 'grabbing the values not correctly' causes.

brianhclo
Posts: 31
Joined: 31 Mar 2014
Has thanked: 8 times

Re: CloseD, openD functions

Postby brianhclo » 28 Oct 2015

I would like to call spx close t-1 and t-2, hang seng close t-1 and open t.
However checking in output it seem it is not grabbing the values correctly.

Example, on 28/10 HKTime 930am I would like
Spx close 27/10, 26/10
Hang seng index close 27/10, open 28/10.
I think that you're getting the wrong values because `OpenD` and `CloseD` return the data based on the bar that they're called on. So `OpenD(1)` returns the day open for the previous bar, but a periods ago of 10 (`OpenD(10)`) can still return the same day open if that bar happens on the same day. So in other words, you might need to determine how many bars there are in a day, and then use a multiple of that for the number of periods ago.

But without a code and output example it's hard to say what 'grabbing the values not correctly' causes.
My understanding is the OpenD(1) means the open price of the instrument on the previous trading day.

I computed a function to work out the day moving averages on minute charts before. It works well and I have no problem with it. I dont think " but a periods ago of 10 (`OpenD(10)`) can still return the same day open if that bar happens on the same day" is a correct interpretation.

It leads me to think if having Hang Seng Index and SPX in the same chart would be the problem.

Thanks.

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

Re: CloseD, openD functions

Postby TJ » 28 Oct 2015

My understanding is the OpenD(1) means the open price of the instrument on the previous trading day.
::
Thanks.
Just to clarify in case anybody misunderstood.


OpenD, CloseD, etc., operate on Date, not Symbol Session.

ie. the open price will be the first trade of a new bar on a new day.

If your chart is 24/7, the open price will be the first trade of the day.
ie the first trade after midnight, not the first trade of RTH or first trade of ETH.

If your chart is NOT 24/7, eg. from 930 to 1600, the open price will be the first trade of the bar that represents
Date > Date[1].

brianhclo
Posts: 31
Joined: 31 Mar 2014
Has thanked: 8 times

Re: CloseD, openD functions

Postby brianhclo » 28 Oct 2015

TJ, got you.

In my case I need to trade Hang Seng Futures via calling closing prices of SPX on t-1 and t-2, what would be your suggestion? I guess CloseD wouldnt work here?

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

Re: CloseD, openD functions

Postby TJ » 28 Oct 2015

TJ, got you.

In my case I need to trade Hang Seng Futures via calling closing prices of SPX on t-1 and t-2, what would be your suggestion? I guess CloseD wouldnt work here?
What is t-1 and t-2?

I read your first post and I have no idea what you are talking about.

brianhclo
Posts: 31
Joined: 31 Mar 2014
Has thanked: 8 times

Re: CloseD, openD functions

Postby brianhclo » 28 Oct 2015

example,

On the 28/10, I am trading Hang Seng Futures, and my strategy wants to be able to reference to SPX Day Close on 27/10 and 26/10.

Previously when all instruments have the same time session I was able to use CloseD(1) and CloseD(2).

brianhclo
Posts: 31
Joined: 31 Mar 2014
Has thanked: 8 times

Re: CloseD, openD functions

Postby brianhclo » 28 Oct 2015

I am using 10 seconds chart for the trading instrument (Hang Seng Futures).

Day close for SPX means the official closing price for S&P500, 4pm EST I believe.

So at 930am HK Time 28th Oct, I would like to reference
S&P500 Official Closing Price on the 27th Oct ~EST 4pm
S&P500 Official Closing Price on the 26th Oct ~EST 4pm


Return to “MultiCharts”