StockFetcher Forums · General Discussion · how to uncover date of volume spike in the past<< >>Post Follow-up
5 posts
msg #124633
Ignore dajo117
8/10/2015 4:44:23 AM

Hi, this is my first post as a new SF subscriber. I am not a programmer.

As a swing-trader, I am trying to write a filter that (for a 6 month chart) :
a. shows a general uptrend left to right
b. then somewhere in the middle of the chart (around 5 weeks or more ago from right edge of chart?) shows a tight ranges for some weeks (4-10 weeks or so?)
c. then a volume spike (> 50% of average vol?)
d. accompanied by a tall range upcandle breakout ('trigger' candle) (close of trigger candle - upper limit of tight range is > 2 x average High-Low of past 10 candles in range?)
e. after trigger candle, candles move up to reach High1, and then retraces once to Low1 and then up again to High2 where High2 is > High1
f. then retraces down to Low2 which is below or near EMA(30) and where Low2 is > Low1
g (Note : this is where I can take a long position where position sizing will be based on 1% of capital = price x (Low 1-Low2) with Low 2 as my Stop-Loss and target profit = 3 x (Low1-Low2) OR
h. alternatively, I further screen for a most recent 'confirmation' up candle before I take a long position at close of the confirmation candle
g. further comments : price > 10, exclude ETFs, average vol > 200K

1st general question : I am facing the problem where I wish for the code to generate stocks whose charts "conceptually" fit the above idea and yet I find I am forced to write code that will likely omit stocks that don't fit EXACTLY FIT ALL the descriptive parameters of the above rules. Can anyone give me an idea of how to solve this in the world of programming?

2nd question : if someone can provide some code to help me get started for above, I would appreciate that.

3rd : I have reviewed the user guide cover to cover and cannot find any 'If, then" type code similar to excel. How do I write a code that goes like : "IF volume = 1.5 x average volume for past 10 candles within range that occurred 5 to 15 weeks ago, THEN generate when (i.e. the number of days when that breakout volume occurred) IF also accompanied by a trigger candle breakout (Note : I know this syntax is not SF code but I hope you can follow the Excel logic)

I hope I am making sense in my first post above. Thank you very much.

4 posts
msg #124637
Ignore wiglu
8/11/2015 4:07:27 PM

Here's an old manual someone put together in 2004 which provides capability to do if then and else. I only joined today and have been looking around for a couple of hours. The Stockfetcher manual seems very basic. However this 2004 one seems really helpful. It's no longer available on, but it was archived on the internet time machine and can be found at:

and here's the excerpt from that manual about if then else. You can find the full description under "boolean logic set".

4) **IMPORTANT** (IMHO) This technique also allows for
IF/THEN/ELSE!!! Let me use an example (NOT necessarilly a
good filter, but a good example!) to explain. Suppose you
want a volume condition, but the volume limit is to be based
on price. Let's say, if a stock's price is less than $5, you
want an average volume(30) of at least 100,000. For stocks >= $5,
you want the average volume(30) to be at least 250,000. Here's a
filter that illustrates how to achieve this:

set{if,count(price is less than 5,1)}
set{vol1,if * 100000}
set{else,1 - if}
set{vol2,else * 250000}
set{vol,vol1 + vol2}

price between 4.5 and 5.5
and average volume(30) is greater than vol

add column average volume(30)
add column if
add column else
add column vol1
add column vol2
add column vol

The first set{} will result in "if" being 1 if the price is
below $5, or 0 if the price is >= $5.

The second set{} command (and here's the trick) will result in
"vol1" being 100,000 if the price is below $5, or ZERO otherwise.
This is kinda like an AND, except the value you're looking for
won't be only zero or one.

The third set{} is really "NOT if", to be used for the "else"
part of the condition.

The fourth set{} uses the same trick as the second, resulting
in "vol2" being 250,000 or zero.

Note that "vol2" will be 250,000 ONLY when "vol1" is zero, and
"vol1" will ONLY be 100,000 when "vol2" is zero. That allows the
last set{} command to be our desired volume limit based on price!
(This is kinda like an OR, except using non-binary numbers.)

Oh, yeah. This is also a case where you might NEED the
implementation of AND described above, and NOT BE ABLE to use
SF's implementation. (Think "volume must be above 100,000 if price
is below 5 AND RSI(2) below 1, otherwise voume must be above 250,000".)

I hope this information is useful.

4 posts
msg #124638
Ignore wiglu
8/11/2015 4:16:42 PM

And to answer your other questions, I'd just start writing logic that fits very close to what you want to do. Then once you've done that and played around a little, you'll be able to make it more general.

I've just written 3 filters using tight criteria and am now experimenting with using some of the commands and indicators so I get more stocks come up. (And the last time I programmed was in Fortran at school 41 years ago.) So it's pretty easy.

I wouldn't ask someone to write your stuff yet. You've got to play around so you can understand it first.


5 posts
msg #124639
Ignore dajo117
8/12/2015 12:01:16 AM

Hi Wiglu,

I appreciate your help...Fortran at 41 years ago means I can take inspiration from you. I shall try to work out the code to get a semblance of what I want. Thanks so much!

5 posts
msg #124640
Ignore dajo117
8/12/2015 2:03:36 AM

Hi, well, below is what I have so far :

chart-time is 6 months
and price is above 20
and average volume (100) is above 200000
and chart-scale is logarithmic
and not ETF
show stocks where count (low is below or 1% above EMA (30), 3) 1 day ago is above 0
and close is above close 1 day ago
and MA(20) reached a new 3 month high within the last 5 weeks
and MA(50) reached a new 6 month high within the last 5 weeks
and MA(10) > MA(50) for the last 5 weeks
and add column industry
and add column sector

Above generated 38 stocks of which DY and GIII looked like a visual match of my 1st posting criteria above. I tried including syntax for the volume spike, price breakout and mid-chart ranging but then ended up either omitting DY or GIII or both depending on how stringent the code was. So not great in that I have to sift through 38 stocks to get just the 2 stocks I wanted - productivity-wise - but that's the outcome so far. Just an update.

P/S I tried to use MS Paint to paste DY and GIII SF charts into this message box but somehow the right click box kept showing the paste function as greyed-out so was not able to do so.

3,317 posts
msg #124650
Ignore four
8/12/2015 2:10:19 PM



Use StockFetcher "draw" feature... click: pencil button make comments and lines and then post image.

1. Click to view the chart. I clicked the 3m chart for SBUX
2 See image below


1. Save your image to your computer and then upload the image to a service-- something like tinypic AND then post the HTML code in the message. That's how I did the image below. PS I used the Windows Snipping Tool to grab the image and add notes.

SBUX - Starbucks Corporation (3m , 6m , 1y , 2y, historical)

Image and video hosting by TinyPic

5 posts
msg #124652
Ignore dajo117
8/12/2015 5:52:16 PM

Hi Four, thanks for your comments. But strangely, I didn't see an image in the post and when I clicked the link you attached, it led me to the tiny site but I didn't see a stock chart image there....

5 posts
msg #124653
Ignore dajo117
8/12/2015 5:54:24 PM

oops...not sure why; but after I posted the above, then suddenly the SBUX chart appeared...strange but anyhow, I appreciate the advice.

StockFetcher Forums · General Discussion · how to uncover date of volume spike in the past<< >>Post Follow-up

*** Disclaimer *** 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. does not recommend particular securities., 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