# Moving Averages: Difference between Crossing over and Greater than

#### stormy77

##### Member
I may be missing something. can anyone explain why the condition "crossing over" is different than "is greater than" in ToS scan option?
For example, the scan for "when 50 sma crosses over 150 sma" produces different results than "when 50 sma is greater than 150 sma"
There is a big difference in scan results. Since Tos gives both options, I'm assuming there is a difference

Solution
A script where the candle is colored:
Blue = moving average 21 crosses above moving average 8​
Magenta = moving average 21 crosses below moving average 8​
Ruby:
``````AssignPriceColor(
if FastMA crosses above SlowMA  then color.blue else
if FastMA crosses below SlowMA then color.magenta else color.current) ;``````
The result is ONE candle is colored where the exact cross took place. The "cross" is the beginning and end of the trend.

A script where the candle is colored:
Blue = moving average 21 is greater than moving average 8​
Magenta = moving average 21 less than moving average 8​
Ruby:
``````AssignPriceColor(
if FastMa is greater than SlowMa then color.blue else color.magenta) ;``````
The result ALL candles are colored...
A script where the candle is colored:
Blue = moving average 21 crosses above moving average 8​
Magenta = moving average 21 crosses below moving average 8​
Ruby:
``````AssignPriceColor(
if FastMA crosses above SlowMA  then color.blue else
if FastMA crosses below SlowMA then color.magenta else color.current) ;``````
The result is ONE candle is colored where the exact cross took place. The "cross" is the beginning and end of the trend.

A script where the candle is colored:
Blue = moving average 21 is greater than moving average 8​
Magenta = moving average 21 less than moving average 8​
Ruby:
``````AssignPriceColor(
if FastMa is greater than SlowMa then color.blue else color.magenta) ;``````
The result ALL candles are colored when greater than

If you scanned for greater than, you would get all results above, even if you were at the end of the trend.

87k+ Posts
317 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?