Hi, i'm trying to add a Filter for an Exploration to this AFL,Seniors help me to code


_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Breakout periods best is usually 18",4,1,100,1,1);
Sellperiods=Param("Exit Breakout",7,1,100,1,1);

HaClose =EMA((O+H+L+C)/4,3); // Woodie 
//HaClose =(O+H+L+C)/4; 
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); 
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
HaLow = Min( L, Min( HaClose, HaOpen ) ); 
Buy= Cover= C>Ref(HHV(High,Buyperiods),-1);
Sell= Short= C<Ref(LLV(Low,Sellperiods),-1);

/* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -15);
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -10);
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -5);

PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorOrange, layer = 0, yposition = HaHigh, offset = -10);
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorOrange, layer = 0, yposition = HaHigh, offset = -15);
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorOrange, layer = 0, yposition = HaHigh, offset = -5);
SellPrice = ValueWhen( Sell, C, 1 );

BuyPrice = ValueWhen( Buy, C, 1 );

Long = Flip( Buy, Sell );

Shrt = Flip( Sell, Buy );
dist = 1.5*ATR(20); 
for( i = 0; i < BarCount; i++ ) 
{ 
if( Buy[i] ) PlotText("" + C[ i ], i, L[ i ]-dist[i], colorLime );
if( Sell[i] ) PlotText("" + C[ i ], i, H[ i ]+dist[i], colorRed ); } 

AlertIf( Buy, "SOUND C:\\Windows\\Media\\tada.wav", "Sell " + C,2,1+2,1);
AlertIf( Sell, "SOUND C:\\Windows\\Media\\chimes.wav","Buy " + C,1,1+2,1);
AlertIf( Short, "SOUND C:\\Windows\\Media\\tada.wav", "Short " + C,3,1+2,1);
AlertIf( Cover, "SOUND C:\\Windows\\Media\\chimes.wav","Cover " + C,4,1+2,1);

Filter=Buy OR Sell;

AddColumn( IIf(Buy,1,0), "signal",1.2,colorWhite,IIf (Buy,colorGreen,colorRed));
AddColumn (C,"current Price",1.2,colorWhite,IIf(C>Ref (C,-1)colorGreen,colorRed));
AddColumn (C,HHV(C,1),"HHV",1.2 colorWhite,IIf (C>(HHV(C,1),colorGreen,colorRed));
AddColumn (C,LLV(C,1),"LLV",1.2,colorWhite,IIf (C<(LLV(C,1),colorGreen,colorRed));

_SECTION_END();

If you are trying to add a filter, then why don't you lookup and learn about 'Filter'?
https://www.amibroker.com/guide/h_exploration.html

1 Like