NexusFi: Find Your Edge


Home Menu

 





SMA down X% in X bars and price X% below SMA


Discussion in ThinkOrSwim

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




 
Search this Thread

SMA down X% in X bars and price X% below SMA

  #1 (permalink)
Brandonoh777
Indianapolis
 
Posts: 4 since Oct 2019
Thanks Given: 0
Thanks Received: 0

I am fairly good at backwards engineering code to do what i want with custom TOS scans but this one kinda has me stumped.... I want to look for ex. 21 period SMA 20% or more lower then 21 period SMA form 20 bars ago and.... price (low) is 10% or more below the current bar 21 period SMA

i would like to figure out the code for each condition individually then i can just add them both into my scann

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
About a successful futures trader who didnt know anythin …
Psychology and Money Management
 
  #2 (permalink)
Nube
Minneapolis Minnesota
 
Posts: 24 since Jul 2019
Thanks Given: 0
Thanks Received: 13


Brandonoh777 View Post
I am fairly good at backwards engineering code to do what i want with custom TOS scans but this one kinda has me stumped.... I want to look for ex. 21 period SMA 20% or more lower then 21 period SMA form 20 bars ago and.... price (low) is 10% or more below the current bar 21 period SMA

i would like to figure out the code for each condition individually then i can just add them both into my scann


 
Code
declare lower;

input length = 21;
input price = close;
input averageType = averageType.SIMPLE;
input compareToBarsAgo = 20;

def ma = MovingAverage(averageType, price, length);

plot MA_Condition = ma < ma[compareToBarsAgo] * .8; 
plot Price_Condition = low < ma * .9;

Reply With Quote
  #3 (permalink)
Brandonoh777
Indianapolis
 
Posts: 4 since Oct 2019
Thanks Given: 0
Thanks Received: 0



Nube View Post
 
Code
declare lower;

input length = 21;
input price = close;
input averageType = averageType.SIMPLE;
input compareToBarsAgo = 20;

def ma = MovingAverage(averageType, price, length);

plot MA_Condition = ma < ma[compareToBarsAgo] * .8; 
plot Price_Condition = low < ma * .9;

ok thanks ill try that!!! if its in a scan do i need the plot scan statement?

Reply With Quote
  #4 (permalink)
Brandonoh777
Indianapolis
 
Posts: 4 since Oct 2019
Thanks Given: 0
Thanks Received: 0


Nube View Post
 
Code
declare lower;

input length = 21;
input price = close;
input averageType = averageType.SIMPLE;
input compareToBarsAgo = 20;

def ma = MovingAverage(averageType, price, length);

plot MA_Condition = ma < ma[compareToBarsAgo] * .8; 
plot Price_Condition = low < ma * .9;

and in the future if i wanted to look at the flip side 21 period sma X % higher then 21 period sma form x bars ago i would change it to declare higher?

Reply With Quote
  #5 (permalink)
Brandonoh777
Indianapolis
 
Posts: 4 since Oct 2019
Thanks Given: 0
Thanks Received: 0


Nube View Post
 
Code
declare lower;

input length = 21;
input price = close;
input averageType = averageType.SIMPLE;
input compareToBarsAgo = 20;

def ma = MovingAverage(averageType, price, length);

plot MA_Condition = ma < ma[compareToBarsAgo] * .8; 
plot Price_Condition = low < ma * .9;

the OK button is grayed out

Attached Thumbnails
Click image for larger version

Name:	disk 6 error.jpg
Views:	191
Size:	72.6 KB
ID:	277904  
Reply With Quote




Last Updated on October 20, 2019


© 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