I could use a little help with a scanner


Im using a combination of ADX trail stop/slim ribbons and 9sma
i have the full code for everything working fine as a strategy however when i try to convert to a scanner it doesnt seem to be 100 percent. if i ask it to show me things that are true within 2 bars it shows me things that dont meet or are too far out any help would be appreciated

input trailType = {default modified, unmodified};
input ATRPeriod =14;
input ATRFactor = 2.0;
def atr = Average(TrueRange(high, close, low), 14);
input averageType = AverageType.WILDERS;
input length = 14; #DI+- length
input adxlength = 20; #ADX sideways length

input SMA1_length = 12;
input displace = 0;
input price = close;
input crazyfast_length = 4;
input superfast_length = 8;
input fast_length = 13;
input slow_length = 21;

def exit = Average(price[-displace], SMA1_length);
def mov_avg4 = ExpAverage(price[-displace], crazyfast_length);
def mov_avg8 = ExpAverage(price[-displace], superfast_length);
def mov_avg13 = ExpAverage(price[-displace], fast_length);
def mov_avg21 = ExpAverage(price[-displace], slow_length);
def hiDiff = high - high[1];
def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

#def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def "DI+" = 100 * MovingAverage(averageType, plusDM, length) / atr;
def "DI-" = 100 * MovingAverage(averageType, minusDM, length) / atr;

def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
def ADX = MovingAverage(averageType, DX, length);

def bullentry = "DI+" >= "DI-" and ADX > 20;
def bearentry = "DI+" <= "DI-" and ADX > 20;
def arrow = (mov_avg4 > mov_avg8 and mov_avg8 > mov_avg13 and close > exit and bullentry is true);
plot bullish =arrow;
I don't have time to dig into your code right now but I can tell you I've experienced similar things with TOS scans. Generally it goes like this...
  1. Have code on a chart
  2. Copy that code into a scan
  3. Look through the scan results on the chart
  4. Notice some don't meet the criteria
  5. Double-check my scan code, timeframe, etc.
  6. Curse TOS

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
291 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.