StockFetcher Forums · General Discussion · Can someone help me with a couple snippets of code?<< >>Post Follow-up
smartguy
47 posts
msg #148591
Ignore smartguy
7/19/2019 12:07:56 PM

I posted this thread here on stockfetcher https://www.stockfetcher.com/forums/General-Discussion/Combining-Trend-Following-and-Mean-Reversion-in-a-Scan-Need/148559
I was hoping someone might be able to help me with a couple snippets of code so I can try this, specifically these 2 snippets-

1. Close is less then most recent pivot point high for 3 (maybe 4 or more would work better) OR MORE days. This means it could be down 3 days, 4 days, 5 days etc. as long as its below recent pivot high and the moving averages are still stacked and sloped in an uptrend. This is the part I don't know how to code i.e. 3 or more days below the recent pivot point high while still having the 20ma above the 50MA and 20MA and 50MA above the 200MA

2.I also want to add a column to the scan showing distance of current price from recent pivot point high so that I can sort for largest difference in current price from the recent pivot high while still meeting the Trend Following portion of the scan. The assumption is the deeper the pullback while still in uptrend offers the best candidates to buy.
Thanks in advance for any help or guidance you can provide.

smartguy
47 posts
msg #148604
Ignore smartguy
7/20/2019 3:02:18 PM

Can someone tell me if these 2 snippets are at least possible with Stockfetcher. Maybe give me a few hints how I should go about it. Thanks in advance for any help given.

Village Elder
231 posts
msg #148605
Ignore Village Elder
modified
7/20/2019 4:12:33 PM

How are you defining pivot high? From pivot points or something else?

If from PPs, which one? There are at least two (R1, R2) above the central PP. Need more clarity on what you are asking for before folks can help.

Perhaps this?

1. Close is less then most recent pivot point high for 3 (maybe 4 or more would work better) OR MORE days. This means it could be down 3 days, 4 days, 5 days etc. as long as its below recent pivot high and the moving averages are still stacked and sloped in an uptrend. This is the part I don't know how to code i.e. 3 or more days below the recent pivot point high while still having the 20ma above the 50MA and 20MA and 50MA above the 200MA

Fetcher[
set{pphigh, pp 5 day high}
close below pphigh
ma(20) above ma(50)
ma(50) above ma(200)

draw pphigh on plot price
]



Have you any backtesting that indicates this approach provides a tradeable "edge" over just buying SPY?

smartguy
47 posts
msg #148607
Ignore smartguy
7/20/2019 6:30:05 PM

No, I have not back tested this method. It was suggested to me by another trader who I know is successful. I do not know how much this idea factors into his trading. That is why I wanted to put together a scan to see for myself. It does seem to make logical sense and buying pullbacks in a defined uptrend is logical also. Thus, a combination of trend following and mean reversion in one technique. Thank you for the code snippet.
You asked a question also that I didn't define for- a pivot point that is how many days along. Probably needs to be at least a 5 day highest high with a lower high on both sides of that pivot high.

StockFetcher Forums · General Discussion · Can someone help me with a couple snippets of code?<< >>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.