NexusFi: Find Your Edge


Home Menu

 





Python dev trying to get started with thinkscript


Discussion in ThinkOrSwim

Updated
    1. trending_up 5,616 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?
Trump Lands in Beijing on CPI Day: Iran Peace Expires To …
Prediction Markets & Event Contracts
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
Friday Update: Markets Now Pricing Fed Rate HIKES as Sta …
Traders Hideout
Thanks Mike. Godspeed.
The Elite Circle
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 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