StockFetcher Forums · Filter Exchange · PANGOLIN Z AND PANGOLIN W - FULL SYSTEM CODE | << 1 ... 4 5 6 7 8 ... 9 >>Post Follow-up |
agawfi 6 posts msg #123629 - Ignore agawfi |
4/23/2015 1:09:56 PM Hello Kevin, I have been monitoring the Pangolin Z for couple of months now and I noticed that the gains are much more robust and consistent when buying the respective stocks during or after a low ^SPX day (or SPY). So I used your exact code and only added one additional term: SPYCLOSE MORE THAN 1.5% BELOW SPYHIGH where SPYHIGH is SPY high 1 week high And as you mentioned in one of your older posts, Stock fetcher doesn't allow backtesting of your VAN THARP POSITION SIZING setup. So I simply assumed a constant position size and back tested it. The results were astonishingly superb with good gains and reasonable number of stocks (not too many to be overwhelmed with !) Start End Win% Lose% R/R ROI G/L DD MaxProf IndROI MarketVal AccntVal Amnt Inv. Comm. G/L UnrG/L 2013 2015 96.9 3.1 35.3 32.0 2.2 -4.0 4.1 22.9 11,968 59,160 14,114 1,745 12,192 (2,146) 2011 2013 94.3 5.7 10.07 33.1 2.8 -5.1 4.2 6.6 44,369 66,255 43,666 2,587 16,886 703 2009 2011 96.7 3.3 18.68 61.4 3.0 -4.4 4.5 20.2 23,042 67,884 23,595 2,766 19,843 (553) 2007 2009 89.3 10.7 1.33 7.4 0.8 -7.0 4.4 -17.9 15,503 42,348 24,202 1,548 1,844 (8,699) So you can see that the Win% are in the 90s in all cases and it is even possible to make money in 2008. Also, number of shares in all of the above 2-yr runs are on the range of 120 shares so about 5 shares per month which I find reasonable and not overwhelming and time consuming. I was wondering Kevin what is your take on this and if it is worthwhile investing more time to optimize the above addition to the filter as I only selected 1.5% arbitrarily. I tried 1% but it didn't give me the same results as above. I don't have the means or the skills to do monte carlo analysis in stratasearch as you do. So if you think it is worthwhile, I would be very keen to see what will be the optimized number and the expected returns of your code with this addition ? Thanks ! |
agawfi 6 posts msg #124233 - Ignore agawfi |
6/30/2015 5:20:35 PM Hi Kevin, I am learning SS and I was wondering if you can direct me where I can find the code you generated for Pangolin Z in SS ? I would appreciate your help ! Thank you |
Toad 20 posts msg #124234 - Ignore Toad modified |
7/1/2015 1:45:06 AM Just wanted to echo the sentiments of probably several people on this board and say thank you Kevin_In_GA...Stock Fetcher should really be giving you your subscription for free because you are a major reason I (and probably several other people) am testing them out. I am just getting my feet wet in trading and I really appreciate the level of detail you go into when you post your strategies. With so many different indicators to screen stocks by it is very easy to over fit test data to the point that the validation data goes to hell making the strategy useless...this is the main problem I have been having with my rudimentary excel testing over the past month. By basing the strategy in fundamentals as you do this seems to be largely avoided, so thank you! Hopefully in time I will be able to make contributions half as useful as yours, but until then I look forward to enjoying at least breaking even in the market. Also, I am interested in seeing the results of the back-testing of your modification in SS agawfi so please do post the results when you get this figured out. If nothing else, from your initial back-testing results it seems like this may be a useful way to go in on a larger position when your additional filter is met. *edit* I modified the filter a bit to automatically round the position size down to the nearest 5 shares (to increase the chance of being filled per Kevin_In_GA's recommendations in the original post...rounding down to prevent overcommitting the allocated funds) as well as to display the total profit target and max loss on the trade...I like to see those as a sanity check going in. I have posted my modified code below with the changed parts in bold. This only changes the display of the results, not the underlying strategy. Hope someone finds it useful. /*DEFINE THE MARKET*/ S&P 500 /*DETERMINE RATIO OF S&P STOCK TO THE ^SPX*/ SET{PRICERATIO, CLOSE / IND(SPY,CLOSE)} SET{RATIOMA20, CMA(PRICERATIO,20)} SET{RATIOSTD20, CSTDDEV(PRICERATIO,20)} SET{DIFF20, PRICERATIO - RATIOMA20} SET{ZSCORE20, DIFF20 / RATIOSTD20} /*DETERMINE THE MAXIMUM AMOUNT YOU ARE WILLING TO LOSE*/ SET{ACCOUNTSIZE, 10000} SET{RISKLEVEL, ACCOUNTSIZE*0.005} /*DETERMINE LIMIT ENTRY POINT*/ SET{LIMITENTRY, MIN(CLOSE, REVERSERSI(2,5))} /* VAN THARP POSITION SIZING - SET THE STOP LOSS AND SHARE SIZE BASED ON LIMIT ENTRY AND AMOUNT WILLING TO LOSE*/ SET{2ATR, 2 * ATR(20)} SET{STOPLOSS, LIMITENTRY - 2ATR} /*DETERMINE THE NUMBER OF SHARES TO BE PURCHASED*/ SET{SHARESTOBUY1, RISKLEVEL/2ATR} SET{SHARESTOBUY2, SHARESTOBUY1-2.5} SET{SHARESTOBUY3, SHARESTOBUY2/5} SET{SHARESTOBUY4, ROUND(SHARESTOBUY3, 0)} SET{SHARESTOBUY, SHARESTOBUY4*5} /*TOTAL AMOUNT OF EQUITY USED IN THIS TRADE*/ SET{POSITIONAMT, LIMITENTRY * SHARESTOBUY} /*PERCENT OF TRADING CAPITAL USED IN THIS TRADE*/ SET{POSITIONPCT1, POSITIONAMT / ACCOUNTSIZE} SET{POSITIONPCT, POSITIONPCT1 * 100} /*DETERMINE THE REWARD-TO-RISK RATIO BASED ON THE PROFIT TARGET AT RSI(2) = 90*/ SET{REWARD1, REVERSERSI(2,90) - LIMITENTRY} SET{REWARD, REWARD1 * SHARESTOBUY} SET{R_R, REWARD / RISKLEVEL} /*DETERMINE THE TOTAL POSITION TARGET PROFIT AND MAXIMUM LOSS*/ SET{TARGETPROFIT1, REVERSERSI(2,90)-LIMITENTRY} SET{TARGETPROFIT, TARGETPROFIT1*SHARESTOBUY} SET{MAXLOSS1, STOPLOSS-LIMITENTRY} SET{MAXLOSS, MAXLOSS1*SHARESTOBUY} /*SET THE CRITERIA NECESSARY TO TRIGGER A TRADE*/ COUNT(ZSCORE20 BELOW 0,4) ABOVE 3 LOW BELOW LOWER BOLLINGER BAND(10,2) CLOSE ABOVE MA(200) RSI(2) BELOW 15 /*FORMAT OUTPUT*/ ADD COLUMN RSI(2) ADD COLUMN ATR(20) {ATR(20)} ADD COLUMN SEPARATOR ADD COLUMN SHARESTOBUY {SHARES TO BUY} ADD COLUMN LIMITENTRY {LIMIT ENTRY} ADD COLUMN REVERSERSI(2,90) {TARGET SELL} ADD COLUMN STOPLOSS {STOP LOSS} ADD COLUMN R_R {REWARD-TO-RISK} ADD COLUMN POSITIONAMT {POSITION SIZE (DOLLARS)} ADD COLUMN POSITIONPCT {EQUITY (%)} ADD COLUMN TARGETPROFIT {TARGET PROFIT (DOLLARS)} ADD COLUMN MAXLOSS {MAX. LOSS (DOLLARS)} SORT ON COLUMN 12 DESCENDING DRAW PRICE LINE AT LIMITENTRY ON PLOT PRICE DRAW PRICE LINE AT REVERSERSI(2,90) ON PLOT PRICE DRAW RSI(2) LINE AT 5 DRAW RSI(2) LINE AT 90 DRAW BOLLINGER BANDS(10,2) DRAW ZSCORE20 LINE AT 0 CHART-TIME IS 3 MONTHS |
Kevin_in_GA 4,599 posts msg #124245 - Ignore Kevin_in_GA |
7/3/2015 10:14:45 PM Here is all the required code for this system in SS syntax. Hopefully this helps folks. Due to the way great than/less than symbols are also used to add HTML code for text, I have substituted the symbols with the words in bold. To use the code in SS replace them with the correct mathematical operators. The first two are custom formulas and need to be added into SS as custom formulas and NOT written into the entry or exit code. To do this, just RTFM or use the help function. +++++++++++++++++++ CUSTOM FORMULA TO CALCULATE THE Z-SCORE Formula name - Zscore parm1 = parameter("parm1"); spxclose = parameter("spxclose"); ratio = close / spxclose; ratioma = ratio - mov(ratio,parm1,simple); Zscore = ratioma / sdev(ratio,parm1); CUSTOM FORMULA TO CALCULATE THE REVERSE RSI FOR LIMIT ENTRY/EXIT Formula name - ReverseRSI RSIperiod = parameter("parm1"); RSIvalue = parameter("parm2"); ExpPer = (2* RSIperiod - 1); AUC = mov(if(close greater than ref(close,-1), close - ref(close,-1),0),ExpPer,exponential); ADC = mov(if(close less than ref(close,-1), ref(close,-1) - close,0),ExpPer,exponential); X = (RSIperiod - 1) * (ADC * RSIvalue/(100 - RSIvalue) - AUC); ReverseRSI = if(X greater than or equal to 0, close + X, close + (X * ((100 - RSIvalue)/RSIvalue))); ENTRY Another weird thing about HTML code - please insert "hadalert" (one word) in place of the two words in bold below had alert(Zscore(20,symbol(^spx,close)) less than 0,4) = 4 and rsi(2) less than 15 and low less than bbl(close,10,2) and close greater than mov(close,200,simple) EXIT - LIMIT ORDER high greater than reversersi(2,90) |
amtmail 34 posts msg #124348 - Ignore amtmail |
7/11/2015 1:05:49 PM Thank you Kevin for the help I sent you email , waiting for your opinion |
Kevin_in_GA 4,599 posts msg #124350 - Ignore Kevin_in_GA |
7/11/2015 6:54:29 PM AMTMAIL: I think that you are crossing a line into "overfitting" a backtest to get better results. It is important not to add in too many constraints or specific values - all too many people keep "tweaking" simple filters until they start to look contrived (example - price above upper Bollinger band (17,2.6) versus (20,2) because you got a slightly higher return). You have not used the above example, but I think you might see what I am trying to convey. If anything, you should take my filter and REMOVE lines of code to make it as simple as needed, but no simpler. All a good filter needs to do is beat the market while not exposing you to too much risk. That would be how I would improve these strategies - by reducing complexity and perhaps building in a trailing stop loss to reduce risk. |
amtmail 34 posts msg #124376 - Ignore amtmail |
7/14/2015 2:50:27 AM Thank you Kevin for your valuable advices about trading but can you please send me the code for this filter for SS |
Kevin_in_GA 4,599 posts msg #124378 - Ignore Kevin_in_GA |
7/14/2015 7:44:24 AM I posted the SS code for Pangolin Z on 7/3 - just a few posts above this one. If you mean you want me to recode the modified filter you sent into SS syntax, that is something for you to do, to learn how to write code in the new software. Also, it goes exactly against what I just said about how I would modify this code going forward. |
amtmail 34 posts msg #124386 - Ignore amtmail |
7/14/2015 7:01:01 PM Thank you , i mean the SS code for the old z- score filter |
Kevin_in_GA 4,599 posts msg #124387 - Ignore Kevin_in_GA |
7/15/2015 11:14:05 AM I posted this a while back. 6/3/2011 3:09:04 PM Kevin I have been working with Stratasearch for the past week or so after reading one of your post referencing it. Appears to be a powerful program ! I am still in the learning phase. How would you trade your SF code above? Exit ? ++++++++ The Zscore function I had to write as a custom function (not hard, as the SS coding language is not too complex). You can find it here: http://www.stratasearch.com/forum/viewtopic.php?f=3&t=950&p=4243#p4243 The entry code is: Zscore(16) < -2 and close > mov(close,200,simple) and wlr(16) < -94 and close < bbl(close,16,2) Exit code: Zscore(16) > -1 or $daysheld > 20 Kevin |
StockFetcher Forums · Filter Exchange · PANGOLIN Z AND PANGOLIN W - FULL SYSTEM CODE | << 1 ... 4 5 6 7 8 ... 9 >>Post Follow-up |
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