|
Public Formulas This is a growing list of formulas with open source code. To test formulas, simply click on the formula name. Please send us your feedback. We would like to hear from you.
|
COLOR_VOLUME This formula does not generate any signals. It demostrates the use of the function stickline(). You can modify the conditions and colors in the formula to see how it will affect the chart. stickline(close>=open,0,vol*1.0,1,0),color9999ff; stickline(close>=open,0,vol*0.8,1,0),color8888ff; stickline(close>=open,0,vol*0.6,1,0),color7777ff; stickline(close>=open,0,vol*0.4,1,0),color5555ff; stickline(close>=open,0,vol*0.2,1,0),color0000ff; stickline(close<open,0,vol*1.0,1,0),colorff9999; stickline(close<open,0,vol*0.8,1,0),colorff8888; stickline(close<open,0,vol*0.6,1,0),colorff7777; stickline(close<open,0,vol*0.4,1,0),colorff5555; stickline(close<open,0,vol*0.2,1,0),colorff0000; ma10: ma(vol,10); ma50: ma(vol,50); CSFR Find stocks which have been traded under 60-day moving average for at least 3 months and break out today with volume. This formula is highly reliable when the market starts warming up after a long downtrend. M := 20; # one month
N := 60; # one season
ma5 := ma(close, 5);
ma10:= ma(close, 10);
maN := ma(close, N);
cond := isup and
close > maN and
count(close > maN, 3*M) = 1 and
every(max(ma5, ma10) < maN, 3*M) and
between(close / ref(close, 1), 1.02, 1.25) and
vol > ma(vol, 50);
signal_csfr : cond;CYQK Croweded trading areas often serve as resistance or support. Thus when the price penetrates a crowded trading area, it is expected to see high volume. If the price goes through crowded areas on light volume, it is suspected that the stock is under the control of some big investors or even market makers. This formula draws a candlestick-like chart. The longer the candlestick is, the more the price has penetrated a crowded area. It further shows a smiling icon when the price range covers more than 18% of the captical (which is the total shares float) in a crowded area, while at the same time, the volume is just less than 1.5% of the capital. This formula is useful if you are analyzing small or medium cap stocks. cyqk_o := winner(o) * 100; cyqk_c := winner(c) * 100; cyqk_h := winner(h) * 100; cyqk_l := winner(l) * 100; top := max(cyqk_o, cyqk_c); bot := min(cyqk_o, cyqk_c); up := close >= ref(close, 1); down := not(up); pvol := if(capital = 0, 0, v/capital*100); stickline(up and c>=o, cyqk_o, cyqk_c, 1, 1), colorblue; stickline(up and c<o, cyqk_o, cyqk_c, 1, 0), colorblue; stickline(up, top, cyqk_h, 0, 0), colorblue; stickline(up, bot, cyqk_l, 0, 0), colorblue; stickline(down and c>=o, cyqk_o, cyqk_c, 1, 1), colorred; stickline(down and c<o, cyqk_o, cyqk_c, 1, 0), colorred; stickline(down, top, cyqk_h, 0, 0), colorred; stickline(down, bot, cyqk_l, 0, 0), colorred; drawicon(cyqk_h-cyqk_l > 18 and pvol <= 1.5, cyqk_l, 1), align1; CYS_OVERSOLD This is a short term trading formula and can be used to find stocks oversold. It looks for stocks where average shareholders have more than 10% loss in the past 10 trading days. This usually happens when the price drops down quickly on light volume. This formula is highly reliable when applied to stocks with market capital more than 10 bil. market_cap := finance("shares_outstanding")*close / 1000000000;
loss := 10;
days := 10;
cys := "cys"(days);
cond := market_cap > 10 and cys < -loss;
signal_cys_oversold: cond;DOJI Find candlestick patterns where open = close. Depending on the high and low values, the formula generates signals for different kinds of DOJIs. signal_doji : close = open and high > low; signal_four_price_doji : high = low; signal_dragonfly_doji : close = open and close = high and high > low; signal_gravestone_doji : close = open and close = low and high > low; signal_long_legged_doji : close = open and high/low > 1.03; ENGULFING This formula looks for candlestick patterns where a large white candlestick body engulfs a preceding small black candlestick (bullish engulfing), or a large black candlestick engulfs a preceding small white candlestick (bearish engulfing). Engulfing patterns can be useful reversal signals when they show up after a clear up/down trend. This formula includes some strict conditions and does not generate many signals. So do not be supprised if you can not find any matches when backtesting. You are encouraged to save this formula in your account so that we can use it everyday to scan stocks for you. top := max(open, close); bot := min(open, close); engulf := ref(high, 1) < top and ref(low, 1) > bot; signal_bullish_engulfing : engulf and ref(isdown, 1) and isup and "trend.down"(5, 20, 10, 0.8); signal_bearish_engulfing : engulf and ref(isup, 1) and isdown and "trend.up"(5, 20, 10, 0.8); FILLED_BLACK_CANDLES Look for one-day candlestick patterns characterized with a long black body having no shadows on either end. Filled black candle, also referred to as black marubozu, is an extremely strong bearish candlestick pattern. range := high - low; signal_filled_black_candles : open = high and close = low and range > ma(range, 10); HAMMER The hammer pattern is where after a bearish trend, a market moves significantly lower after the open, but rallies to close well above the intraday low. The inverted hammer pattern is a hammer which is upper side down. This formula looks for stocks with the hammer or inverted hammer patterns. range := high - low;
trend_down := "trend.down"(5, 20, 10, 0.75);
cond1 := high = max(open,close) and
high-low > 3.5*(high-min(open,close)) and
range > ma(range, 10) and
trend_down;
cond2 := min(open,close) = low and
high-low > 3.5*(max(open,close)-low) and
range > ma(range, 10) and
ref(trend_down, 1);
signal_hammer : cond1;
signal_inverted_hammer : cond2;HANGING_MAN Look for stocks which, after an advance, move significantly lower after the open, but rallies to close well above the intraday low. range := high - low;
cond := high = max(open,close) and
high-low > 3.5*(high-min(open,close)) and
range > ma(range, 10) and
ref("trend.up"(5, 20, 10, 0.75), 1);
signal_hanging_man : cond;HITW Find stocks which gapped down after a long up-trend. HITW, or Hole-In-The-Wall, is typically used to identify potential shorting opportunities. days:= barslast(high = hhv(high, 40) and "trend.up"(5, 20, 10, 0.9));
cond := days < 3 and
high < ref(low, 1) and
isdown;
signal_hitw : cond;HOLLOW_RED_CANDLES Look for one-day candlestick patterns characterized with a long white body having no shadows on either end. Hollow red candle, also referred to as white marubozu, is an extremely strong bullish candlestick pattern. range := high - low; signal_hollow_red_candles : open = low and close = high and range > ma(range, 10); MACD_CROSSOVER Find stocks where the macd diff line crosses above 0 and is above the signal line (bullish crossover), or the macd diff line crosses below 0 and is below the signal line (bearish crossover). diff := "macd.diff"(12, 26, 9); dea := "macd.dea"(12, 26, 9); signal_macd_bullish_crossover : cross(diff, 0) and diff > dea; signal_macd_bearish_crossover : cross(0, diff) and diff < dea; MACD_OVERBOUGHT Find stocks where the macd historgram (macd.macd) has been above 0 for the last 3 weeks and reached a new 6 month high today. macd := "macd.macd"(12, 26, 9); cond := every(macd > 0, 3*5) and macd = hhv(macd, 6*20); signal_macd_overbought : cond and every(vol > 20000, 20); MACD_OVERSOLD Find stocks where the macd historgram (macd.macd) has been below 0 for the last 3 weeks and reached a new 6 month low today. macd := "macd.macd"(12, 26, 9); cond := every(macd < 0, 3*5) and macd = llv(macd, 6*20); signal_macd_oversold : cond and every(vol > 20000, 20); RSI_CROSS_ABOVE_45 Find stocks which reached the 20-day lowest low in the past 5 days and has increasing price and volume for 2 days, its rsi just crossed above 45 today. You can set n:=60 to let the formula find less but more reliable signals. n := 20; rsi := "rsi"(14); days:= llvbars(low, n); increasing := close > ref(close, 1) and vol > ref(close, 2); cond := days < 5 and every(increasing, 2) and cross(rsi, 45); signal_rsi_above_45 : cond and every(vol > 20000, 20); WILLIAMS_R The Williams %R indicator was introduced by Larry Williams. It is working by identifying the overbought/oversold levels. The scale extends from 0 to -100. The overbought level is considered 0 to -20, and oversold -80 to -100. The formula generates williamsr_overbought signals when williamsr crosses above the line of -20, it generates williamsr_oversold signals when williamsr crosses below the line of -80. williamsr := "WMR"; # WMR is the name of Williams %R indicator in the system signal_williamsr_overbought : cross(williamsr, -20); signal_williamsr_oversold : cross(-80, williamsr); |