vars:line15(0),line30(0);
line15=Average(close,15);
line30=Average(close,30);
condition1=o<c and o=l and h>c and h-c>c-o and (h-c)/(c-o)>=1.1;//red
condition2=o>c and c=l and h>o and h-o>o-c and (h-o)/(o-c)>=1.1;//green
condition3=o>c and o=h and l<c and h-c<c-l and (c-l)/(o-c)>=1.1;//green
condition4=o<c and c=h and l<o and c-o<o-l and (o-l)/(c-o)>=1.1;//red
if marketposition=0 and condition1 then sellshort("S1") next bar market;
if marketposition=0 and condition2 then sellshort("S2") next bar market;
if marketposition=-1 and c<entryprice and entryprice-c>=0.1 then buytocover next bar market;
if marketposition=-1 and c>entryprice and c-entryprice>=0.1 then buytocover next bar market;
if marketposition=0 and condition3 then buy("B1") next bar market;
if marketposition=0 and condition4 then buy("B2") next bar market;
if marketposition=1 and c>entryprice and c-entryprice>=0.1 then sell next bar market;
if marketposition=1 and c<entryprice and entryprice-c>=0.1 then sell next bar market;