Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Is this what you are looking for? I just took the stock Exponential moving avg script and added input for a new time period. I think it would be better if you could gather the OHLC info using the rec statement, but this works fine.
BTW, if anyone knows how to do this using the "rec" statement please let me know.
I know how but I am not sure I understand what you want to do exactly. If you just want to use OHLC as an input for price rather than close, then that wouldn't require a rec variable to do so. Help me understand exactly what you mean and I'll code it for you in a matter of seconds
In order to access data of a different aggregation period in your code, specify the period parameter using the corresponding Aggregation Period constant. You can also use a pre-defined string value for this purpose: 1 min, 2 min, 3 min, 4 min, 5 min, 10 min, 15 min, 20 min, 30 min, 1 hour, 2 hours, 4 hours, Day, 2 Days, 3 Days, 4 Days, Week, Month, Opt Exp, and <current period>.
notice that the time period you want to reference must be greater than the time period on your chart. e.g., you can't reference 5 min data on a 30 min chart but i don't think that that is a problem in the case described here
your code would look something like this:
def a = Average(close(period = AggregationPeriod.FIVE_MIN));i would have provided the link to the documentation but i am new here and can't post links (yet)
I would like to (using a rec variable) from a 1min chart, gather the OHLC that would make a 30min bar. For example. if the time is 10:24, (1) get the CLOSE of the 10:24 1min bar, this is the close of the 30min bar. (2) from time 10:00 to 10:24 find the HIGH and LOW. (3) get the OPEN from the 10:00 1 min bar. This would be the same as if you had a 30min chart open in a seperate pane. Then you can use the rec variable like... anchorClose[1] or anchorClose[2] or anchorHigh[1] or anchorLow[3] etc to calculate a higher time frame anchor indicator that you can use on a smaller chart.
I hope that wasn't confusing. Basically I want to see a 30min or 15min stochastics on a 1 or 5 min chart but be able to change the period to 10, 15, 30, 60 etc (a multitimeframe stochastics indicator)