get ohlc from lower timeframe in Amibroker

#1
Hi all,

is it possible to get ohlc values from lower timeframe, e.g., if I am using 60min tf but needs H and L from second bar of 5min timeframe.
I have tried using

Code:
T = TimeNum();
TimeFrameSet(in5Minute);
x = ValueWhen(T <= 92000, H, 1); // also tried with 92500
TimeFrameRestore();
TimeFrameExpand(x, in5Minute, expandlast);
but it seems like AB is not capable to extract data from lower timeframe. Am I doing right/any mistake or is there any other way ?
 

Romeo1998

Well-Known Member
#4
dont give up, whatever ideas n strategies u have in mind, try to convert it to code n test it... if 1 tool or platform is not working, try the other one....:)
I tried a few things in tradingview n was able to do it... :)
In the code below... we r taking the high of the 9th candle of every new day from the 5 min interval n plotting it.... correct value is shown on all lower n higher intraday timeframes, that is, 1min,3min,5min,15min,30min,45min,1hr,2hr,3h,4h.... but gives wrong values on daily, weekly n monthly timeframes...i think that much is acceptable :) good luck :)

Code:
//@version=4
study("My Script",overlay=true)
newday = change(dayofweek)
a = valuewhen(newday,high,0)
b = valuewhen(barssince(newday)==8,high,0)
c = security(syminfo.tickerid, "5", b)
plot(c)
1627248636644.png
 
#5
dont give up, whatever ideas n strategies u have in mind, try to convert it to code n test it... if 1 tool or platform is not working, try the other one....:)
I tried a few things in tradingview n was able to do it... :)
In the code below... we r taking the high of the 9th candle of every new day from the 5 min interval n plotting it.... correct value is shown on all lower n higher intraday timeframes, that is, 1min,3min,5min,15min,30min,45min,1hr,2hr,3h,4h.... but gives wrong values on daily, weekly n monthly timeframes...i think that much is acceptable :) good luck :)
longtime back I tried afl coding and lost interest due to such AB afl limits (and less time due to job . . . and few trading losses as newbie . . . ;) ), then during ups and downs in intermittent trading, I came across TV platform few yrs back which actually resurrected my interest in afl coding bcos TV's Pine Script have much similarity in syntax with afl scripting. I must say here, TV is amazing.

Bcos of feasibility in Pine, I tried to get lower TF ohlc in AB but then limitations came up and I queried here.

. . . anyway, thanks again for quick reply @Romeo1998.
 

Similar threads