NexusFi: Find Your Edge


Home Menu

 





TOS Script (Code attached): Close inbetween 30 and 50 ma with 30ma<50ma<100ma


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
Morafi24
San Antonio
 
Posts: 1 since Oct 2020
Thanks Given: 0
Thanks Received: 0

Hello! I've been trying to make a TOS script which scans for stocks that close in between the 30 and 50ma without the price crossing the 50 ma. The price can also touch the 30ma. The moving averages cannot cross and the 30ma must be less than the 50ma which must be less than the 100ma. Here is my script so far. I thought it was right but every time I run it I get literally all the stocks in the market.

def ma30 = SimpleMovingAvg(close,30);
def ma50 = SimpleMovingAvg(close,50);
def ma100 = SimpleMovingAvg(close,100);
def trend = ma30 < ma50 < ma100;
def target = ma30 <= close < ma50;
plot scan = target;

I will also be doing one in reverse where the 30ma is greater than the 50ma which is greater than the 100ma.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Oil Surges ~18% in One Week as Iran Conflict Disrupts Gl …
Commodities
Tradeify 3.0 Overhauls Futures Prop Firm Model -- One-Ti …
Funded Trading Evaluation Firms
Kraken Becomes First US Digital Asset Bank With Direct F …
Cryptocurrency
Topstep Acquires The Futures Desk -- Prop Firm Consolida …
Funded Trading Evaluation Firms
Victory Day Delivers: Russia-Ukraine Ceasefire Market Cl …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 kjhosken 
Seattle, WA/USA
 
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
Posts: 96 since Sep 2016
Thanks Given: 7
Thanks Received: 35

TOS typically doesn't like multiple conditions strung together. So if you separate out your conditions with "AND" it should work.

 
Code
def ma30 = SimpleMovingAvg(close,30);
def ma50 = SimpleMovingAvg(close,50);
def ma100 = SimpleMovingAvg(close,100);
def trend = ma30 < ma50 and ma50 < ma100 and ma30 < ma100;
def target = ma30 <= close and close < ma50;
plot scan = target;


Follow me on X Reply With Quote
  #3 (permalink)
midpoint
Santa Clara, California
 
Posts: 2 since Sep 2012
Thanks Given: 0
Thanks Received: 0



Morafi24 View Post
Hello! I've been trying to make a TOS script which scans for stocks that close in between the 30 and 50ma without the price crossing the 50 ma. The price can also touch the 30ma. The moving averages cannot cross and the 30ma must be less than the 50ma which must be less than the 100ma. Here is my script so far. I thought it was right but every time I run it I get literally all the stocks in the market.

def ma30 = SimpleMovingAvg(close,30);
def ma50 = SimpleMovingAvg(close,50);
def ma100 = SimpleMovingAvg(close,100);
def trend = ma30 < ma50 < ma100;
def target = ma30 <= close < ma50;
plot scan = target;

I will also be doing one in reverse where the 30ma is greater than the 50ma which is greater than the 100ma.

plot scan = Close >= SimpleMovingAvg( close, 30 ) && Close < SimpleMovingAvg( close, 50 );


Reply With Quote




Last Updated on November 13, 2020


© 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