| Registered User Joined: 10/6/2014
 Posts: 34
 
 | 
	Hi, 
	I have an indicator A that on the graph that has a value of 1 or 0.  
	Starting from the first bar onward, 
	I want to code an indicator D that plots 1 when A=1, however filters out when A=1 the next 20 days and resets, so after 20 days, when A=1, D=1 again, and then filter another 20days and so forth. My code looks like this 
	  
	'# Youx = chart.YouxiaoguodingA   (this is indicator A) 
	Dim TempA as single 
	Dim D as integer 
	Dim C as integer 
	Dim i as integer 
	TempA = Youx.value 
	D =0 
	C=0 
	i=0 
	While true 
	if tempA = 1 
	D=1 
	while c<20 
	i = i-1 
	c=c+1 
	D=0 
	end while 
	else 
	i= i-1 
	end if 
	tempA = Youx.value(i) 
	end while 
	Plot = D 
	  
	However this code freezes the software and won't load results.  
	Is it because I didn't start from the first bar in this code? or what problems is it?  
	Or what coding can achieve my goal?  
	  
	Thank you. 
	  |