# Mark a 15min candle, if a morning star is formed in 5min candles

Hello guys, I did the code successfully in which if the timeframe is 5 min, and their is a crossover in Stoch RSI in hourly timeframe, it will show me an arrow in 5 min.

However Now, I am trying to do is, I scanned a pattern say "Morning Star" in 5 min duration(Interval).
And if the Timeframe in use is 15minutes, I want to show an up arrow there, indicating a morning star is formed in 5min interval.

``````_SECTION_BEGIN("Morning Start Try 2");

varMin5C = TimeFrameGetPrice( "C", in5Minute, 0, expandPoint );
varMin5O = TimeFrameGetPrice( "O", in5Minute, 0, expandPoint );

varMin15C = TimeFrameCompress( Close, in15Minute );
varMin15O = TimeFrameCompress( Open, in15Minute );

MDS2 = Ref(varMin5C,-2)<Ref(varMin5O,-2) AND Ref(varMin5O,-1) < Ref(varMin5C,-2)
AND Ref(varMin5C,-1) < Ref(varMin5C,-2) AND varMin5O > Ref(varMin5C,-1) AND varMin5C > (Ref(varMin5C,-2)+Ref(varMin5O,-2))/2
AND Ref(varMin5O,-1) == Ref(varMin5C,-1) ;

vbarInterval = Interval(0);

for( i = 0; i < BarCount; i++ )
{
if( MDS2[i] ) PlotText( "Morning Star @ " + Interval(0) + varMin5C[ i ], i-1, L[ i ], colorGreen );

if(vbarInterval == 300){
if( MDS2[i] ) PlotText( "Morning Star @ " + Interval(0) + varMin5C[ i ], i-1, L[ i ], colorGreen );
}else if(vbarInterval == 900){
MDS25=TimeFrameExpand(MDS2,in15Minute,expandPoint);
if( !MDS25[i] ) PlotText( "Morning Star @ " + Interval(0) + varMin5C[ i ], i-1, L[ i ], colorGreen );
PlotShapes(IIf(!MDS25, shapeHollowUpArrow, shapeNone),colorBlue, 0,H, Offset=140);

}
//if( Sell[i] ) PlotText( "Selln@" + C[ i ], i, H[ i ]+dist[i], colorRed, colorYellow );
}

_SECTION_END();
``````

Can you pls clarify what you’re attempting to achieve. I think what you’ve said is the following: your current chart is set to 15minutes interval, and you want to put a visual indication on it, when a particular formation (“Morning Star”) occurs on a more detailed timeframe.

The following two statements from your post above, concern me:

if the timeframe is 5 min, and their is a crossover in Stoch RSI in hourly timeframe, it will show me an arrow in 5 min

if the Timeframe in use is 15minutes, I want to show an up arrow there, indicating a morning star is formed in 5min interval.

If I reinterpret them:

1. On a chart with a 5-minute interval, show an arrow when there is a crossover in the “Stoch RSI” on the same interval, ie. 5 minutes.
2. On a chart with a 15-minute interval, show an arrow when there is a “Morning Star” on the 5-minute interval.

If you meant “5-minute” and not “15-minute” for the second requirement, then pls restate which one it is, so that we don’t make assumptions.

If the second requirement is indeed what you want, then I think you need to have another read of the AB User Manual – sometimes it can be a little cryptic, and needs some re-reading and experimenting to fully understand what’s possible. The following extracts come from “Multiple Time Frame support in AFL” in the AB User Manual:

For example if you need to calculate 13-bar moving average on 5 minute data and 9 bar exponential avarage from hourly data while current interval is 1 minute

Just one function call to retrieve price from higher time frame.

The following simple exploration shows what happens after you switch to a higher timeframe. Run Exploration on current symbol, all quotations, periodicity set to daily and you will see how "weekly close compressed" column contains empty values at the beginning and weekly compressed data at the end of array.

If you read them carefully, you’ll see that they all suggest that it’s only possible to “draw down”/ import/ use data from a longer interval, on a shorter one, eg. using data from a daily interval on a chart set to 1-hour is Ok/ permitted, but not the other way around.

My Requirement is

If the Interval() is set to 5min (I am watching this interval), and a candle pattern is formed in 15mins,
I should know while reading the 5min chart(Using current chart) that a pattern is in progress in 15min chart.

My real problem starts when I check for a Morning Star Pattern, using a 15min Open/Close. I get a Boolean array of True/False. I can not TimeframeCompress / TimeframeExpand operations on it to show it in 5min chart.

Did it make sense?

If everything about the morning star is in 15min TF, you don't need to get each price in 5min.
Your computation wont meet the logic anyway.

Why don't you do the whole thing in 15m like this?

``````TimeFrameSet( in15Minute );

Pb2O = Ref( C, -2);    // O two bars ago
Pb2C = Ref( C, -2);    // C two bars ago
Pb1O = Ref( O, -1);    // O prev bar
Pb1C = Ref( C, -1);    // C prev bar

MS = Pb2C < Pb2O AND Pb1O < Pb2C AND Pb1C < Pb2C AND O > Pb1C
AND C > (Pb2C + Pb2O)/2 AND Pb1O == Pb1C;

TimeFrameRestore();    // Back to normal 5m TF

``````

The unfortunate part is none of my 5m/15m data had a +ve morning star pattern so you have to test it yourself.
Liquid instruments intraday in the age of HFT rarely do this for bluechips / liquid instruments.

I used to spend time watching the algo keep tweaking its bid or sell price almost every tic with same qty and only 1 bidder/seller at that price.

By the way, every function call you make has an overhead. If you are going to use the same code a few times, use a variable instead.

Oops I think I missed the last line

``````// Continuation
TimeFrameRestore();

MS = TimeFrameExpand( MS, in15Minute, expandPoint);
PlotShapes( Nz( MS)*shapeHollowSmallUpTriangle, colorBlue, 0, L);
``````