01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | INPUT :M( 14 , 1 , 300 , 30 );
VARIABLE :ct:= 0 ,atrValue:= 0 ;
ma20: ma ( c , 20 );
ma60: ma ( c , 60 );
TR1:= MAX ( MAX (( HIGH - LOW ), ABS ( REF ( CLOSE , 1 )- HIGH )), ABS ( REF ( CLOSE , 1 )- LOW ));
ATR: MA (TR1,m);
majc: cross (ma20,ma60);
masc: cross (ma60,ma20);
if majc and holding = 0 then
begin
buy (majc and holding = 0 , 1 , market );
atrValue:=ATR;
end
if holding > 0 and ct<= 4 and ( c - ENTERPRICE )>=atrValue and atrValue<> 0 then
begin
buy ( 1 , 1 , market );
ct:=ct+ 1 ;
atrValue:=ATR;
end
if masc and holding > 0 then
begin
sell ( 1 , holding , market );
ct:= 0 ;
atrValue:= 0 ;
end
|