Long term trading strategy - Stock sreener

raj_hpking

Well-Known Member
#1
Hi,

How can I write AFL to scan stocks for below requirement,

1) Stock with weekly MACD HISTOGRAM is above 0 line. I.e. UP
2) With daily MACD HISTOGRAM is below 0 line but heading towards line 0.

This is very simple strategy that I read in one of the book. This strategy is called seasonal strategy and best suit for swing to long term traders.


I need afl to scan such stock. How can I write. Any help would be greatly appreciated.
 

raj_hpking

Well-Known Member
#2
Hi, What is wrong with below AFL for above requirement,

TimeFrameSet(inWeekly);
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

ml = MACD(r1, r2);
sl = Signal(r1,r2,r3);
Hist = ml-sl;

condition1 = Hist > Ref(Hist,-1); //MACD Histogram should be above line 0.

TimeFrameRestore();

TimeFrameSet(inDaily);

r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

ml = MACD(r1, r2);
sl = Signal(r1,r2,r3);
Hist = ml-sl;

condition2 = Hist < Ref(Hist,-1); //MACD Histogtram should be below line 0.

TimeFrameRestore();

Filter=TimeFrameExpand(condition1 AND condition2,inDaily);
 

suri112000

Well-Known Member
#3
Hi, What is wrong with below AFL for above requirement,

TimeFrameSet(inWeekly);
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

ml = MACD(r1, r2);
sl = Signal(r1,r2,r3);
Hist = ml-sl;

condition1 = Hist > Ref(Hist,-1) AND Hist>0;
//MACD Histogram should be above line 0.

TimeFrameRestore();

TimeFrameSet(inDaily);

r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );

ml = MACD(r1, r2);
sl = Signal(r1,r2,r3);
Hist = ml-sl;

condition2 = Hist > Ref(Hist,-1) AND Hist < 0;
//MACD Histogtram should be below line 0.

TimeFrameRestore();

Filter=TimeFrameExpand(condition1 AND condition2,inDaily);
Addcolumn (C, "close");
I think it should work now.
 

raj_hpking

Well-Known Member
#4
No, it is still not giving the expected result.
 

Similar threads