Hi,
I am using below AFL for buy and sell alert for price crossing study line. When I am using it with a single line it is working fine, but when I use it with rectangle box study it is not showing correct. Sometime it shows only the top line of Y axis cross or sometime it is showing only the lower line crossing.
I think it is due to the rectangle has values of startY and endY coordination. I tried to write with the help of Getting X, Y co-ordinates of Study() but I am unsuccessful.
I need the alert if:
- When the price touches the bottom line of rectangle (start Y)
- When the price is trading within the rectangle range (between start Y and end Y)
- When the price crossed the top line (end Y).
_SECTION_BEGIN("TL cross B/S");
SU = Study("SU", ChartID=1327 );
RE = Study("RE", ChartID=1327 );
//trendlineS = Study("SU", GetChartID() );
//trendlineR = Study("RE", GetChartID() );
//StartY = LastValue( ValueWhen( ExRem( trendlineS, 0 ), trendlineR ) );
//EndY = LastValue( ValueWhen( trendlineR, trendlineS ) );
Buy= Cross(SU, L);
Sell= Cross(H, RE);
Filter=Buy OR Sell;
AlertIf( Buy, "SOUND C:\\Windows\\Media\\Windows Ringin.wav", "Audio alert", 2 );
AlertIf( Sell, "SOUND C:\\Windows\\Media\\Windows Ringin.wav", "Audio alert", 2 );
//PlotShapes(shapeUpArrow*Buy,colorGreen,0, L,-10 );
//PlotShapes(shapeDownArrow*Sell,colorRed,0, H,-10 );
AddColumn( IIf(Buy,C,IIf(Sell,C,Null)) ,"S and D touch",1.0,colorWhite,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack)));
_SECTION_END();