Hi
I am using timeframeset and set it to show Monthly Close price. When I am in timeframe Weekly chart, the timeframeset inMonthly show different result than the real Monthly chart close. There is no problem when I am in Daily Chart, it shows the correct Monthly close value.
I notice It only happens during February, other months are correct. Anything wrong with this code? Please help.
tfM = inMonthly;
TimeFrameSet(tfM);
mclose = C;
TimeFrameRestore();
mclose2 = TimeFrameExpand(mclose,tfM, expandFirst);
Title = "Monthly Close = "+WriteVal(mclose2, 1.0);
Thanks.
TimeFrame works with "multiples".
If you use minute you can see 2min, 3min, 4min day, week etc..
but if you use 2minutes you can not see 3 minutes.
The same happens with week. week is not multiple of month.
Hi
Since no other senior members answering this question beside awilson, I guess awilson's answer is the correct answer. It's rather irritating seeing different value than the real Monthly close value although only for the month February.
Thanks.
@newbietrader,
Your question has only been up for 20 hours. Lots of time still to get other people to respond.
I don't have the opportunity to test your code currently, but what about just getting and setting the VALUE you need in to a variable, and then just use the value (perhaps the Lastvalue function) in your code as you need it.
Or on the daily chart, find where the month changes, and look at the close value of the previous daily bar to get the monthly close.
As a newbie, you will need to open your thinking up to other methods. @awilson has answered why your current code does not give you the results you expect, but you can look to other ideas or methods for other ways to get your desired results.
Good Luck.
1 Like
@newbietrader @awilson is correct. You are mistaken. The Monthly Close will not match up with the Weekly date except in months where the last trading day of the Month is also the last trading day of a Week. Think about it, look at your calendar. It is common sense.
Also worth noting that you are using expandFirst
. I hope you realize you are looking into the future when using the Close. expandFirst
makes the Monthly Close available from the first bar in the new month.
http://www.amibroker.com/guide/afl/timeframeexpand.html
You need to review the user guide and learn about what the MTF functions are doing.
http://www.amibroker.com/guide/h_timeframe.html
Re-read the instructions, try coding a few examples, and search through this forum for several other examples.
Then when you have a firm grasp of what you are trying to achieve using the MTF functions if you still have questions come post specifics here on the forum and you will probably get help.