NexusFi: Find Your Edge


Home Menu

 





Help with a think script problem


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,197 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

Help with a think script problem

  #1 (permalink)
johnzhou20
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

Reply With Quote




Last Updated on November 29, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts