Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Filter coding Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
ansinzhou
Posted : Thursday, September 3, 2015 12:43:23 AM
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.

 

Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.