# 200(SMA) or 55(MovExp) touch the current bar low

#### Stockmarker

##### Member
Hi Friends, Good evening !
Just a quick question, How do I write a scan when the 200 SMA touch the closing candle ( Just wanted to display the results if the SMA touch the low wick of the candle)

Example :

I was able to display the results when the 200 SMA touch last closed candle low wick, However, it displays even the 200 SMA touch the body.

The following scan I'm doing with the current setup:

Setting up a scan using SMA length 200 between SMA 1 open price and SAM 1 low price

I get the expected results for the positive closure by using the above scan... if it is closing negative getting false signal as I uses open.

Two scenarios:
1) If the closing candle is showing positive closure which has low wick , open, close, high wick(From the bottom). the result should display only 200 SMA touch low wick of the candle
2) if the closing candle is showing negative closure which has high wick,open, close, low wick (from the top), looking for only 200 sma touch low wick of the candle.

Pls. suggest ! Thanks in advanced.

Last edited:
you stated

"(Just wanted to display the results if the SMA touch the low wick of the candle)"

you can just use the wizard

price --> low ---> is equal to -----> study -----> moving average ---> 200

Thanks both of you for the response and help !
Sorry for not keeping the code which is being used...

Example : I just tested the following scenario using the following code but no luck.

1) low is equal to MovAvgExponential("price" = LOW, "length" = 55)."AvgExp"

2) low is equal to MovAvgExponential("price" = CLOSE, "length" = 55)."AvgExp"

3) low is equal to MovAvgExponential("price" = OPEN, "length" = 55)."AvgExp"

In this example: I'm looking for the results if the AvgExp 55 touch low wick of the candle (Not the body or high wick)..
If I look @ BL ticker , I see that Exponential Moving average 55 touch low wick of the candle. Here is the screen shot.

Add the TOS scan study filter below and play with the parameters. It works. Good luck.

MovingAvgCrossover(crossingType = "below")

cabe1332

Thanks for response Cabe! I used the following study which is showing BL . However it shows if the 55 line touch the body as well.

if you dont want the body touching, then what you mean to say is that you want the

CLOSE to be greater than the moving average.
Low is equal to the moving average

Thanks both of you for the response and help !
Sorry for not keeping the code which is being used...

Example : I just tested the following scenario using the following code but no luck.

1) low is equal to MovAvgExponential("price" = LOW, "length" = 55)."AvgExp"

2) low is equal to MovAvgExponential("price" = CLOSE, "length" = 55)."AvgExp"

3) low is equal to MovAvgExponential("price" = OPEN, "length" = 55)."AvgExp"

In this example: I'm looking for the results if the AvgExp 55 touch low wick of the candle (Not the body or high wick)..
If I look @ BL ticker , I see that Exponential Moving average 55 touch low wick of the candle. Here is the screen shot.

I used the same which you suggested in the last reply (low is equal to ) , don't want to keep less than as it display other tickers as well.

that will make it so the low, or the low wick is touching and EXACTLY equal to the 55 EMA
Code:
``low is equal to MovAvgExponential("length" = 55)."AvgExp"``

if your expecting to use this with a live scanner as a watchlist beware that the scanner only updates once every 3 to 5 mins and you will most likely miss when when the scan becomes true.

that will make it so the low, or the low wick is touching and EXACTLY equal to the 55 EMA
Code:
``low is equal to MovAvgExponential("length" = 55)."AvgExp"``

if your expecting to use this with a live scanner as a watchlist beware that the scanner only updates once every 3 to 5 mins and you will most likely miss when when the scan becomes true.

Thanks for your information. I'm using for Day chart... I tried to do with mentioned study..

Just to say , I'm able to get the list if I use the following code.

Need to find out the current candle status whether it is closed positively or negatively compare with previous day.

1) IF it is positive close(compare with previous day candle) :

a) Scan would be : Moving Average 55 between SMA1 open and SMA1 low (it display if the 55 touch the low wick of the candle)

2) If it is negative close (compare with previous day)

a) Scan would be : Moving Average 55 between SAM1 close and SAM1 low (it display the correct value)

If we don't have any other solution , I think the above cases should work.

Here is the question :

How do I include or do check if the candle is positive or negative with previous candle.

Last edited:
Just to say, I see the solution would be we need to verify whether the current candle closed (postievly or negative) wiht previous day.

Thanks for your information. I'm using for Day chart... I tried to do with mentioned study..

Just to say that,, I'm able to get the list if I use the following code.

Need to find out the current candle status whether it is closed positively or negatively compare with previous day.

1) IF it is positive close:

a) Scan would be : Moving Average 55 between SMA1 open and SMA1 low (it display if the 55 touch the low wick of the candle)

2) If it is negative close (compare with previous day)

a) Scan would be : Moving Average 55 between SAM1 close and SAM1 low (it display the correct value)

If we don't have any other solution , I think the above cases should work.

Here is the question :

How do I include or do check if the candle is positive or negative with previous candle.

@Stockmarker add a study filter on your watchlist under price performance then choose "Price_Direction". You can place with the parameters. Good luck.

cabe1332

Thanks Cabe for your information and help!
I'm still not able to get correct results... I tried to use the following scan which display the tickers if 55 Movavg touch body of the candle also.

Example: AFRM.

@Stockmarker Try using crosses above within x bars and less than now type logic... Either your logic is wrong or the concept is beyond the capabilities of TOS... At any rate you have to test a price against MA more than one way on a single candle, if possible...

@Stockmarker Try using crosses above within x bars and less than now type logic...

Sorry, I don't get it using crosses above, could you pls. explain little more on it?

@Stockmaker I think you are looking at this all wrong which perhaps you didn't catch in my last post... Price touches MA, not MA touches Price... This is especially true the slower timeframe you work with... Go at this the right way and I think you will have better luck... I don't want to show you the code, I want you to work through the logic and come up with the result you desire... You'll learn more that way rather than me handing you working code... Change your train of thought and you'll get there...!!!
Thanks Rad for the offer. Happy to learn from you and community.

I tried with the following code.

"low is less than or equal to MovAvgExponential("price" = close, "length" = 55)."AvgExp""

(I used is "equal to" or "equals" in the code, it doesn't show up any results)

The above scan display the ticker which I'm looking for, and it shows some other tickers which I don't want as those tickers are not fall under my criteria .

Example : BL (this ticker is good ( the last candle low tickers touch 55 MA))
BLK ( the above displays this ticker as well as the 55 touch the body)

Still working on to see if I get the correct scan (if I'm doing wrong)

Thanks Rad for the offer. Happy to learn from you and community.

I tried with the following code.

"low is less than or equal to MovAvgExponential("price" = close, "length" = 55)."AvgExp""

(I used is "equal to" or "equals" in the code, it doesn't show up any results)

The above scan display the ticker which I'm looking for, and it shows some other tickers which I don't want as those tickers are not fall under my criteria .

Example : BL (this ticker is good ( the last candle low tickers touch 55 MA))
BLK ( the above displays this ticker as well as the 55 touch the body)

Still working on to see if I get the correct scan (if I'm doing wrong)
For time being, having the following code in the custom scan:

For the uptrend candle:

Code:
``````def sma200=MovAvgExponential("length" = 200)."AvgExp";
def smalow= SimpleMovingAvg("price" = LOW, "length" = 1)."SMA";
def smaopen= SimpleMovingAvg("price" = OPEN, "length" = 1)."SMA";

def up=sma200 between smalow and smaopen;

plot up1=up is true within 1 bar;``````

For the negative candle:

Code:
``````def sma200=MovAvgExponential("length" = 200)."AvgExp";
def smalow= SimpleMovingAvg("price" = LOW, "length" = 1)."SMA";
def smaopen= SimpleMovingAvg("price" = CLOSE, "length" = 1)."SMA";

def up=sma200 between smalow and smaopen;

plot up1=up is true within 1 bar;``````

As suggested by Ben, I may reach out to support team for this query.

Thanks and appreciated everyone for all help and information. Happy to be part of this group. Cheers.

Hi Everyone ! Good evening !
Sorry to trouble you, if I wanted to display the result set with the following code for the previous day?

Code:
``````declare lower;
def sma200=MovAvgExponential("length" = 200)."AvgExp";
def sma50=MovAvgExponential("length" = 50)."AvgExp";
def sma20=MovAvgExponential("length" = 20)."AvgExp";

def up=sma200 between sma50 and sma20 from 1 bar ago;

plot X=up is true;``````

I tried to run the scan but it is displaying the current day tickers... I tried to display the tickers for previous day by running today if the above statement is true ? not sure if I'm missing anything here? Can you pls check for me ?

Hi Everyone ! Good evening !
Sorry to trouble you, if I wanted to display the result set with the following code for the previous day?

Code:
``````declare lower;
def sma200=MovAvgExponential("length" = 200)."AvgExp";
def sma50=MovAvgExponential("length" = 50)."AvgExp";
def sma20=MovAvgExponential("length" = 20)."AvgExp";

def up=sma200 between sma50 and sma20 from 1 bar ago;

plot X=up is true;``````

I tried to run the scan but it is displaying the current day tickers... I tried to display the tickers for previous day by running today if the above statement is true ? not sure if I'm missing anything here? Can you pls check for me ?

Never mind. I got the answer.

I shall put up[1] is true which resolved my case. Thanks.

Never mind. I got the answer.

I shall put up[1] is true which resolved my case. Thanks.
@Stockmarker glad you were able to get it working to your need. GL.

87k+ Posts
215 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?