# How to write a code to screen stocks that are close to moving average

**URL:** <https://tradingqna.com/t/how-to-write-a-code-to-screen-stocks-that-are-close-to-moving-average/83618>\
**Category:** Streak - backtesting\
**Created:** [July 11, 2020, 10:10am UTC](https://tradingqna.com/t/how-to-write-a-code-to-screen-stocks-that-are-close-to-moving-average/83618 "2020-07-11T10:10:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![curiousvi](https://tradingqna.com/letter_avatar_proxy/v4/letter/c/50afbb/32.png) [@curiousvi](https://tradingqna.com/u/curiousvi)\
**Post date:** [July 11, 2020, 10:10am UTC](https://tradingqna.com/t/how-to-write-a-code-to-screen-stocks-that-are-close-to-moving-average/83618/1 "2020-07-11T10:10:24Z")

</div>

How to write stocks that are close or at the 50/100/200 moving average @Streak @portfolioplus911

---

<div class="post-metadata">

**Author:** ![Krishnendu](https://tradingqna.com/user_avatar/tradingqna.com/krishnendu/32/20265_2.png) [@Krishnendu](https://tradingqna.com/u/Krishnendu)\
**Post date:** [July 13, 2020, 9:13am UTC](https://tradingqna.com/t/how-to-write-a-code-to-screen-stocks-that-are-close-to-moving-average/83618/2 "2020-07-13T09:13:17Z")

</div>

There are lots of ways to do this.

What you need to understand is that all SMA/EMAs just like anything else that is plotted is just a number. I have created this for stocks trading within 3% from its 50 SMA.

 ![Screenshot_2020-07-13%20Streak%20Create%2C%20backtest%20and%20deploy%20trading%20strategies(1)](https://tradingqna.com/uploads/default/original/3X/4/0/40f9b7adeadd027c1fc258de9d7db96ed1edfd28.png)

You can add conditions for 100/200 SMA and play around with the percentage to set a range that you want.

---

<div class="post-metadata">

**Author:** ![Praneet\_Kumar](https://tradingqna.com/letter_avatar_proxy/v4/letter/p/7ea924/32.png) [@Praneet\_Kumar](https://tradingqna.com/u/Praneet_Kumar)\
**Post date:** [September 12, 2020, 11:30am UTC](https://tradingqna.com/t/how-to-write-a-code-to-screen-stocks-that-are-close-to-moving-average/83618/3 "2020-09-12T11:30:35Z")

</div>

thanks a lot. This was really helpful.

---

<div class="post-metadata">

**Author:** ![Wizard\_1819](https://tradingqna.com/user_avatar/tradingqna.com/wizard_1819/32/34411_2.png) [@Wizard\_1819](https://tradingqna.com/u/Wizard_1819)\
**Post date:** [September 23, 2020, 10:31am UTC](https://tradingqna.com/t/how-to-write-a-code-to-screen-stocks-that-are-close-to-moving-average/83618/4 "2020-09-23T10:31:40Z")

</div>

How to join Streak ? Platform looks very interesting to me.

---

<div class="post-metadata">

**Author:** ![ShubhS9](https://tradingqna.com/user_avatar/tradingqna.com/shubhs9/32/32667_2.png) [@ShubhS9](https://tradingqna.com/u/ShubhS9)\
**Post date:** [September 23, 2020, 10:35am UTC](https://tradingqna.com/t/how-to-write-a-code-to-screen-stocks-that-are-close-to-moving-average/83618/5 "2020-09-23T10:35:27Z")

</div>

You can visit [streak.zerodha.com](http://streak.zerodha.com)

---

<div class="post-metadata">

**Author:** ![Wizard\_1819](https://tradingqna.com/user_avatar/tradingqna.com/wizard_1819/32/34411_2.png) [@Wizard\_1819](https://tradingqna.com/u/Wizard_1819)\
**Post date:** [September 25, 2020, 10:50am UTC](https://tradingqna.com/t/how-to-write-a-code-to-screen-stocks-that-are-close-to-moving-average/83618/6 "2020-09-25T10:50:25Z")

</div>

thanks a lot for the reply
