Code: Select all
inputs: Price( Close ), Length( 9 ), Displace( 0 ) ;
variables: var0( 0 ) ;
Variables: TL(-1);
var0 = AverageFC( Price, Length ) ;
condition1 = Displace >= 0 or CurrentBar > AbsValue( Displace ) ;
if condition1 then
begin
Plot1[Displace]( var0, "Avg" ) ;
if Displace <= 0 then
begin
condition1 = Price crosses over var0 ;
if condition1 then
Alert( "Price crossing over average" )
else
begin
condition1 = Price crosses under var0 ;
if condition1 then
Alert( "Price crossing under average" ) ;
Once TL=TL_New_s(Date,Time_s,0,Date,Time_s,0);
TL_SetEnd_s(TL,Date[Displace],Time_s[Displace],Plot1 [Displace] );
TL_SetBegin_S(TL,Date[Displace+1],Time_s[Displace+1],Plot1[Displace+1]);
TL_SetExtRight(TL,true) ;
TL_SetStyle(TL, tool_dotted);
TL_SetColor(TL,darkgreen);
end;
end ;
end; [code]