How to get the dynamic previous day close in AFL for explanation according tp from date selected in range ?
Hi, I am using this in my AFL Code .It calculates previous day close corresponding to today i.e current day. But I wast the close with respect to date chosen in exploration Start date & End date
Please note I am using this code for intraday . It is working fine for today. But it is not working for previous days.
You will have to learn about the "TimeFrame*" commands.
Also, how to specify your issue more clearly.
You will usually receive more help when you show your work (as in posting your code).
LastValue(TimeFrameGetPrice("Close", inDaily, -1))
I am using this for Previous Day Close in my afl
What is dynamic about a prev day close ?
As @snoopy.pa30 suggested, learning a few TimeFrame and related functions wouldn't hurt.
Please let me make it clear that I am not asking you to write code for me .I am just asking specific question about the functionality to solve my problem I am putting the query when I am unable to find out the solution.
My question was that in my AFL I want Previous close . For this I am using function LastValue(TimeFrameGetPrice("Close", inDaily, -1)) . If I execute the afl for current date then it gives correct output. But if run this for older time period the same close price is shown. I am running this AFL intraday.
By using LastValue()
you are telling AmiBroker to give you the last value in the array. If you just use the TimeFrameGetPrice()
call without the LastValue()
, you'll probably get exactly what you want.
Like @mradtke said, probably don't need Lastvalue.
Also, I am not trying to be too critical, but if you notice in your original post, there was no information on what timeframe you were using, or the code that you were using. So that left me guessing.
One additional thought. Learn how to use Explorations. I have been using AB for a while (mainly for charting and indicators) but have become a big time convert to using Explorations while developing code, as you can see whatever variables you want at any time. Setting your Filter conditions you control what you get, and I have found that it is EXTREMELY helpful to debug my code.