vancouver, canada
Posts: 1 since Oct 2015
Thanks Given: 0
Thanks Received: 0
|
Hello all,
I am trying to edit the think script code for scanning stocks based on compounded returns over a specific length but I can't seem to find a command that can simplify a sequence of time. To show you:
input price = close;
input percent = 19.8;
input Choice = {default greater, less};
input length = 10;
def z = length - 1;
def y = 100*((log(price[z]) - log(price[length])) + (log(price[z - 1]) - log(price[z])) + (log(price[z - 2]) - log(price[z - 1])) + (log(price[z - 3]) - log(price[z - 2])) + (log(price[z - 4]) - log(price[z - 3])) + (log(price[z - 5]) - log(price[z - 4])) + (log(price[z - 6]) - log(price[z - 5])) + (log(price[z - 7]) - log(price[z - 6])) + (log(price[z - 8]) - log(price[z - 7])) + (log(price[z - 9]) - log(price[z - 8])));
plot scan;
switch (Choice){
case greater:
scan = y >= percent;
case less:
scan = y <= -percent;
}
In essence, what is the command for this ? I would like to go out for further periods of defined lengths such as 1 year based on daily returns for example but I can't seem to find the resources for this on the Thinkscript tutorial website and I also tried to browse the web. I would greatly appreciate any help because once my lengths becomes specified for a period of 30 days or greater, then i receive an error where the command is too complex. It would make my life a lot easier if someone could help (as a side note, I would prefer to use daily cumulative returns here as opposed scaling out to larger time frames such as weekly or monthly. Having said that, knows a simplified method will also allow me to have the opportunity to scan stocks based on lower time frames.)
Thanks for reading
|