Rank: Newbie
Groups: Registered Users, Subscribers, Unverified Users Joined: 11/15/2016(UTC) Posts: 5
|
Hi,
I am new to the forum, and have just purchased Metastock Pro. I am testing a couple of systems and have some experience creating basic systems or indicators using the metastock programming language. Does anyone know if there is an indicator to display the opening range of a stock or index, meaning the high and low of the first 5 minutes or 30 minutes of trading (high and low from 9:30 to 9:35 AM NY time).
Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,960
Thanks: 92 times Was thanked: 155 time(s) in 150 post(s)
|
Hi,
An important part of the formula language to note is that it operates off of the native interval of the chart. So if you are looking at a Daily chart, there is no way to extract this information.
You would need to have a 5-minute chart opened in order to gather this information. For example, you can use the ValueWhen function in combination with the Time functions (Hour(), Minute(), etc) to report a data array (Open, High, Low, Close, Volume) at a given time.
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers, Unverified Users Joined: 11/15/2016(UTC) Posts: 5
|
Thanks, I will try out your suggestion.
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,960
Thanks: 92 times Was thanked: 155 time(s) in 150 post(s)
|
To give a more specific example:
ValueWhen(1,Hour()=9 AND Minute()=30,C)
This would return the Close price of the most recent 9:30 AM price bar.
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers, Unverified Users Joined: 11/15/2016(UTC) Posts: 5
|
Thanks. I tried it with the High and Low:
ValueWhen(1,Hour()=9 AND Minute()=30, H)
ValueWhen(1,Hour()=9 AND Minute()=30, L)
and it gave me what I expected using 5 minute bars, by the way I am using Metastock Pro RT.
What if I use 1 minute bars and I would like the highest high between 9:30 and 9:35, how would the formula be?
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,960
Thanks: 92 times Was thanked: 155 time(s) in 150 post(s)
|
This formula would be interval dependent, meaning it would be written to use 1-minute data (so the HHV function would look back over 5 1-minute bars from 9:35 AM backwards:
ValueWhen(1,Hour()=9 AND Minute()=35,HHV(H,5))
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers, Unverified Users Joined: 11/15/2016(UTC) Posts: 5
|
Thanks for the suggestions, little by little I am putting my system together. Now I have another question... how can I simulate that any open positions be closed at 16:00 NY time if there is one open at the end of every day? I tried to input in the System Editor / Sell Order tab the instruction
"ValueWhen(1,Hour()=16 AND Minute()=00, C)",
and assumed that it would sell at the closing price of the 16:00 minute bar, but I am getting very strange things, it closes my trades the bar after they are opened. I also tried typing a 0 instead of a 1 just before the Hour() command, but that was even worse.
Any suggestions please?
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,960
Thanks: 92 times Was thanked: 155 time(s) in 150 post(s)
|
You would not want to use ValueWhen for your sell condition. Simply use the time functions by themselves.
Hour()=16 AND Minute()=00
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers, Unverified Users Joined: 11/15/2016(UTC) Posts: 5
|
Things are starting to work well. Something else, is it possible to run the system test on a "continuous contract" for futures? I am running my tests on the Russell 2000 (TFSZ6) and S&P 500 (ESZ6) futures contracts, but obviously before Sep 16, the liquidity is so low that the bars displayed generate strange trading signals.
Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,960
Thanks: 92 times Was thanked: 155 time(s) in 150 post(s)
|
This should not be a problem, just make sure to use the "c1" version of the symbol, i.e. ESc1 or TFSc1
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.