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

Stockmarker

Member
VIP
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:

rad14733

Well-known member
VIP
@Stockmarker You didn't post any Thinkscript code but it sounds like you're almost there... Are you checking for close > open or close < open as part of your filtering...??? Is that the part you are missing...??? It would greatly help if you posted your working code, not a shared link...
 

XeoNoX

Well-known member
VIP
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
 

Stockmarker

Member
VIP
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.

 

cabe1332

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

MovingAvgCrossover(crossingType = "below")

Vbd4Xgs.png


cabe1332
 

XeoNoX

Well-known member
VIP
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
 

Stockmarker

Member
VIP
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.

Thanks for your response @XeoNoX

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.
 

XeoNoX

Well-known member
VIP
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.
 

Stockmarker

Member
VIP
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.



Thanks again for your help.
 
Last edited:

cabe1332

Member
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.



Thanks again for your help.

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

cabe1332
 

rad14733

Well-known member
VIP
@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

Member
VIP
@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...
Sure thanks !
Just to mention the ask again : Looking for the tickers(D timeframe ) where the 55 MA touch the ticker low wick (Not the body or high wick).
 

rad14733

Well-known member
VIP
@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...!!!
 

Stockmarker

Member
VIP
@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)
 

Stockmarker

Member
VIP
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.
 

Stockmarker

Member
VIP
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 ?

Thanks for your help in advanced.
 

Stockmarker

Member
VIP
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 ?

Thanks for your help in advanced.
Never mind. I got the answer.

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

Similar threads

Top