Close of bar of specific time
Author: maninjapan
Creation Date: 2/7/2012 12:46 PM
profile picture

maninjapan

#1
I am working with a strategy that measures the change in the current close compared to a specific time of day.

For example: (current close - 10:30am close) / 10:30am close

How do I refer to this 10:30 am close?



Thank you
profile picture

Eugene

#2
Get the date/time from Bars[bar].Date while looping bar by bar, and on how to determine that bar see the FAQ:

FAQ | Strategies and WealthScript > "How do I code a rule for time of the day?"
profile picture

maninjapan

#3
Thanks Eugene. I may be completely off track here, but am I able to assign the value to a variable using something like this and then refer back to this as part of the entry condition?

CODE:
Please log in to see this code.
profile picture

Eugene

#4
Sure.
profile picture

maninjapan

#5
First step, I would like to just chart the value of 'xClose'. Ive attempted the following based on some other examples but receive an error' CS0103 @(30,28) the name xClose is not valid in this context' (I use Japanese windows so this is a rough translation).
Any hints as to what I am doing wrong or what the correct format should be for this? In its current format it should be a very simple indicator that keeps track of the 10:30am close through out the day


CODE:
Please log in to see this code.
profile picture

Eugene

#6
You're mixing up a double value with a DataSeries.

Create a new blank DataSeries. Check the time condition, if it's true then assign the Close to the DataSeries at the current bar. Then you'll be able to plot the new DataSeries.

For examples, start from the WealthScript Programming Guide.
profile picture

maninjapan

#7
Eugene, by 'create a new blank DataSeries', are you referring to the How to: Create a "semi-formal" Custom Indicator?

Thank you
profile picture

Cone

#8
Not necessarily. See DataSeries > Filling a Custom DataSeries. Use the technique in Example 2.
profile picture

maninjapan

#9
Thanks Cone (and Eugene). I believe I am almost where I want to be, The following returns the value at the specified time. However apart from that specific time, it returns 0, I am trying to carry the value the following day at 10:30 when it will be updated to the new 10:20 close price.

CODE:
Please log in to see this code.
profile picture

maninjapan

#10
Thanks Cone (and Eugene). I believe I am almost where I want to be, The following returns the value at the specified time. However apart from that specific time, it returns 0, I am trying to carry the value the following day at 10:30 when it will be updated to the new 10:30 close price.

CODE:
Please log in to see this code.
profile picture

Eugene

#11
CODE:
Please log in to see this code.
profile picture

maninjapan

#12
Thank you both for your time, not only did I plot the data I needed, I learnt a few things too.
CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).