First candle 60min bullish and cross(ma5,ma20) at lower time frame

Dear all,
I am a newbie in afl programming.
I want to show (Explore) a list of stocks whose first candle 60minute (new day) is bullish and cross ma5,ma20 in 5minute time frame.

I tried like this:

_SECTION_BEGIN("MA's Crossing when 1st candle 60m Bull");

dt = DateTime();
tn = TimeNum();
nd = Day() != Ref(Day(), -1);

ValueMin = 5000000000; //5B

TimeFrameSet( inDaily ); // switch now to Daily
ValueTrx = ((LastValue(O)+LastValue(H)+LastValue(L)+LastValue(C))/4) * LastValue(V); 
//Calculate value transaksi	
TimeFrameRestore(); // restore time frame to original
/// Expansion AFTER TimeFrameRestore
ValueTrx = TimeFrameExpand(ValueTrx,inDaily);

TimeFrameSet( inHourly ); // switch now to Hourly
Bullish = ((Close - Open)/Open) * 100 > 5; //Body candle more than 5% 
Mom_P = ((Close - Open)/Open) * 100;

TimeFrameRestore(); // restore time frame to original

Bullish = TimeFrameExpand(Bullish, inHourly);
Mom_P = TimeFrameExpand(Mom_P, inHourly);

gc = Cross(ma5, ma20);

Filter = Bullish AND gc AND ValueTrx>ValueMin; 



When i run explore in 5minute time frame the result are still not as expected

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.