5528 visualizzazioni
CM_MTF ATR Bands/Stops
Many Options Available Via Input Tab:
-Chart Defaults to Upper and Lower ATR's Based on Current Chart TimeFrame
-Ability to Plot either Upper and/or Lower ATR's
-Ability to Change the Time Frame ATR's are Based On!
-Ability to change Look Back Period and ATR Multiplier Individually for Both Time Frames
-This Gives you the ability to plot same Time Frame with (for ex.) a 5 ATR with a 1.5 Mult and a 14 ATR with a 2.0 Mult etc.
-Or you can plot Daily ATR's on a 60 minute Chart etc.
-ATR Multipliers are Calculated with Code that allows "Non Whole Numbers" Allowing Ability to use 1.5 ATR's, 1.8 ATR's etc.
***Endless # of Combinations can be used!!!!
Many Options Available Via Input Tab:
-Chart Defaults to Upper and Lower ATR's Based on Current Chart TimeFrame
-Ability to Plot either Upper and/or Lower ATR's
-Ability to Change the Time Frame ATR's are Based On!
-Ability to change Look Back Period and ATR Multiplier Individually for Both Time Frames
-This Gives you the ability to plot same Time Frame with (for ex.) a 5 ATR with a 1.5 Mult and a 14 ATR with a 2.0 Mult etc.
-Or you can plot Daily ATR's on a 60 minute Chart etc.
-ATR Multipliers are Calculated with Code that allows "Non Whole Numbers" Allowing Ability to use 1.5 ATR's, 1.8 ATR's etc.
***Endless # of Combinations can be used!!!!
//Created By ChrisMoody on 11-20-2014 study(title="CM_MTF_AverageTrueRange_Stops", shorttitle="CM_MTF_ATR_Stops", overlay=true) length = input(5, minval=1, title="# of Bars to Calculate ATR") mult = input(15, minval=1, maxval=40, title="Value X .1, 10=1 (No Multiplier), 15=1.5 times ATR Value") sav = input(true, title="Show ATR Stop Above Price") sbv = input(true, title="Show ATR Stop Below Price") useCurrentRes = input(true, title="Use Current Chart Resolution?") resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="D") //Optional 2nd ATR Bands Inputs def = input(false, title="Optional 2nd ATR Bands - Inputs Below?") length2 = input(5, minval=1, title="# of Bars to Calculate ATR - Optional 2nd Bands Plot") mult2 = input(30, minval=1, maxval=40, title="Value X .1, 10=1 (No Multiplier), 15=1.5 times ATR Value - Optional 2nd ATR Bands Plot") sav2 = input(false, title="Show ATR Stop Above Price - Optional 2nd ATR Bands Plot") sbv2 = input(false, title="Show ATR Stop Below Price - Optional 2nd ATR Bands Plot") useCurrentRes2 = input(true, title="Use Current Chart Resolution - Optional 2nd ATR Bands Plot?") resCustom2 = input(title="Use Different Timeframe - Optional 2nd Bands Plot? Uncheck Box Above", type=resolution, defval="D") res = useCurrentRes ? period : resCustom res2 = useCurrentRes2 ? period : resCustom2 //Multiplier Calculation Xmult = mult * .1 //Optional 2nd Bands Xmult2 = mult2 * .1 //ATR Calculation with Multiplier atrMult = sma(tr, length) * Xmult outATR = security(tickerid, res, atrMult) //Optional 2nd Bands atrMult2 = sma(tr, length2) * Xmult2 outATR2 = security(tickerid, res2, atrMult2) //Values Above and Below Bars aboveStop = high + outATR belowStop = low - outATR //Optional 2nd Bands aboveStop2 = high + outATR2 belowStop2 = low - outATR2 ///Values Plotting chosen Chart Resolution aboveFinal = security(tickerid, res, aboveStop) belowFinal = security(tickerid, res, belowStop) //Optional 2nd Bands aboveFinal2 = security(tickerid, res2, aboveStop2) belowFinal2 = security(tickerid, res2, belowStop2) //plot Statements p1=plot(sav and aboveFinal ? aboveFinal : na, title="1st ATR Band Upper Plot1", style=linebr, linewidth=3, color=red) p2=plot(sbv and belowFinal ? belowFinal : na, title="1st ATR Band Lower Plot1", style=linebr, linewidth=3, color=lime) plot(sav and aboveFinal ? aboveFinal : na, title="1st ATR Band Upper Plot2", style=circles, linewidth=3, color=red) plot(sbv and belowFinal ? belowFinal : na, title="1st ATR Band Lower Plot2", style=circles, linewidth=3, color=lime) //Optional 2nd Bands p3=plot(sav2 and aboveFinal2 ? aboveFinal2 : na, title="2nd ATR Band Upper Plot1", style=linebr, linewidth=4, color=red) p4=plot(sbv2 and belowFinal2 ? belowFinal2 : na, title="2nd ATR Band Lower Plot1", style=linebr, linewidth=4, color=lime) plot(sav2 and aboveFinal2 ? aboveFinal2 : na, title="2nd ATR Band Upper Plot2", style=circles, linewidth=4, color=red) plot(sbv2 and belowFinal2 ? belowFinal2 : na, title="2nd ATR Band Lower Plot2", style=circles, linewidth=4, color=lime) fill(p1, p3, color=red, transp=80) fill(p2, p4, color=lime, transp=80)
I am newbie to trading.....And just now i watched a youtube video on this indicator(https://www.youtube.com/watch?v=3gNxBYL1oJU&%3Blist=PLP1qMpUAau2A3fWBSqYeKP3ZOR997VUWz&%3Bindex=1)by TTM..can you code it please for trading view community
Step 1
//Multiplier Calculation
Xmult = mult * .1
//Optional 2nd Bands
Xmult2 = mult2 * .1
The * .1 takes 15 and makes it 1.5 therefore if you changed it to .001 then the multiplier would need to be 1618
So end result would be
//Multiplier Calculation
Xmult = mult * ..001
//Optional 2nd Bands
Xmult2 = mult2 * .001
Step 2
In inputs section take the mult and mult2 Input and change the maxval setting from 40 to as high as you would want it, or you can take that parameter out all together. also set the default input to 1000 or so...or 1618 if thats the default setting your going to use.
End Result: Replace the first two lines in Inputs tab, and then the code a few lines below the inputs tab to this.
mult = input(1618, minval=1000, maxval=5000, title="Value X .1, 1000=1 (No Multiplier), 1618=1.618 times ATR Value")
mult2 = input(1618, minval=1000, maxval=5000, title="Value X .1, 1000=1 (No Multiplier), 1618=1.618 times ATR Value - Optional 2nd ATR Bands Plot")
//Multiplier Calculation
Xmult = mult * ..001
//Optional 2nd Bands
Xmult2 = mult2 * .001
Let me know if it doesn't work...but it should.
http://pastebin.com/ATzGn89L