When I code a multitimeframe strategy on say weekly timeframe using functions timeframeset and then timeframeexpand. I expect it to give same results if i run it on weekly or daily or any lower timeframe but the results deviate. Can anyone give a reason for it and how to resolve this issue.

By your own words you are apparently missing TimeframeRestore function before expansion.

Read below links (again)

Additional note (mentioned in manual too): longer interval has to be integer multiple of shorter interval.
So if you want to look at longer intervals e.g. from 5-min interval then you can look at e.g. 10-min (2x5min), 15-min (3x5min), etc. But you can not look at e.g. 7-min interval (7/5 = 1.4) or 12-min interval (12/5 = 2.4) etc. from that shorter 5-min interval. Same applies to other interval examples.

Another possible reason: QuickAFL

Also read here
How to ask a good question since your post is rather less detailed. So for example provide reproducible code and details about where code is run and with UI settings.

Thanks for your response,

I am using timeframerestore fucntion between timeframeset and timeframeexpand, and i am doing it in multiple of the data like 5 min, 10 min, 15min, hourly, daily, still there is a deviation

Your query is not clear on several factors. Like:

  1. What is the exact base Interval of your chart?
  2. To which Higher timeframe interval you are Compressing it to?
  3. Since, you are using TimeFrameSet to Compress, how are you Expanding the same?

For e.g.:
If the base interval is in1Minute, then, you can compress it "to" Higher timeframes like 5 min, 10 min, 15 min etc. And then you need to expand back "from" that Higher timeframe.

You need to be clear on your precise requirements.

While Compressing your requirements might vary as follows:

  1. compressLast - last (close) value of the array within interval
  2. compressOpen - open value of the array within interval
  3. compressHigh - highest value of the array within interval
  4. compressLow - lowest value of the array within interval
  5. compressVolume - sum of values of the array within interval

(Source: TimeFrameCompress() function guide)

Similarly while Expanding your requirements might vary as follows:

  1. expandLast - the compressed value is expanded starting from last bar within given period (so for example weekly close/high/low is available on Friday's bar)
  2. expandFirst - the compressed value is expanded starting from first bar within given period (so for example weekly open is available from Monday's bar)
  3. expandPoint - the resulting array gets not empty values only for the last bar within given period (all remaining bars are Null (empty)).

(Source: TimeFrameExpand() function guide)

Your claims like:

are baseless and shows that you have not spent enough time researching the nuances. You literally need to digest this article - Multiple Time Frame support in AFL. And this Multi-TimeFrame topic is amongst one of the most questioned or discussed subject here in this forum. So, please thoroughly search this forum for some eye-openers as below:

Why TimeFrameExpand is essential (Warning 509)
TimeFrameSet and TimeFrameExpand
How to properly use TimeframeExpand function

Due to lack of any detail I am still guessing, by any chance are you trying to do the reverse, i.e. capture data of a Lower TimeFrame while being on a Higher TimeFrame chart. If so, then this might help you:

StaticVarSet/StaticVarGet Multiple Timeframe Assistance

If you happen to post again, kindly be precise for others to understand your requirements and help you with a proper solution but simply claiming that things do not align is inappropriate.

But a deviation from what? We have no idea what you've tested or how your code looks. Are you writing in AFL? (How would we know?) Does your code pass the Verify Syntax check? (Again, how would we know?)

I want my car to be a shade of blue but the color isn't coming out of the paint mixer the way I want. Somebody give me the formula for the shade I need.

See the problem? Who knows exactly what shade of blue I want unless I provide some details on the various blues I've already tried?