Usage of TimeFrameGetPrice function

I am trying to get 3 min Close price from first 3 min OHLC in a 15 min candle chart, tried below statement but its giving me 15 min Close price.

TimeFrameGetPrice("C", 3*in1Minute, 0, expandFirst)

My strategy is planned for 15 min candle timeframe, but I want to capture first 3 minutes price of a candle and based on my condition enter on close of first 3 min close of a 15 min candle for early entry.
Can any expert help me please if this is possible to achieve.

You can't access data with a shorter interval (3m) than your base interval (15m). You would need to run your strategy on a 3m chart, and then use TimeFrameCompress() to create 15m bars for your indicators.

1 Like

Thanks mradtke, I thought the reverse is also possible.

@dtm - you really need to READ the manual http://www.amibroker.com/guide/h_timeframe.html especially text within ORANGE boxes. It is extremely important to read those orange boxes. The information given in them is essential.

So once again, that's essential reading:
http://www.amibroker.com/guide/h_timeframe.html

Thanks Tomasz, for your comment. I read that now, my bad.

Trying to achieve the below condition. Working on 1 min candle chart and want to get 5 min EMA crossover point.

TimeFrameSet(in5Minute);
C_5MIn =  TimeFrameCompress(C, in5Minute);

FastEMALength = 5; 
SlowEMALength = 20;

Emafast_5min = EMA(C_5MIn, FastEMALength);
EmaSlow_5min = EMA(C_5MIn, SlowEMALength);

EMAShort_5min = Cross(EmaSlow_5min,Emafast_5min) ; 
EMABuy_5min = Cross(Emafast_5min,EmaSlow_5min);
TimeFrameRestore();

Buy = TimeFrameExpand(EMABuy_5min, in5Minute));

This is not working, not sure where I did the mistake. Can this be achieved, if so can you please help to fix this.

If you are using TimeFrameSet, you don't need to (and should not) additionally call compress on Close array. Close is already compressed after TimeFrameSet

TimeFrameSet(in5Minute);
C_5MIn =  TimeFrameCompress(C, in5Minute);  // that is INCORRECT if you already called TimeFrameSet

Your code should be just using Close:

TimeFrameSet(in5Minute);

FastEMALength = 5; 
SlowEMALength = 20;

Emafast_5min = EMA(Close, FastEMALength); // this Close is already compressed
EmaSlow_5min = EMA(Close, SlowEMALength);

EMAShort_5min = Cross(EmaSlow_5min,Emafast_5min) ; 
EMABuy_5min = Cross(Emafast_5min,EmaSlow_5min);
TimeFrameRestore();

Buy = TimeFrameExpand(EMABuy_5min, in5Minute);

1 Like

Thanks Tomasz, it worked. I appreciate your help.