cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a way to write a rule where the majority of subrules are true?

wwasilev
Making moves

Hi,

Just returned to TS and I'm trying to code a rule where over the last X bars, price was above EMA 20 for X-Y times - where X-1, or X-2 etc.

On another site, they support a looping rule;

LoopSum("Close(CTR)>SMA(20,0)",10) for example. LoopSum counts the number of time the condition in quotes is true. CTR is a private variable inside LoopSum and the second arg specifies the number of times to loop.

So if I wanted to screen for a stock that closed above SMA20 at least 7 times over the last 10 days, this would work;

LoopSum("Close(CTR)>SMA(20,0)",10)>=7

Can I do the same in TS?

Best,

Walter

0 REPLIES 0