# Timeframe AFL: help needed in checking formula

Good Day!

I have a 5 minute default chart where i use the below AFL to know when WMA-36 has crossed MA-50

``````Upcross=Barssince(cross(WMA(C,36),MA(C,50)));
``````

I want to get the value of the same variable in a daily time frame with out upsetting the variables calculated in the current time frame. I am using the below formula but gives me results as {EMPTY]. Please help me out.

``````Upcross_daily=Timeframecompress(Upcross, inDaily);
``````

Your code is incorrect on the conceptual level (not coding). Consult manual http://www.amibroker.com/guide/h_timeframe.html
In short you should be compressing PRICES (OHLC) then do Cross() on compressed prices. See also: How do I debug my formula?

Tried the above. still not getting the results. i might be doing something wrong.

``````Close_daily=Timeframecompress(C,inDaily);
``````

Yet Upcoss_D gives me [Empty].

Again - re-read the manual. It is all there. Read the orange boxes. You are doing things against the manual http://www.amibroker.com/guide/h_timeframe.html

Still not clear or able to grasp. will Barssince work on a different timeframe ?

doing the below but giving wrong results, any help appreciated (my default chart and calculations are in 5 Min)

``````TimeFrameSet(inDaily);
DailyCrossOver=Cross(WMA(C,36),MA(C,50));
TimeFrameRestore();
Barsfromcross=TimeFrameExpand(Barsfromcross,inDaily);

``````

What does "wrong results" refer to?
Your moving averages are daily time frame ones but not of 5-min time frame.

thanks my bad. i am getting the results. but i get [Empty] while referencing the "Barsfromcross" variable for example

``````StartPointSincecross=Ref(Low,-Barsfromcross); or LowSincecross=LLV(Low,Barsfromcross);
``````
``````TimeFrameSet(inDaily);
DailyCrossOver=Cross(WMA(C,36),MA(C,50));
TimeFrameRestore();
DailyCrossOver=TimeFrameExpand(DailyCrossOver,inDaily);
//Barsfromcross=TimeFrameExpand(Barsfromcross,inDaily);

StartPointSincecross = Valuewhen(DailyCrossOver, L);
LowSincecross = LowestSince(DailyCrossOver,L);
``````

thanks @codejunkie . when i check below code from you. i get a different number for Low when the cross happens. (Chart attached)

``````StartPointSincecross = Valuewhen(DailyCrossOver, L);
``````

Now my problem is i am not able to reference the OHLC of the "Barsfromcross"

``````TimeFrameSet(inDaily);
DailyCrossOver=Cross(WMA(C,36),MA(C,50));