I recently talked to a friend who sent me a thread on an SMA cross strategy dubbed "The System", by TraderBJones on twitter. There is a pdf written about it:
https://docs.google.com/presentatio...h2hMEFe7cFIU/edit#slide=id.g118a2787cc5_0_152
though the general strategies follow any typical moving average cross strategies you've seen.
The thread:
https://t.co/GmFVnoqPP9
I wanted to test this quick script, which plots the two SMAs -- according to the documentation, it should either be used on a 30-minute aggregation for intraday trading or daily for swings, so I allowed for MTF aggregation since we both trade on lower time frames. As an idea, I wanted to see if better entries or adding opportunities could be found by combining this with peaks and valleys, particularly those that qualified as market pullbacks (5% or more):
In general, this should be used to follow the rules of "The System" as it's written, but the identification of strong peaks during a bearish trend or strong valleys during a bullish trend within the system should allow for optimal entries in the direction of the System's trend, while the trend is still strong.
This is just a test script, so if anyone sees any promise in this you're welcome to improve it. Thanks to @halcyonguy for their incredible market pullback study: https://usethinkscript.com/threads/identifying-market-pullback-i-e-5.12744/#post-108853
https://docs.google.com/presentatio...h2hMEFe7cFIU/edit#slide=id.g118a2787cc5_0_152
though the general strategies follow any typical moving average cross strategies you've seen.
The thread:
https://t.co/GmFVnoqPP9
I wanted to test this quick script, which plots the two SMAs -- according to the documentation, it should either be used on a 30-minute aggregation for intraday trading or daily for swings, so I allowed for MTF aggregation since we both trade on lower time frames. As an idea, I wanted to see if better entries or adding opportunities could be found by combining this with peaks and valleys, particularly those that qualified as market pullbacks (5% or more):
In general, this should be used to follow the rules of "The System" as it's written, but the identification of strong peaks during a bearish trend or strong valleys during a bullish trend within the system should allow for optimal entries in the direction of the System's trend, while the trend is still strong.
This is just a test script, so if anyone sees any promise in this you're welcome to improve it. Thanks to @halcyonguy for their incredible market pullback study: https://usethinkscript.com/threads/identifying-market-pullback-i-e-5.12744/#post-108853
Code:
# The System
# By @TraderBJones on twitter
# Coded by Chemmy for useThinkScript.com
# corrections_peak_to_valley_00 portion credits
#https://usethinkscript.com/threads/identifying-market-pullback-i-e-5.12744/
#Identifying Market Pullback (i.e. 5%+)
# Thread starterscottsamesame Start dateToday at 9:01 AM
#.........................................
# ref: peak/valley code , robert post#10
# https://usethinkscript.com/threads/zigzag-high-low-with-supply-demand-zones-for-thinkorswim.172/#post-7048
#.........................................
# Inputs
input fast = 10;
input slow = 50;
input displace = 0;
input showBreakoutSignals = no;
input addlabels = yes;
input agg = aggregationPeriod.THIRTY_MIN;
def price1 = close(period=agg);
def price2 = close(period=agg);
## SMA plots
plot SMAFast = Average(price1[-displace], fast);
plot SMASlow = Average(price2[-displace], slow);
# Signals plots
plot UpSignal = SMAFast crosses above SMASlow;
plot DownSignal = SMAFast crosses below SMASlow;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
## Look and feel settings
SMAFast.SetDefaultColor(GetColor(1));
SMASlow.SetDefaultColor(GetColor(3));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
SMAFast.AssignValueColor(if SMAFast >= SMASlow then color.Light_Green else color.Light_Red);
SMASlow.AssignValueColor(if SMAFast >= SMASlow then color.Dark_Green else color.Red);
SMASlow.SetLineWeight(3);
AddLabel(addlabels, if SMAFast >= SMASlow then "System UP" else "System DOWN", if SMAFast >= SMASlow then color.green else color.red);
### Peak and Valley code
input min_percent_change = 5;
input length = 10;
def na = double.nan;
def bn = BarNumber();
def lastBar = HighestAll(if IsNaN(close) then 0 else bn);
def offset = Min(length - 1, lastBar - bn);
def peak = high > highest(high[1], length - 1) and high == GetValue(highest(high, length), -offset);
def valley = low < Lowest(low[1], length - 1) and low == GetValue(Lowest(low, length), -offset);
# set to 0 if peak and valley happen on same bar
def pv = if bn == 1 then 0
else if peak and valley then 0
else if peak then 1
else if valley then -1
else pv[1];
def peak2 = if bn == 1 then 0
else if peak and pv[1] != -1 then 0
else peak;
def valley2 = if bn == 1 then 0
else if valley and pv[1] != 1 then 0
else valley;
input color_peak_valley_bars = yes;
input color_remaining_bars = yes;
AssignPriceColor(
if (peak and color_peak_valley_bars) then Color.LIME
else if (valley and color_peak_valley_bars) then Color.magenta
else if (peak and !color_peak_valley_bars) then Color.current
else if (valley and !color_peak_valley_bars) then Color.current
else if color_remaining_bars then Color.DARK_GRAY
else color.current);
def peak_line = if bn == 1 then 0
else if peak2 then close
else if valley2[1] then 0
else peak_line[1];
def valley_line = if bn == 1 then 0
else if valley2 then close
else if peak2[1] then 0
else valley_line[1];
plot zp = if peak_line > 0 then peak_line else na;
zp.setdefaultcolor(color.red);
zp.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot zv = if valley_line > 0 then valley_line else na;
zv.setdefaultcolor(color.green);
zv.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
#----------------------------
input gain_drop_stats = yes;
def gain = if pv[1] == 0 then 0
else if peak2 then round(close - valley_line, 2)
else 0;
def gain_per = if pv[1] == 0 then 0 else round( 100 * gain/valley_line, 1);
def is_gain_big = (gain_per >= min_percent_change);
addchartbubble((gain_drop_stats and peak2 and valley_line > 0 and gain_per > 1.30), high,
gain + "\n" +
gain_per + " %"
, ( if is_gain_big then color.green else color.gray), yes);
#----------------------------
def drop = if pv[1] == 0 then 0
else if valley2 then round(peak_line - close, 2)
else 0;
def drop_per = if pv[1] == 0 then 0 else round( 100 * drop/peak_line, 1);
def is_drop_big = (drop_per >= min_percent_change);
addchartbubble((gain_drop_stats and valley2 and peak_line > 0 and drop_per > 1.30), low,
drop + "\n" +
drop_per + " %"
, ( if is_drop_big then color.red else color.gray), no);
#
AddLabel(yes, if (SMAFast >= SMASlow and zp < SMASlow) then "Poss. Entry on Pullback" else " ", if (SMAFast >= SMASlow and zp < SMASlow) then color.green else color.red);
AddLabel(yes, if (SMAFast < SMASlow and zv > SMASlow) then "Poss. Entry on Pullback" else " ", if (SMAFast < SMASlow and zv > SMASlow) then color.red else color.green);
#Alerts
Alert(UpSignal, "System Up!", Alert.Bar, sound.Ding);
Alert(DownSignal, "System Down!", Alert.Bar, sound.Ding);
# End Code
Last edited by a moderator: