NexusFi: Find Your Edge


Home Menu

 





Python dev trying to get started with thinkscript


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
CSharpTrader
Philadelphia, Pa/United States
 
Posts: 3 since Jan 2013
Thanks Given: 1
Thanks Received: 1

Traders, hello...

I have a TOS account, and I thought I'd deviate from my python work, to write some custom scan criteria within the platform. I've hit a bit of a wall; after a day of searching and reading the, uh, 'docs' I'm no closer to a solution. My question is:

In the scanner condition environment (99% of web examples seem to work with strategies), how does one refer to, or loop over (whatever the best way is) past bars?

I'm looking for a 50sma > 200sma over the past 100 days, and no closes below the 200sma over the same lookback. Should be pretty simple. I've tried 'fold' to no avail.. it seems to be a plotting- related function.

Can someone get me started in the right direction? It'd be huge. Thanks!


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
S&P 500 Holds the Line: No Fast Track for SpaceX, Op …
Stocks and ETFs
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Would a node-based workflow for automated trading be useful?
Traders Hideout
I Have a Thing Called Iran -- Trump Stays in DC as Airsp …
Prediction Markets & Event Contracts
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 growex 
Trubchevsk
 
Experience: Beginner
Platform: tos
Trading: stocks
Posts: 61 since May 2011
Thanks Given: 40
Thanks Received: 79

def avg50 = average(close,50);
def avg200 = average(close,200);
plot x = sum(close< avg200,100)==0 and sum(avg50 > avg200,100)==100;

it will check if close is equal to or greater than avg 200 for 100 days and if avg50 is greater than avg200 for 100 days


Follow me on X Reply With Quote
Thanked by:
  #3 (permalink)
CSharpTrader
Philadelphia, Pa/United States
 
Posts: 3 since Jan 2013
Thanks Given: 1
Thanks Received: 1


That is fantastic. Thank you so much...


Reply With Quote
Thanked by:




Last Updated on February 15, 2014


© 2026 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 - Downloads - Top
no new posts