StockFetcher Forums · General Discussion · Is this correct?<< >>Post Follow-up
pa247
143 posts
msg #147948
Ignore pa247
5/29/2019 11:38:43 AM

I dont think im calculating this correctly. Can someone who is much smarter than I take a look please?

In the second step you calculate Drawdown Percent and square it:
DP = ((Close Max - Current Close) / Close Max * 100)^2


set{draw_down1, HC - close}
set{draw_down2, HC * 100}
set{draw_down3, draw_down1 / draw_down2}
set{dp, draw_down3 ^(1/2)}

nibor100
1,042 posts
msg #147952
Ignore nibor100
5/29/2019 2:38:21 PM

@pa247

a. What is 'HC' supposed to be? seems like it needs to be defined in its own set statement.

b. There are at least 2 ways to square a value in SF

1. use the power command (found in the announcements forum "Many More Math Functions")

set{dp, pow(draw_down3,2)}

2. set{dp, draw_down3 ^ draw_down3}

Hope this helps,
Ed S.


Village Elder
231 posts
msg #147953
Ignore Village Elder
5/29/2019 5:20:38 PM

2. set{dp, draw_down3 ^ draw_down3}

Nope - this raises draw_down3 to the power of draw_down3, not squaring it (unless by chance draw_down3 = 2)

Either use

(draw_down3)^2 or

draw_down3 * draw_down3

nibor100
1,042 posts
msg #147958
Ignore nibor100
5/29/2019 8:42:40 PM

Not sure how I got a caret in my previous post instead of an asterisk as my test code was:

"set{dr, .5 * 100} add column dr
show stocks where close is above 5.00 and add column pow(dr,2)
set{dr2, dr * dr} add column dr2"

but anyhow Village Elder is correct, it should be a multiplication asterisk for my example 2.

Sorry about that,
Ed S.

pa247
143 posts
msg #147963
Ignore pa247
5/30/2019 9:42:41 AM

@Ed and Village elder... thank you for help. I’m posting the whole filter Im trying to create as I’m still having a problem with step 3 coming out to zero, which is not correct and that causes step 4 to be wrong also.. I’ve read all through the forum and still don’t see where I’m going wrong. Help is appreciated.

market is nasdaq
market is not etf
close > 10
volume > 1234567
optionable
/* 1. First you have to get the maximum close price in the analyzed period:
Close Max = Highest Close in the selected period (p1) */

set{HC, max(high, close 14 days ago)}
/*set{HC,max close(14)} */
add column hc

/*2. In the second step you calculate Drawdown Percent and square it:
DP = ((Close Max - Current Close) / Close Max * 100)^2 */

set{draw_down1, HC - close}
set{draw_down2, HC * 100}
set{draw_down3, draw_down1 / draw_down2}
set{dp, draw_down3 * draw_down3}
add column draw_down3

/* 3. In the third step you apply simple moving average to the Drawdown percent with the same bar period which was used to get maximum close price:
DPma = SMA(DP, p1) */

set{dpma,cma(dp,14)}
add column dpma

/*4. In the last step you calculate UI as square root from smoothed Drawdown percent calculated in step #3:
UI = SQR(DPma) */

set{UI,cstddev(dpma)}
add column UI



nibor100
1,042 posts
msg #147965
Ignore nibor100
5/30/2019 10:00:43 AM

@pa247,

At first glance, it seems that you are getting the max of today's High price and the closing price of 14 days ago instead of the highest closing price of the past 14 days.

Also, it appears that at the end you are setting "UI" to be the custom standard deviation of 'dpma' and I believe you want to get the square root of 'dpma'

Later on today I'll see if I can modify your filter so it gets what you want.

Ed S.

nibor100
1,042 posts
msg #147966
Ignore nibor100
5/30/2019 11:02:52 AM

@pa247,

Is the filter below what you are after?

Ed S.

Fetcher[
market is nasdaq
market is not etf
close > 10
volume > 1234567
optionable

set{HC, close 14 day high} add column hc

set{draw_down1, HC - close}
set{draw_down2, draw_down1/HC }

set{draw_down3, 100 * draw_down2} add column draw_down3

set{dp, draw_down3 * draw_down3}

set{dpma,cma(dp,14)} add column dpma

set{UI,pow(dpma,0.5)} add column UI
]




bushynose
22 posts
msg #147967
Ignore bushynose
modified
5/30/2019 11:04:45 AM

Fetcher[
market is nasdaq
market is not etf
close > 10
volume > 1234567
optionable
/* 1. First you have to get the maximum close price in the analyzed period:
Close Max = Highest Close in the selected period (p1) */

set{HC, max(high, close 2 week high)}
/*set{HC,max close(14)} */
add column hc

/*2. In the second step you calculate Drawdown Percent and square it:
DP = ((Close Max - Current Close) / Close Max * 100)^2 */

set{draw_down1, HC - close}
set{draw_down2, HC * 100}
set{draw_down3, draw_down1 / draw_down2}
set{dp, draw_down3 * draw_down3}
add column draw_down3

/* 3. In the third step you apply simple moving average to the Drawdown percent with the same bar period which was used to get maximum close price:
DPma = SMA(DP, p1) */

set{dpma,cma(dp,14)}
add column dpma

/*4. In the last step you calculate UI as square root from smoothed Drawdown percent calculated in step #3:
UI = SQR(DPma) */

set{UI,pow(dpma,0.5)}

add column UI
draw UI
]

If you want the root of a function simply raise your measure to the decimal equivalent of its fraction. For example ...

the 1st root of the CLOSE = close^(1/1)
the 2nd (square) root of the CLOSE = close^(1/2)
the 3rd (cube) root of the CLOSE = close^(1/3)
the 4th root of the CLOSE = close^(1/4)


pa247
143 posts
msg #147984
Ignore pa247
5/31/2019 9:12:58 AM

@ Ed, Elder, Bushynose... Thank you for help and info. Working good now.

Paula

graftonian
1,089 posts
msg #147985
Ignore graftonian
5/31/2019 10:48:46 AM

My take on step 1:
Fetcher[
/* 1. First you have to get the maximum close price in the analyzed period:
Close Max = Highest Close in the selected period (p1) */
SYMLIST(SPY)
SET{X, CLOSE 14 DAY HIGH}
DRAW X ON PLOT PRICE
SET{HC, MAX(X, HIGH)}
DRAW HC ON PLOT PRICE ADD COLUMN HC
]



StockFetcher Forums · General Discussion · Is this correct?<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.