# Calculation of Indicator on intraday + past eod data based on daily data

Hi

So i want to backtest some indicator based on daily timeframe during intraday periods. For ex:
indi=Rsi(14)
buy=indi>50
Above indicator is based on daily timeframe and i want to backtest it during intraday as if prices till particular time/bar are end of day prices or if the day ends at that bar , what would be my indicator.
Lets say its 10:30 AM, so my indicator should be such that it uses past 13 daily values and open ,high ,low and close till 1030 of today for calculation. Assuming lets say i am running a backtest on 5min bar.

Hi
I have tried using multi timeframe like following:

``````TimeFrameSet(inDaily);
MA_test=MA(C,2);
TimeFrameRestore();
ma1=TimeFrameExpand(MA_test,inDaily);
Plot(ma1,"ma2",colorRed,styleLine);
``````

But this not work as intented.

This basically uses expandlast so value only changes end of day.

Since i want to backtest when my eod indicator condition gets triggered intraday.

expandPoint - the resulting array gets not empty values only for the last bar within given period (all remaining bars are Null (empty)).

Using expandPoint will do what you want, but will only works for trading not for backtesting.

@akshay.gupta55, I believe @awilson is correct: for backtesting there is no easy way to do what you want simply by using the TimeFrame* functions or with standard array logic. Instead, you would need to use loops to:

1. Create an array which contains daily data for everything before the "current (daily) bar"
2. Enter the next intraday data value for the current bar
3. Calculate the indicator using that modified array
4. Store the current bar indicator result back into another array.

It's not terribly complex, but it will be time consuming (i.e. inefficient) from an execution standpoint.