tradearcher

Trade Archer - Moving Averages - v1.4F

Trade Archer Moving Averages has been updated!

Description:
Moving averages are one of the cornerstones to technical analysts tool box. There are several different kinds of moving averages of which the most common can be selected. Up to four moving averages may be configured and displayed with the option to show clouds between them. Additionally I have added a trend identification system that analyzes the slopes of the moving averages instead of relying on moving average cross overs for long/short signals.

Features:
- Multiple Moving Average Choices including: SMA , EMA, DEMA, TEMA, RMA, HMA, WMA, and VWMA.
- Four fully customizable MAs including length, color, and/or optional clouds between the MAs.
- Three ways to display MA trends: bar color, background and/or colored shapes.

Notes:
The default settings for the MA lengths are: 9, 19, 50, 200. MAs default to EMAs if none are selected.
If you use a blend of MAs, like SMA and EMA, you can apply the indicator again to the same chart and enable/disable the ones you want visible, their type, and trend display.

If you have any questions or need help configuring, feel free to contact me.

Good luck
Trade Archer
tradearcher@gmail.com
www.tradearcher.com
@tradearcher
Remove from Favorite Scripts Add to Favorite Scripts
//Created By User Trade Archer (Kevin Johnson)
//Last Update 8/4/2015
//Added support for SMA, EMA, DEMA, TEMA, WMA, HMA, RMA, and VWMA.  Defaults to EMA
//Note: If you make some neat additions, let me know.  Thanks & Enjoy

study(title="Trade Archer - Moving Averages - v1.4F", shorttitle="TA-MAs-v1.4F", overlay=true, precision=2)
  
//Collect source input and Moving Average Lengths
src = input(close, defval=close, type=source, title="Source:")
fast = input(9, minval=2, step=1, defval=9, type=integer, title="Fast MA Length")
medfast = input(19, minval=2, step=1, defval=19, type=integer, title="Medfast MA Length")
medslow = input(50, minval=2, step=1, defval=50, type=integer, title="Medslow MA Length")
slow = input(200, minval=2, step=1, defval=200, type=integer, title="Slow MA Length")

//Trend is based of combination of two MAs. Preferably MA1 length is shorter than MA2
ma1src = input(1, minval=1, defval=1, maxval=3, type=integer, step=1, title="MA1: (1) *Fast, (2)  MedFast, (3)  MedSlow")
ma2src = input(3, minval=2, defval=3, maxval=4, type=integer, step=1, title="MA2: (2)  MedFast, (3) *MedSlow, (4)  Slow")

//Coloring Options
usebg = input(true, defval=true, type=bool, title="Color Background of Trend")
usedots = input(true, defval=true, type=bool, title="Color Shape of Trend")
usebar = input(true, defval=true, type=bool, title="Color Bars of Trend")

//Set all MAs to a certain type
usesma = input(false, defval=false, type=bool, title="SMA")
useema = input(true, defval=true, type=bool, title="EMA (default)")
usedema = input(false, defval=false, type=bool, title="DEMA")
usetema = input(false, defval=false, type=bool, title="TEMA")
usewma = input(false, defval=false, type=bool, title="WMA")
usehma = input(false, defval=false, type=bool, title="HMA")
userma = input(false, defval=false, type=bool, title="RMA")
usevwma = input(false, defval=false, type=bool, title="VWMA")

//Functions
dema(s,l) => e1 = ema(s, l), e2 = ema(e1, l), out = 2 * e1 - e2
tema(s,l) => e1 = ema(s, l), e2 = ema(e1, l), e3 = ema(e2, l), out = 3 * (e1 - e2) + e3
hma(s,l) => out = wma( 2*wma(s, l/2)-wma(s, l), round(sqrt(l)) )
ma(s,l) => out = usesma ? sma(s,l) : useema ? ema(s,l) : usewma ? wma(s,l) : usehma ? hma(s,l) : userma ? rma(s,l) :
      usevwma ? vwma(s,l) : usedema ? dema(s,l) : usetema ? tema(s,l) : ema(s,l)
maSelect(c) => out = ma1src == 1 ? ma(src,fast) : ma1src == 2 ? ma(src,medfast) : ma1src == 3 ? ma(src,medslow) : ma1src == 4 ? ma(src,slow) : ema(src,50)
isLong = close > ma(src,50)
isShort = close <= ma(src,50)

//One time calculations
mafast = ma(src,fast)
mamedfast = ma(src,medfast)
mamedslow = ma(src,medslow)
maslow = ma(src,slow)

ma1check = maSelect(ma1src)
ma2check = maSelect(ma2src)

//plot MAs & save as variable
pfast = plot( mafast, linewidth=1, color=green, title="Fast MA" )
pmedfast = plot( mamedfast, linewidth=1, color=green, title="Medfast MA" )
pmedslow = plot( mamedslow, linewidth=2, color=red, title="Medslow MA" )
pslow = plot( maslow, linewidth=1, color=maroon, title="Slow MA" )

//fill between two emas
fquickcloud = fill(pfast, pmedfast, color=green, transp=90, title="Quick Cloud")
fnormalcloud = fill(pmedfast, pmedslow, color=yellow, transp=90, title="Normal Cloud")
fslowcloud = fill(pmedslow, pslow, color=red, transp=90, title="Slow Cloud")

//Converging and Diverging Conditionals
rfLength = 2
condcr1f2 = rising(ma1check,rfLength) and falling(ma2check,rfLength)  //condc1
condcf1r2 = falling(ma1check,rfLength) and rising(ma2check,rfLength)  //condc2

conddr1r2 = rising(ma1check,rfLength) and rising(ma2check,rfLength)   //condd1
conddf1f2 = falling(ma1check,rfLength) and falling(ma2check,rfLength) //condd2

upColor = lime
neColor = yellow
dnColor = red
//Color Trend of background, bar, or shapes
bgcolor(usebg and condcr1f2 or usebg and conddr1r2 ? upColor : usebg and condcf1r2 or usebg and conddf1f2 ? dnColor : usebg ? neColor : na, transp=90)
plotshape(usedots, style=shape.square, location=location.bottom, color=condcr1f2 or conddr1r2 ? upColor : condcf1r2 or conddf1f2 ? dnColor : neColor, title="Dots", transp=0)
barcolor(usebar and condcr1f2 or usebar and conddr1r2 ? upColor : usebar and condcf1r2 or usebar and conddf1f2 ? dnColor : usebar ? neColor : na)
Sweet! Nice work!
Reply
tradearcher PRO coondawg71
a year ago
Thanks.
I tried to make it simple, yet customizable.

Thanks for being patient.
Reply
tradearcher PRO coondawg71
a year ago
One potential sample configuration:

snapshot
Reply
Great display of moving averages with mutilple choices, love the clouds (great color choices) and cross over indications. However, I did notice there is an error in the code at line 40:

maSelect(c) => out = ma1src == 1 ? ma(src,fast) : ma1src == 2 ? ma(src,medfast) : ma1src == 3 ? ma(src,medslow) : ma1src == 4 ? ma(src,slow) : ema(src,50)

should be

maSelect(c) => out = c == 1 ? ma(src,fast) : c == 2 ? ma(src,medfast) : c == 3 ? ma(src,medslow) : c == 4 ? ma(src,slow) : ema(src,50)

otherwise the ma2 choice will always be 3 (which seems to be a good choice anyway).

I have used this moving average display with a MACD oscillator for confirmation with some success, still optimizing the settings though, I found the Hull MA to be particularly useful. I'm very new to binary trading/day trading, so I am still learning the art.
Reply
tradearcher PRO JustUncleL
a year ago
Thanks!

I try to make the colors intuitive and configurable for those that like to tweak it more or want another way to envision the trends.
I am glad you like it. Regarding maSelect(c), thanks! I will try and A/B test the two versions and see the difference when I get a chance.

Hull's is good as well. Responsive with controlled lag. Try a HMA50, to start, if looking for decent mid-term trends; then adjust as necessary.
What trading vehicles do you like to trade: equities, options, forex, futures... ?
Reply
JustUncleL PRO tradearcher
a year ago
The change I suggested also affects ma1 (it stays at 1 at the moment), so you will notice some differences. I current mostly trade forex pairs with very short trade durations 60 sec, 3min and 5min (I normally like 60sec). I'm using the setting (10, 20, 50, 200) with Hull MA and the MA(1,3) crossover highlighting (I find your color scheme great). I use MA clouds and indicators on 60sec trades, getting my signals from MACD(16,7,5) crossovers and using your MA chart with Bollinger(20,2) added for confirmation and trend directions, seems to work pretty good on forex pairs and some high volume stocks.
Reply
tradearcher PRO JustUncleL
a year ago
Sorry for not replying sooner. Slamming week from some other projects I am working on.

So MACD uses EMAs to derive their calculations. So I like to sync my charts with the same underlying calculations of MAs. For instance if I use standard MACD(12,26,9), with EMA calculation, I would do one of two things: (1) change my price MAs to EMA12 and EMA26 or (2) keep your current HMAs(10,20,50,200) and use a modified MACD that uses HMAs for their calculation. I find it helps with the timing, but your results may vary.

I plan on trying out your configurations as well. As I like learning how others visualize price/volume dynamics.
Reply
JustUncleL PRO tradearcher
a year ago
I tried both of your suggestions: suggestion (1) works OK but the EMA crossovers seem to lag too much compared to HMAs; suggestion (2) I created a modified version of ChrisMoody's "CM_MacD_Ult_MTF" using HMA instead of EMA, but so far I could not find the right settings to get the MACD crossovers matching trend change correctly. From my testing so far, the strategy I currently have; if I use the original "CM_MacD_Ult_MTF" with MACD(10,20,5) and use your HMA(10,20,50,200) to confirm and indicate exit points, this seems to work best for me. To make things cleaner I just cloud the HMA10 and HMA20 crossover and disable all other coloring, so that I only use the MACD for my entry signals and use HMA cross overs for confirmation and exit (when cross back again) and I also add the Bollinger(20,2) unclouded. I use the HMA50 and HMA200 for longer term trend directions. I also use your 4xMA clouds and indicator in some of my other strategies,
Reply
tradearcher PRO JustUncleL
a year ago
That was quick. I also have a customized MACD that I use. I also have an OBV with MAs for trending. I am curious as to what your screen looks like.
This is an example with the OBV MAs below and a Bull/Bear Strength at the top. For the Bull/Bear Strength, it's values range from 0 to 9, with 9 being most bullish and 0 as most bearish. It is a simple trend system that takes in account various different bullish indicators. Here is an example:

snapshot
Reply
FractalEyeZ
8 months ago
Nice work and thanks for this. Is there a way to make the background cloud plot two different colors depending on the direction of the trend? For example, I just want to use one instance of the indicator with 2 WMA's that crossover but I want the background cloud itself to change to a custom color of my choice on direction of the dominant trend. Maybe you could add a "Normal Cloud Up" custom color and a "Normal Cloud Down" custom color for example so the colors will change after the MA's crossover.

I have an indicator that does this for MT4 and I could post a picture of it so you can see what I mean if you need me to. It's some type of Filled Ribbon MA and if you set the thickness of the Lines to maximum it creates a filled in cloud with two colors that change when the trend changes. I just want my background to be light blue when the MA's cross up and a light gray when the MA's cross down.

snapshot
Reply
tradearcher PRO FractalEyeZ
8 months ago
Thanks for the feedback and comments. Excellent suggestion. I know what you are talking about with different colors for the zone between two MAs. I will try and update this weekend if I can find some time.
I have an OBV MA indicator as well.
Reply
FractalEyeZ tradearcher
8 months ago
Oh cool man, and thanks for all your efforts.

Enjoy your weekend :)
+1 Reply
tradearcher PRO FractalEyeZ
7 months ago
Sorry. Been a bit swamped. I have found similar code to it. Little more involved than I thought at first. But it is on my todo list as it is a useful feature.
Reply
tradearcher PRO tradearcher
7 months ago
Do you know how to add code to a current script? If so, append the color below to the current script.
It will do cloud color changes only for Fast and MedFast MAs. Tweak the indicator 'Style' options to
get your desired effect.

//Created By User Trade Archer (Kevin Johnson), 4/9/2016
// Quick Cloud Color Patch with Fast and MedFast MAs.
// Cloud Color Changes based on: CM_Enhanced_Ichimoku Cloud-V5
usecldchg = input(true, defval=true, type=bool, title="Cloud Color Change")
fastAbove = mafast >= mamedfast ? 1 : na
medfastBelow = mafast <= mamedfast ? 1 : na

s1plotU = fastAbove ? mafast : na
s2plotU = fastAbove ? mamedfast : na
s1plotD = medfastBelow ? mafast : na
s2plotD = medfastBelow ? mamedfast : na

col = fastAbove ? lime : red
sp1 = plot(usecldchg and s1plotU ? s1plotU : na, title='1', style=linebr, linewidth=2, color=col)
sp2 = plot(usecldchg and s2plotU ? s2plotU : na, title='2', style=linebr, linewidth=2, color=col)
sp3 = plot(usecldchg and s1plotD ? s1plotD : na, title='3', style=linebr, linewidth=2, color=col)
sp4 = plot(usecldchg and s2plotD ? s2plotD : na, title='4', style=linebr, linewidth=2, color=col)
//Fills that color cloud based on Trend.
fill(sp1, sp2, color=lime, transp=70, title='Above')
fill(sp3, sp4, color=red, transp=70, title='Below')
Reply
tradearcher PRO tradearcher
7 months ago
Here we go with a sample setup with Cloud Color Change.

snapshot
Reply
FractalEyeZ tradearcher
7 months ago
Thank you Kev, I really appreciate your efforts because I tried to figure it out last week but was just left scratching my head! I did look at CM's Ichimoku Cloud code but could not figure out how to properly re-code it. You programmer guys are really smart and I knew you would figure it out.

I pasted the new updated lines of code right beneath this line:

fslowcloud = fill(pmedslow, pslow, color=red, transp=90, title="Slow Cloud")

and it works perfectly! Now I have the best MA and can customize it how I want...nice :)

Mine are currently set to 21 and 63 WMA's and I'm really diggin' the purple and grey...hehehe!!!

So this is now version v1.4G right?

snapshot
Reply
tradearcher PRO FractalEyeZ
7 months ago
Thanks for the feedback. Looks great!
For version 1.4G or maybe 1.5, I will add it two the other two clouds that I have in the script. (My desire to be consistent).
You can also run multiple versions of the same indicator to filter the signals for a different perspective.

Which ever MA type that simplifies your visual analysis and increases your trading/investing success rate is the correct one.
To stay in sync with news and historical practices, I always have either EMA50 and EMA200 or SMA50 and SMA200. But that may not be the case with FX.
Reply
FractalEyeZ tradearcher
7 months ago
Good idea to use multiple versions of the same indi with different settings. I do that sometimes to make comparisons and get different perspectives.

May you have a great week of trading ahead. I'm about to start looking over my charts as we speak and see if I see anything interesting that may be setting up.
+1 Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out