StockFetcher Forums · General Discussion · Calculating a Total column<< >>Post Follow-up
glgene
616 posts
msg #40144
Ignore glgene
1/11/2006 2:05:31 PM

How do you put a "1" in a designated column if a certain condition is met, and how do you put a "0" in a designated column if a certain condition is not met?

Example: If a stock's fast MACD (12,26,9) is above its slow MACD, then put a "1" to a column (called MACD); otherwise it's a 0.

Or, if a stock's OBV is greater than 0, put a "1" in a column (called OBV); otherwise it's a 0.

Or, if a stock's close is above its 30-day EMA, put a "1" in that column (called Close); otherwise, it's a 0.

Finally, I need to calculate a total of these point columns (called Total), which in the above example if all conditions were positive, the total score would be 3. (Or it could be 0, 1, or 2).

I want to track 6-7 variables, so the Total would be a maximum of the number of variables.

Can anybody help me with this one? Thanks in advance.

GL Gene


nikoschopen
2,824 posts
msg #40148
Ignore nikoschopen
1/11/2006 2:58:51 PM

set{test, count(MACD fast line(12,26,9) crossed above MACD slow line(12,26,9),1)}
and Average Volume(90) is above 50000
and close is between 5 and 250
add column test


nikoschopen
2,824 posts
msg #40149
Ignore nikoschopen
1/11/2006 3:07:34 PM

The following should come close to what you're looking for:


set{test1, count(MACD fast line(12,26,9) crossed above MACD slow line(12,26,9),1)}
set{test2, count(OBV above OBV 1 day ago,1)}
set{test3, count(close above EMA(30),1)}
set{testsum1, test1 + test2}
set{testsum, testsum1 + test3}

and Average Volume(90) is above 50000
and close is between 5 and 250

add column testsum


alf44
2,025 posts
msg #40150
Ignore alf44
1/11/2006 3:07:46 PM

glgene,

Ya gotta use the "count" !

See below :

------------------

Fetcher[/* glgene's "Total" filter */

/* MACD check */
set{MACD_check, count(MACD(12,26,9) Fast Line is above MACD(12,26,9) Slow Line, 1)}

/* OBV check */
set{OBV_check, count(OBV is greater than 0, 1)}

/* EMA(30) check */
set{EMA30_check, count(Close is above EMA(30), 1)}

/* IndicatorFetcher */
set{MACD1, MACD_check * 1}
set{OBV2, OBV_check * 1}
set{EMA3, EMA30_check * 1}

/* FetcherSummation */
set{Total12, MACD1 + OBV2}
set{Total123, Total12 + EMA3}

Market is NASDAQ 100

/* Column Information */
add column MACD1
add column OBV2 {OBV1}
add column EMA3 {EMA1}
add column Total123 {Total}

sort column 8 descending
]



--------------------

Is that pretty much what you had in mind ?


Regards,

alf44


PS. I used NASDAQ 100 as a Stock Universe. You can obviously use whatever you wish !





nikoschopen
2,824 posts
msg #40151
Ignore nikoschopen
1/11/2006 3:11:03 PM

forgot to make it a hyperlink...

Fetcher[
set{test1, count(MACD fast line(12,26,9) crossed above MACD slow line(12,26,9),1)}
set{test2, count(OBV above OBV 1 day ago,1)}
set{test3, count(close above EMA(30),1)}
set{testsum1, test1 + test2}
set{testsum, testsum1 + test3}

and Average Volume(90) is above 50000
and close is between 5 and 250

add column testsum
]




glgene
616 posts
msg #40152
Ignore glgene
1/11/2006 3:30:34 PM

That's what I was looking for!! Thanks Alf and Niko. I assume I can use that on a Watchlist, too.




alf44
2,025 posts
msg #40155
Ignore alf44
1/11/2006 3:54:16 PM

...yep gene...

just include the phrase "apply to watchlist(whateverwatchlist)" !

You should be good to go !

Good Luck !


alf44




StockFetcher Forums · General Discussion · Calculating a Total column<< >>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.