Amibroker formula, multi time frames

Discussion in 'Trading Software' started by themickey, Jul 8, 2010.

  1. /*
    I'm attempting to use an Amibroker exploration which in one go will indicate how many periods a stock has traded in different multi time frames.
    ie, Monthly, weekly and daily.

    This is my attempt below but the exploration results come out all the same.

    Any suggestions?
    Is it is possible?
    I've researched this a bit but can't suss it out.

    Period1 = LastValue(Cum(1)) -1; // total number of MONTHLY bars traded

    Period2 = LastValue(Cum(1)) -1; // total number of WEEKLY bars traded

    Period3 = LastValue(Cum(1)) -1; // total number of DAILY bars traded

    Filter = 1;

    AddColumn(Period1, "Period1" ); // Monthly
    AddColumn(Period2, "Period2" ); // Weekly
    AddColumn(Period3, "Period3"); // Daily

    // or

    AddColumn(TimeFrameExpand(Period1, inMonthly), "Period1" ); // Monthly
    AddColumn(TimeFrameExpand(Period2, inWeekly), "Period2" ); // Weekly
    AddColumn(TimeFrameExpand(Period3, inDaily), "Period3" ); // Daily
  2. Your formula is incorrect. You would need to replace all occurrences of Cum(1) with Cum( NOT IsNull( C ) )
  3. Thankyou, OK, just done that.
    Lastvalue(Cum( NOT IsNull( C )));

    Results still all identical.
  4. ahaa, worked it out.
    I was doing my exploration in monthly periods and this was giving same results across the board.
    When I went to daily periodicity in the setting window, this gave me the correct results.
    Thank you for your assistance.
  5. I'm attempting to do an exploration from back several months ago, eg an exploration on 31/03/2009.

    Therefore from 31/03/2009....
    a) I'm wanting to count the number of bars from first bar traded.
    b) I'm wanting to count the number of bars to last bar traded.

    I've tried the below but they don't give the correct barcount

    Period1 = LastValue(Cum(NOT IsNull(C)));
    Period2 = EndValue(Cum(NOT IsNull(C)));
    Period3 = BeginValue(Cum(NOT IsNull(C)));
    Period4 = BarsSince(period1);

    Any suggestions appreciated on where I'm going wrong.
  6. I should add that I'm doing a daily periodicity exploration but wanting to count monthly bars.

    Period1 = LastValue(Cum(NOT IsNull(C)));
    Period2 = EndValue(Cum(NOT IsNull(C)));
    Period3 = BeginValue(Cum(NOT IsNull(C)));
    Period4 = BarsSince(period1);
  7. Please use support at amibroker dot com.
    Elitetrader is not a place to get tech support for AB.

    As to the matter, if you want to count only in-range bars then you would need to add appropriate condition such as:

    whattocount = Status("barinrange") AND NOT IsNull(C);
    Period1 = LastValue(Cum(whattocount));
  8. Thank you for your assistance.
  9. Hi Amibroker powerusers.

    Need some help in clarifying whether backtests using 2 timeframes can be done . I know there are functions to fetch data from higher timeframes (ex 60m into a 10m) but I am concerned that there might be material limitations to this kind of testing. Let me explain. Using TimeFrameSet / TimeFrameExpand functions you can map 60m data into 10m charts in case you have a buy trigger like....If 10m adx<20 and 60m adx > 80 then buy at market.

    The timeframeExpand has a flag of either 'expandlast' or 'expandfirst'.

    In a 10m chart the 12:40pm bar would have the 11-12pm value of ADX if 'expandlast' was used (too late) OR the 12-1pm value of ADX if expandfirst was used. (big no no since you are peeking into the future!!)
    In either scenario, would'nt the results be inaccurate?

    The real accurate solution would be to have the 12:40-12:50 bar paired off with an hourly bar which at that point is only from 12-12:50. Thoughts?
  10. My two cents. An hourly bar is an hourly bar. Standard indicators are calculated on bar close. A bar from 12:00 to 12:50 would be a 50 min bar in my dictionary but not an hourly bar. But maybe in a another dictionary or rather math book 1+1 = 3 nowadays.

    expandfirst looks at the current state of a higher tf bar. So if a bar is not closed yet then the value of the current last hourly bar being looked from tf10 changes the same way it would change if looking at one hour time frame's current last bar without looking from lower TF. So at 12:49.59 you have the close of an indicator in 10m TF and you have the current state of the higher tf indicator whose bar is not finished yet. So in other words next 10m bar's hourly value could be different or the same one and would be the actual next hourly close since you have a new full hourly bar then at 12:59:59. So actually that's what you mean. Otherwise ask support of AB to be sure.
    #10     Nov 6, 2013