StockFetcher Forums · Filter Exchange · A set of trading rules regarding SPY and SH :<< 1 2 3 4 >>Post Follow-up
cidrolin
21 posts
msg #119273
Ignore cidrolin
modified
4/30/2014 6:05:22 AM

Ive started with Stratasearch looking for trading rules regarding SPY and SH tickers.
Basically, I was looking for a trend following model : I study the period 2007-2014, and I choose that we were in bear market when MA(index(^spx,close),15)) > MA(index(^spx,close),200)). Bull market was then defined by MA(index(^spx,close),15)) < MA(index(^spx,close),200)). My idea was that the market has two differents moods : bear and bull and that it is possible to find simple yet effective trading rules in these two moods. It will have only one position at time, SPY, SH or cash.

BearSystem -- when MA(index(^spx,close),15)) < MA(index(^spx,close),200)) :
The Chaikin money flow index was a great indicator of entry and exit regarding SPY and SH. I end up with entry when CMF(14) < 0 and exit when CMF(14) > 0.
Entry Stratasearch code :
// 1) Bearish
(mov(symbol(^spx,close),15,Simple) < mov(symbol(^spx,close),200,Simple)) and
// 3) Chaikin Money Flow
(cmf(14) < 0)


Exit Stratasearch code :
// 1) Bearish
(mov(symbol(^spx,close),15,Simple) > mov(symbol(^spx,close),200,Simple)) or
// 3) Chaikin Money Flow
(cmf(14) > 0)


BullSystem -- when MA(index(^spx,close),15)) > MA(index(^spx,close),200)) :
The Avg Directional Movement was a good indicator of entry and exit regarding only SPY. Given the strong up bias in bull market, I cannot find any effective way of trading SH. Combining Avg Directional Movement of SPY with Qstick position of ^VIX was then very effective.

Entry Stratasearch code :
// 1) Bullish
(mov(symbol(^spx,close),15,Simple) > mov(symbol(^spx,close),200,Simple)) and
// 2) Avg Directional Movement
(adx(8) > pdi(8) or adx(8) > mdi(8)) and
// 3) Qstick VIX
(symbol(^VIX, qst(10)) < 0)


Exit Stratasearch code :
// // 1) Bullish 15 200
(mov(symbol(^spx,close),15,Simple) < mov(symbol(^spx,close),200,Simple)) or
// 2) Avg Directional Movement
(adx(8) < pdi(8) and adx(8) < mdi(8))




Here the result :
Bull Bear Equity

Bull Bear Report

Values are quite robust : if you change numerical values in trading rules, you doesn't change so much the results. However, this strategy doesn't work well prior 2008.


Any comments, thoughts and criticism are welcome.

NOTE1: it appears that Stratasearch is computing ADX, PDI and MDI as integers. I'm investigating if it's a feature or a bug in SS. I then don't want / be able to post Stockfetcher filters at this time.


gmg733
623 posts
msg #119276
Ignore gmg733
modified
4/30/2014 8:39:49 AM

I take it this is somewhat of a manual process? When 15MA is over 200MA you run the bull signal and vice versa? Or is this part of one strategy in SS? Market orders?

Did you try variable settings to find the optimal settings over your time of reference?

So far it looks pretty damn good to me.

Thanks for sharing.



cidrolin
21 posts
msg #119282
Ignore cidrolin
4/30/2014 9:28:41 AM

This strategy switches between SPY SH and cash (no holding).

The numerical values were optimized over this time frame : as previously said, if you change numerical values in trading rules, you doesn't change so much the results.

No leverage used, and you enter and exit at the opening of the next day.

For Stratasearch, I use a multisystem with "BullSystem" over SPY + "BearSystem" over SPY and SH.

cidrolin
21 posts
msg #119283
Ignore cidrolin
4/30/2014 9:29:59 AM

By the way, I am looking for a way to round to the nearest integer in stockfetcher...

cidrolin
21 posts
msg #119284
Ignore cidrolin
modified
4/30/2014 11:01:02 AM

I figure it out.
Here is a SF filter to enter (buy SPY) and exit (sell SPY) when market is Bull.

Fetcher[symlist(SPY)
draw ma(15)
draw ma(200)
set{isBull, count(ma(15) > ma(200),1)}
set{isBear, count(ma(15) < ma(200),1)}
add column isBull
set{qstickvix, IND(^VIX,QStick(10))}
set{buy0,count(qstickvix < 0,1)}
set{buy1,count(round(ADX(8)) > round(PDI(8)),1)}
set{buy2,count(round(ADX(8)) > round(MDI(8)),1)}
set{buy3,buy1 + buy2}
set{buy4, buy3 * buy0}
set{buy5, buy4 * isBull}
set{buy_to_open,count(buy5 > 0,1)}
draw buy_to_open
add column buy_to_open
set{sell1,count(round(ADX(8)) < round(PDI(8)),1)}
set{sell2,count(round(ADX(8)) < round(MDI(8)),1)}
set{sell3,sell1 * sell2}
set{sell4, sell3 + isBear}
set{sell_to_close,count(sell4 > 0,1)}
draw sell_to_close
add column sell_to_close
]



I think that the boolean algebra is OK, bu I have a trouble. I think it's related to ADX calculation.

SS buy SPY from 02/10 to 03/28, but as you can see SF from 02/10 to 03/25.... SF always exit a trade before SS does.

I must think about it.


gmg733
623 posts
msg #119285
Ignore gmg733
4/30/2014 11:15:00 AM

Nice work. Does the 'sell' mean long SH or short SPY?

cidrolin
21 posts
msg #119287
Ignore cidrolin
4/30/2014 11:31:18 AM

When you're in "BullSystem", you only consider SPY.

So buy means "buy to open SPY" and sell means "sell to close SPY".

I edit the previous post.

dashover
166 posts
msg #119289
Ignore dashover
4/30/2014 2:04:07 PM

Does the system on SS list the actual trades and dates etc?



gmg733
623 posts
msg #119290
Ignore gmg733
4/30/2014 2:39:59 PM

Making sense now. Sorry.

Looks good so far. But I haven't dug into it too much.

My assumption is you will probably create a new filter for the bear market or somehow incorporate into this one. I see you have the logic in the beginning (bull vs bear), but you are only looking for SPY only in the symlist. As you stated before, you have three possible positions, SPY, SH or cash.

Thanks.

cidrolin
21 posts
msg #119295
Ignore cidrolin
5/1/2014 6:06:46 AM

The fastest way is use to use 2 filters.

BullSYSTEM :
Only active when boolean isbull is true.
You buy to open SPY at the next open following buy_to_open signal.
You sell to close SPY at the next open following sell_to_close signal.
You can have no position open (so being in cash).

Fetcher[symlist(SPY)
draw ma(15)
draw ma(200)
set{isBull, count(cma(ind(^SPX,close),15) > cma(ind(^SPX,close),200),1)}
set{isBear, count(cma(ind(^SPX,close),15) < cma(ind(^SPX,close),200),1)}
add column isBull
set{qstickvix, IND(^VIX,QStick(10))}
set{buy0,count(qstickvix < 0,1)}
set{buy1,count(round(ADX(8)) > round(PDI(8)),1)}
set{buy2,count(round(ADX(8)) > round(MDI(8)),1)}
set{buy3,buy1 + buy2}
set{buy4, buy3 * buy0}
set{buy5, buy4 * isBull}
set{buy_to_open,count(buy5 > 0,1)}
draw buy_to_open
add column buy_to_open
set{sell1,count(round(ADX(8)) < round(PDI(8)),1)}
set{sell2,count(round(ADX(8)) < round(MDI(8)),1)}
set{sell3,sell1 * sell2}
set{sell4, sell3 + isBear}
set{sell_to_close,count(sell4 > 0,1)}
draw sell_to_close
add column sell_to_close
]



BearSYSTEM :
Only active when boolean isbear is true.
You buy to open SPY or SH at the next open following buy_to_open signal.
You sell to close SPY or SH at the next open following sell_to_close signal.
You can have no position open (so being in cash).

Fetcher[symlist(SPY,SH)
draw ma(15)
draw ma(200)
set{isBull, count(cma(ind(^SPX,close),15) > cma(ind(^SPX,close),200),1)}
set{isBear, count(cma(ind(^SPX,close),15) < cma(ind(^SPX,close),200),1)}
add column isBear
set{buy1,count(cmf(14) < 0,1)}
set{buy2, buy1 * isBear}
set{buy_to_open,count(buy2 > 0,1)}
draw buy_to_open
add column buy_to_open
set{sell1,count(cmf(14) > 0,1)}
set{sell2, sell1 + isBull}
set{sell_to_close,count(sell2 > 0,1)}
draw sell_to_close
add column sell_to_close
]



I will think if I can combine it into a single filter

StockFetcher Forums · Filter Exchange · A set of trading rules regarding SPY and SH :<< 1 2 3 4 >>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 2016 - 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