Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.56 KB | None | 0 0
  1. //@version=3
  2. //test
  3. //
  4. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ VOLATTITLITY PRICE ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  5.  
  6. sTitle = "Dynamic Support And Resistance "
  7. sShort = "📊 DSAR ®"
  8. sRelease = "2018-7-21"
  9. sOverlay = true
  10. sScale = scale.right
  11. sPrecision = 0
  12.  
  13. // strategy(title=sTitle+" [v"+sRelease+"]", shorttitle=sShort, overlay=sOverlay, scale=sScale, precision=sPrecision,
  14. // initial_capital=sInitial_capital, commission_value=sCommission_value, pyramiding=sPyramiding,
  15. // default_qty_type=sDefault_qty_type, default_qty_value=sDefault_qty_value, calc_on_order_fills=sCalc_on_order_fills)
  16.  
  17. study(title=sTitle+" [v"+sRelease+"]", shorttitle=sShort, overlay=sOverlay, scale=sScale, precision=sPrecision)
  18.  
  19.  
  20. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  21. // ?DEFAULT SETTINGS?
  22. //
  23. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  24.  
  25. defLongLen = 390
  26. defLongTF = 0
  27. defShortLen = 70
  28. defShortTF = 0
  29. //INPUTS
  30.  
  31. //INPUTS
  32.  
  33.  
  34.  
  35. defLongDev = "price"
  36. defLongDev1 = 1.28
  37. defLongDev2 = 2.01
  38. defLongDev3 = 2.51
  39. defLongDev4 = 3.09
  40. defLongDev5 = 4.01
  41.  
  42.  
  43. defShortDev = "price"
  44. defShortDev1 = 0.00
  45. defShortDev2 = 0.00
  46. defShortDev3 = 0.0
  47. defShortDev4 = 0.00
  48. defShortDev5 = 0.00
  49.  
  50. defShowLongBands = "[4] Standard to Bronze"
  51. defShowShortBands = "[4] Standard to Bronze"
  52.  
  53. defThemeLongShade = "Dark"
  54. defThemeColorAboveLong = "01 Red"
  55. defThemeColorBelowLong = "12 Blue"
  56. defThemeLongCenter = "Light Grey"
  57.  
  58. defThemeShortShade = "Dark"
  59. defThemeColorAboveShort = "01 Red"
  60. defThemeColorBelowShort = "12 Blue"
  61. defThemeShortCenter = "Light Grey"
  62.  
  63. defThemeMiniShade = "Dark"
  64. defThemeColorAboveMini = "01 Red"
  65. defThemeColorBelowMini = "08 Green"
  66. defThemeMiniCenter = "Light Cyan"
  67.  
  68.  
  69. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  70. // ?FUNCTION INPUTS?
  71. //
  72. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  73.  
  74. // VWAP Length (average over N bars back)
  75. longLength = input( title="Length (bars back)", type=integer, defval=defLongLen, minval=1 )
  76.  
  77. multiplier = input(1, minval=0,maxval=20, title="time multiplier")
  78. vol = volume
  79. src = close
  80. // Calculate Anchor Length Multiplier from Period
  81. func_intbyMints() =>
  82. intMints = 0.0
  83. intMints := isintraday ? interval :
  84. isdaily ? interval * 24 * 60 :
  85. isweekly ? interval * 7 * 24 * 60 :
  86. ismonthly ? interval * 4 * 7 * 24 * 60 : interval
  87. intMints // output
  88.  
  89. anchor = multiplier * func_intbyMints()
  90. mult = not interval or anchor==1 or interval>=anchor or anchor>10000 ? 1 : round(anchor/interval)>1? round(anchor/interval) : 1
  91. mult := interval or anchor==1 or interval>=anchor or anchor>1 ? mult: round(anchor/interval)>1? round(anchor/interval) : 1
  92. longerLength = mult==1 ? longLength : (longLength * multiplier)
  93.  
  94. sorce = input(defval=close, title='Source')
  95. fslen = input(defval=13, title='Fast Ma', minval=5)
  96. melen = input(defval=21, title='Medium Ma', minval=8)
  97. sllen = input(defval=34, title='Slow Ma', minval=13)
  98. brkfb = input(defval=1.13, title='Breaking', minval=0.62, step=0.02)
  99. multx = input(1,'Multiplier', minval=1)
  100.  
  101.  
  102. func_linx_WSMA(_val, _len) =>
  103. ema(_val, (_len*2)-1)
  104.  
  105. func_linx_TEMA(_val, _len) =>
  106. ema1 = ema(_val, _len)
  107. ema2 = ema(ema1, _len)
  108. ema3 = ema(ema2, _len)
  109. tema = 3 * (ema1 - ema2) + ema3
  110. out = nz(tema)
  111.  
  112. func_linx_DEMA(_val, _len) =>
  113. out1 = ema(_val, _len)
  114. out2 = ema(out1, _len)
  115. out = 2 * out1 - out2
  116.  
  117. func_linx_EHMA(_val, _len) =>
  118. out = ema(2*ema(nz(_val), _len/2)-ema(nz(_val), _len), round(sqrt(_len)))
  119.  
  120. func_linx_MHLMA(_val, _len) =>
  121. HHH = highest(high,round(_len*0.66))
  122. LLL = lowest(low,round(_len*0.66))
  123. MHL = avg(avg(HHH,LLL),_val)
  124. MHT1 = func_linx_DEMA( MHL,round(_len*0.66))
  125. MHT2 = func_linx_EHMA( MHT1,round(_len*0.66))
  126. Miff = MHT1 - MHT2
  127. ZLML = MHT1 + Miff
  128. TEMHL = func_linx_EHMA(ZLML,round(_len*1.32))
  129. out = func_linx_EHMA(TEMHL,_len)
  130.  
  131.  
  132. // 8- Hull Moving Average
  133. func_linx_HULL(_val, _len) =>
  134. out = wma(2*wma(nz(_val), _len/2)-wma(nz(_val), _len), round(sqrt(_len)))
  135.  
  136. func_linx_Steep(_val, _len, _tf) =>
  137. isP = false, isM = true , mnts =func_intbyMints()
  138. iTF = nz(_tf) >= 1 ? nz(_tf) : 1
  139. dec = abs(log(syminfo.mintick*syminfo.pointvalue) / log(10))
  140. mPi = 3.141592653589793 , tang = 180
  141. val = nz(_val) , len = nz(_len) //Rise (Fall) / Run - Price Diff => rise-fall / number of bars - run
  142. slp = ((change(val,len))*100)/len
  143. out = isP ? isM ? ((slp/mnts)*iTF)*pow(10,dec) : slp*pow(10,2) : isM ? (((atan(slp/100)/mPi*tang)/mnts)*iTF)*pow(10,dec) : (atan(slp/100)/mPi*tang)*pow(10,2)
  144.  
  145. func_linx_3732(_val) =>
  146. (.5 * _val + .866* _val[1] + 1* _val[2] + .866 * _val[3]+.5 * _val[4] ) / 3.732
  147.  
  148. func_slope(v,l)=>(linreg(v,l,0)-linreg(v,l,0)[l])/l // orj
  149. fnVWAPp(Price, Weight, Length) => sum(Price * Weight, Length ) / sum(Weight, Length)
  150.  
  151. MC = sorce////
  152. s1 = func_slope(MC,fslen)
  153. s2 = func_slope(MC,melen)
  154. s3 = func_slope(MC,sllen)
  155.  
  156. Price = MC , Price := s1 > 0 and s2 > 0 and s3 > 0 ? lowest(MC,sllen) : s1 < 0 and s2 < 0 and s3 < 0 ? highest(MC,sllen): nz(Price[1])
  157. Price := func_linx_MHLMA(Price, melen) //
  158. chup = Price+ (atr(sllen)*brkfb), chdw = Price- (atr(sllen)*brkfb)
  159. crng = (chup-chdw), zone =(chup-chdw)*0.240
  160.  
  161. bullSignal = crossover(s1, s3)
  162. bearSignal = crossunder(s1, s3)
  163.  
  164.  
  165. alertcondition(bullSignal,title="BUY Alert",message="BUY Alert")
  166. alertcondition(bearSignal,title="SELL Alert",message="SELL Alert")
  167.  
  168. //enableScalpGuides = input(true, title="Mini Scalper Engage?")
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176. //________________________________
  177. // LONG TIMEFRAME SETTINGS
  178. enableLong = input(true, title="Long Bands[On/Off]")
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185. //
  186. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  187. // ?LONG DEVIATION INPUT SETTINGS?
  188. //
  189. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  190.  
  191. showLongBands = defShowLongBands
  192.  
  193. // Long Standard Deviations Parameters (default: Metallic Means)
  194. longDev1 = defLongDev1 // Zero ratio (Fib ratio n=0)
  195. longDev2 = defLongDev2 // Golden ratio (Fib ratio n=1)
  196. longDev3 = defLongDev3 // Silver ratio (Fib ratio n=2)
  197. longDev4 = defLongDev4 // Bronze ratio (Fib ratio n=3)
  198. longDev5 = defLongDev5 // Copper ratio (Fib ratio n=4)
  199.  
  200.  
  201. //
  202. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  203. // ?LONG TIMEFRAME INPUTS?
  204. //
  205. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  206. themeLongShade = input(title="🎨 shade", type=string, defval=defThemeLongShade,
  207. options=["Dark", "Light"])
  208.  
  209. // Long: Color selection for each side
  210. themeColorAboveLong = input(title="🎨 🔼", type=string, defval=defThemeColorAboveLong,
  211. options=["01 Red","08 Green","12 Blue","04 Black"])
  212. themeColorBelowLong = input(title="🎨 🔽", type=string, defval=defThemeColorBelowLong,
  213. options=["01 Red", "08 Green","12 Blue","04 Black"])
  214.  
  215. // Long alternating fill selector (bullish/bearish)
  216. longFillAlt = input(false, title="📈/📉")
  217.  
  218. // Center and "opposite" bands (other side of the mean)
  219. themeLongCenter = defThemeLongCenter
  220.  
  221.  
  222.  
  223. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  224. // ?SHORT TIMEFRAME INPUT?
  225. //
  226. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  227. enableShort = input(true, title="Short Bands[On/Off]")
  228.  
  229. // VWAP Length
  230. shortLength = input( title="Length (bars back)", type=integer, defval=defShortLen, minval=1 )
  231. //
  232. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  233. // ?DEVIATION INPUTS?
  234. //
  235. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  236. showShortBands = defShowShortBands
  237.  
  238.  
  239. // Standard Deviations Parameters (default: Metallic Means)type = float, step = 0.1)
  240. shortDev1 = defShortDev1 // Zero ratio (Fib ratio n=0)
  241. shortDev2 = defShortDev2 // Golden ratio (Fib ratio n=1)
  242. shortDev3 = defShortDev3 // Silver ratio (Fib ratio n=2)
  243. shortDev4 = defShortDev4 // Bronze ratio (Fib ratio n=3)
  244. shortDev5 = defShortDev5 // Copper ratio (Fib ratio n=4)
  245. // Fine-tune volume weight and deviations
  246.  
  247.  
  248. //
  249. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  250. // ?THEMES?
  251. //
  252. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  253. // Short shades (Dark to Light)
  254. themeShortShade = input(title="🎨 shade", type=string, defval=defThemeShortShade,
  255. options=["Dark", "Light"])
  256.  
  257. // Short: Color selection for each side
  258. themeColorAboveShort = input(title="🎨 🔼", type=string, defval=defThemeColorAboveShort,
  259. options=["01 Red", "08 Green","12 Blue","04 Black"])
  260. themeColorBelowShort = input(title="🎨 🔽 ", type=string, defval=defThemeColorBelowShort,
  261. options=["01 Red","08 Green","12 Blue","04 Black"])
  262.  
  263. // Short alternating fill selector (bullish/bearish)
  264. shortFillAlt = input(false, title="📈/📉")
  265.  
  266. // Short alternating fill selector (bullish/bearish)
  267. MiniFillAlt = input(false, title="m📈/m📉")
  268.  
  269. // Center and "opposite" bands (other side of the mean)
  270. themeShortCenter =defThemeShortCenter
  271.  
  272.  
  273. enableScalpGuides = input(false, title="Bell Algo")
  274. enableBuyandSell = input(true, title= "Buy/Sell")
  275.  
  276. //Mini Theme
  277. themeMiniShade = input(title="🎨", type=string, defval=defThemeMiniShade,
  278. options=["Dark", "Light"])
  279.  
  280. // Short: Color selection for each side
  281. themeColorAboveMini = input(title="🎨 🔼", type=string, defval=defThemeColorAboveMini,
  282. options=["01 Red", "08 Green"])
  283. themeColorBelowMini = input(title="🎨 🔽", type=string, defval=defThemeColorBelowMini,
  284. options=["01 Red","08 Green"])
  285. // Center and "opposite" bands (other side of the mean)
  286. themeMiniCenter = defThemeMiniCenter
  287.  
  288. plotshape( enableBuyandSell == true ? bearSignal : na , title="BUY NOW", location = location.abovebar,style=shape.triangledown, text="BEAR", color=#EF5350, transp=0)
  289. plotshape( enableBuyandSell == true ? bullSignal : na , title="SELL IT",location = location.belowbar, style=shape.triangleup, text="BULL", color=#2196F3, transp=0)
  290.  
  291. fnVWAP(Price, Weight, Length) => sum(Price * Weight, Length ) / sum(Weight, Length)
  292. longSMA = sma(src,longerLength)
  293. shortSMA = sma(src,shortLength)
  294.  
  295. longfnWeightedStDev(Price, Weight, Length) => sqrt( sum(Weight * pow(Price-longSMA, 2), Length ) / sum(Weight, Length) )
  296. shortfnWeightedStDev(Price, Weight, Length) => sqrt( sum(Weight * pow(Price-shortSMA , 2), Length ) / sum(Weight, Length) )
  297.  
  298. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  299. // ? CALCULATE?
  300.  
  301. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦???¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  302.  
  303. // Evaluate if long and short deviation multipliers are the same (otherwise use short value).
  304. shortDev1 := shortDev1 == 0 ? longDev1 : shortDev1
  305. shortDev2 := shortDev2 == 0 ? longDev2 : shortDev2
  306. shortDev3 := shortDev3 == 0 ? longDev3 : shortDev3
  307. shortDev4 := shortDev4 == 0 ? longDev4 : shortDev4
  308. shortDev5 := shortDev5 == 0 ? longDev5 : shortDev5
  309.  
  310.  
  311.  
  312. longPrice = src
  313. longVolume = vol
  314. shortPrice = src
  315. shortVolume = vol
  316. shortTime = anchor
  317. longTime = anchor
  318.  
  319.  
  320. // VWAP
  321. longMean = fnVWAP( longPrice, longVolume, longerLength)
  322. shortMean = fnVWAP(shortPrice, shortVolume, shortLength)
  323. //hold_me = crossover(longTime,longPrice)
  324. //alertcondition(hold_me,title="Hold Alert", message="HOLD Alert")
  325. // WEIGHTED STANDARD DEVIATION
  326. longDeviation = longfnWeightedStDev( longPrice, longTime, longerLength)
  327. shortDeviation = shortfnWeightedStDev(shortPrice, shortTime,shortLength)
  328.  
  329. //
  330. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦??¦¦¦¦¦¦¦
  331. // ?Deviations?
  332. //
  333. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  334.  
  335. // Which long lines to calculate and draw
  336. showLongDev5 = showLongBands=="[5] All"
  337. showLongDev4 = showLongBands=="[4] Standard to Bronze" or showLongDev5
  338. showLongDev3 = showLongBands=="[3] Stardard to Silver" or showLongDev4
  339. showLongDev2 = showLongBands=="[2] Standard & Golden" or showLongDev3
  340. showLongDev1 = showLongBands=="[1] Standard Deviation" or showLongDev2
  341. showLongMean = showLongBands=="VWAP only" or showLongDev1
  342.  
  343. // Which short lines to calculate and draw
  344. showShortDev5 = showShortBands=="[5] All"
  345. showShortDev4 = showShortBands=="[4] Standard to Bronze" or showShortDev5
  346. showShortDev3 = showShortBands=="[3] Stardard to Silver" or showShortDev4
  347. showShortDev2 = showShortBands=="[2] Standard & Golden" or showShortDev3
  348. showShortDev1 = showShortBands=="[1] Standard Deviation" or showShortDev2
  349. showShortMean = showShortBands=="VWAP only" or showShortDev1
  350.  
  351. // Long Timeframe above*
  352. longDevLineAbove1 = showLongDev1 ? longMean + ( longDev1 * longDeviation ) : na
  353. longDevLineAbove2 = showLongDev2 ? longMean + ( longDev2 * longDeviation ) : na
  354. longDevLineAbove3 = showLongDev3 ? longMean + ( longDev3 * longDeviation ) : na
  355. longDevLineAbove4 = showLongDev4 ? longMean + ( longDev4 * longDeviation ) : na
  356. longDevLineAbove5 = showLongDev5 ? longMean + ( longDev5 * longDeviation ) : na
  357. // Long Timeframe below
  358. longDevLineBelow1 = showLongDev1 ? longMean - ( longDev1 * longDeviation ) : na
  359. longDevLineBelow2 = showLongDev2 ? longMean - ( longDev2 * longDeviation ) : na
  360. longDevLineBelow3 = showLongDev3 ? longMean - ( longDev3 * longDeviation ) : na
  361. longDevLineBelow4 = showLongDev4 ? longMean - ( longDev4 * longDeviation ) : na
  362. longDevLineBelow5 = showLongDev5 ? longMean - ( longDev5 * longDeviation ) : na
  363.  
  364. // Short Timeframe above
  365. shortDevLineAbove1 = showShortDev1 ? shortMean + ( shortDev1 * shortDeviation ) : na
  366. shortDevLineAbove2 = showShortDev2 ? shortMean + ( shortDev2 * shortDeviation ) : na
  367. shortDevLineAbove3 = showShortDev3 ? shortMean + ( shortDev3 * shortDeviation ) : na
  368. shortDevLineAbove4 = showShortDev4 ? shortMean + ( shortDev4 * shortDeviation ) : na
  369. shortDevLineAbove5 = showShortDev5 ? shortMean + ( shortDev5 * shortDeviation ) : na
  370. // Long Timeframe below
  371. shortDevLineBelow1 = showShortDev1 ? shortMean - ( shortDev1 * shortDeviation ) : na
  372. shortDevLineBelow2 = showShortDev2 ? shortMean - ( shortDev2 * shortDeviation ) : na
  373. shortDevLineBelow3 = showShortDev3 ? shortMean - ( shortDev3 * shortDeviation ) : na
  374. shortDevLineBelow4 = showShortDev4 ? shortMean - ( shortDev4 * shortDeviation ) : na
  375. shortDevLineBelow5 = showShortDev5 ? shortMean - ( shortDev5 * shortDeviation ) : na
  376.  
  377.  
  378.  
  379.  
  380. //
  381. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  382. // ?DESIGN?
  383. //
  384. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦??¦¦¦??¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  385.  
  386.  
  387. red20 = #EF9A9A
  388. red30 = #E57373
  389. red50 = #F44336
  390. red70 = #EF5350
  391. red90 = #EF5350
  392.  
  393. black00 = #000000
  394.  
  395.  
  396. blue20 = #90CAF9
  397. blue30 = #64B5F6
  398. blue50 = #2196F3
  399. blue70 = #1976D2
  400. blue90 = #0D47A1
  401.  
  402.  
  403. green20 = #A5D6A7
  404. green30 = #81C784
  405. green50 = #4CAF50
  406. green70 = #4CAF50
  407. green90 = #4CAF50
  408.  
  409. grey20 = #EEEEEE
  410. grey30 = #E0E0E0
  411. grey40 = #BDBDBD
  412. grey50 = #9E9E9E
  413. grey70 = #616161
  414. grey80 = #424242
  415. grey90 = #212121
  416.  
  417. //
  418. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  419. // ?COLOR THEMES?
  420. //
  421. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦???¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  422.  
  423. // work out the shade here first, then plug that variable into colorAbove and colorBelow
  424. colorLongRed = themeLongShade=="Dark" ? red90 : red70
  425. colorLongBlue = themeLongShade=="Dark" ? blue90 : blue70
  426. colorLongGreen = themeLongShade=="Dark" ? green90 : green70
  427. colorLongGrey = themeLongShade=="Dark" ? grey30 : grey30
  428.  
  429. colorShortRed = themeShortShade=="Dark" ? red90 : red70
  430. colorShortBlue = themeShortShade=="Dark" ? blue90 : blue70
  431. colorShortGreen = themeShortShade=="Dark" ? green90 : green70
  432. colorShortGrey = themeShortShade=="Dark" ? grey30 : grey30
  433.  
  434.  
  435. colorLongBlack = themeLongShade=="Dark" ? black00 : black00
  436.  
  437.  
  438.  
  439. colorShortBlack = themeShortShade=="Dark" ? black00 : black00
  440.  
  441.  
  442.  
  443. //MINI SCALP THEME
  444.  
  445.  
  446. colorMiniBlack = themeMiniShade=="Dark" ? black00 : black00
  447.  
  448.  
  449.  
  450. //MINI SCALP THEME
  451.  
  452. colorMiniRed = themeMiniShade=="Dark" ? red90 : red70
  453. colorMiniGreen = themeMiniShade=="Dark" ? green90 : green70
  454. colorMiniGrey = themeMiniShade=="Dark" ? grey30 : grey30
  455.  
  456. colorAboveMini =
  457. themeColorAboveMini=="01 Red" ? colorLongRed :
  458. themeColorAboveMini=="08 Green" ? colorLongGreen :
  459. colorMiniGrey
  460.  
  461. colorBelowMini =
  462. themeColorBelowMini=="01 Red" ? colorShortRed :
  463. themeColorBelowMini=="08 Green" ? colorShortGreen :
  464. colorMiniGrey
  465.  
  466.  
  467.  
  468. colorAboveLong =
  469. themeColorAboveLong=="01 Red" ? colorLongRed :
  470. themeColorAboveLong=="08 Green" ? colorLongGreen :
  471. themeColorAboveLong=="12 Blue" ? colorLongBlue :
  472. themeColorAboveLong=="04 Black" ? colorLongBlack :
  473. colorLongGrey
  474.  
  475.  
  476.  
  477. colorBelowLong =
  478. themeColorBelowLong=="01 Red" ? colorLongRed :
  479. themeColorBelowLong=="08 Green" ? colorLongGreen :
  480. themeColorBelowLong=="12 Blue" ? colorLongBlue :
  481. themeColorBelowLong=="04 Black" ? colorLongBlack :
  482. colorLongGrey
  483.  
  484. colorAboveShort =
  485. themeColorAboveShort=="01 Red" ? colorShortRed :
  486. themeColorAboveShort=="08 Green" ? colorShortGreen :
  487. themeColorAboveShort=="12 Blue" ? colorShortBlue :
  488. themeColorAboveShort=="04 Black" ? colorShortBlack :
  489. colorShortGrey
  490.  
  491. colorBelowShort =
  492. themeColorBelowShort=="01 Red" ? colorShortRed :
  493. themeColorBelowShort=="08 Green" ? colorShortGreen :
  494. themeColorBelowShort=="12 Blue" ? colorShortBlue :
  495. themeColorBelowShort=="04 Black" ? colorShortBlack :
  496.  
  497. colorShortGrey
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509. //
  510. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦??¦¦¦??¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  511. // ?FILL POINTS FOR BULLISH/BEARISH?
  512. //
  513. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  514. longFillCenter = themeLongCenter=="Light Grey" ? grey40 : themeLongCenter=="Dark Grey" ? grey90 : themeLongCenter=="Red" ? red : blue
  515. shortFillCenter = themeShortCenter=="Light Grey" ? grey40 : themeLongCenter=="Dark Grey" ? grey90 : themeLongCenter=="Red" ? red : blue
  516. MiniFillCenter = themeMiniCenter== "Light Cyan" ? green90 : themeMiniCenter=="Light Grey" ? grey40 :themeMiniCenter=="Dark Grey" ? grey90 : themeMiniCenter=="Red" ? red : blue
  517.  
  518.  
  519.  
  520. isLongBullish = close > longMean
  521. fillLongAbove = not(isLongBullish) and longFillAlt ? longFillCenter : colorAboveLong
  522. fillLongBelow = isLongBullish and longFillAlt ? longFillCenter : colorBelowLong
  523.  
  524. // Short bands fill color
  525. isShortBullish = close > shortMean
  526. fillShortAbove = not(isShortBullish) and shortFillAlt ? shortFillCenter : colorAboveShort
  527. fillShortBelow = isShortBullish and shortFillAlt ? shortFillCenter : colorBelowShort
  528.  
  529. // Short bands fill color
  530. isMiniBullish = close > Price
  531. fillMiniAbove = not(isMiniBullish) and MiniFillAlt ? MiniFillCenter : colorAboveMini
  532. fillMiniBelow = isMiniBullish and MiniFillAlt ? MiniFillCenter : colorBelowMini
  533.  
  534.  
  535.  
  536.  
  537. //
  538. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  539. // ?PLOT?
  540. //
  541. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦???¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  542. //plotshape( enableBuyandSell == true ? hold_me : na , title="Breakout Up", style=shape.arrowup, location=location.belowbar, size=size.auto, text="HOLD!", color=purple, transp=0)
  543. plot(enableScalpGuides ? Price : na , title='Median',join=false, transp=0, color=MiniFillCenter )
  544. plot(enableScalpGuides ? chup : na , title='Up' ,join=false, transp=0, color=colorAboveMini )
  545. plot(enableScalpGuides ? chdw : na , title='Dw' ,join=false, transp=0, color=fillMiniBelow )
  546. plot(enableScalpGuides ? chup+(crng*multx) : na , title='Up' ,join=false, transp=0, color=colorAboveMini )
  547. plot(enableScalpGuides ? chdw-(crng*multx) : na , title='Dw' ,join=false, transp=0, color=colorBelowMini)
  548. plot(enableScalpGuides ? chup[multx]+((crng+zone)*multx) : na , title='Up' ,join=false, transp=0, color=colorAboveMini )
  549. plot(enableScalpGuides ? chdw[multx]-((crng+zone)*multx) : na , title='Dw' ,join=false, transp=0, color=colorBelowMini )
  550. //plot(enableScalpGuides ? MinMd : na , title='Dw' ,join=false, transp=0, color=red )
  551.  
  552. // Means
  553. mainLongMean = plot(enableLong ? longMean : na, title="------ MEAN (LONG) -------", linewidth=1, style=circles, join=false, transp=0, color=grey80)
  554. mainShortMean =plot(enableShort ? shortMean : na, title="------ MEAN (SHORT) ------", linewidth=1, style=circles , join=false, join=false, transp=0, color=grey80)
  555.  
  556. // Long Deviation Lines
  557. longAbove1 = plot( enableLong ? longDevLineAbove1 : na, title="[1??] Standard Deviation (SELL?)", style=circles, join=false, transp=0 , color = grey50 )
  558. longAbove2 = plot( enableLong ? longDevLineAbove2 : na, title="[2??] Golden Dev. Above ", style=circles, join=false, transp=0 , color = colorAboveLong )
  559. longAbove3 = plot( enableLong ? longDevLineAbove3 : na, title="[3??] Silver Dev. Above ", style=circles, join=false, transp=0 , color = colorAboveLong )
  560. longAbove4 = plot( enableLong ? longDevLineAbove4 : na, title="[4??] Bronze Dev. Above ", style=circles, join=false, transp=0 , color = colorAboveLong )
  561.  
  562. longBelow1 = plot( enableLong ? longDevLineBelow1 : na, title="[1??] Standard Deviation (BUY?)", style=circles, join=false, transp=0 , color = grey50 )
  563. longBelow2 = plot( enableLong ? longDevLineBelow2 : na, title="[2??] Golden Dev. Below ", style=circles, join=false, transp=0 , color = colorBelowLong )
  564. longBelow3 = plot( enableLong ? longDevLineBelow3 : na, title="[3??] Silver Dev. Below ", style=circles, join=false, transp=0 , color = colorBelowLong )
  565. longBelow4 = plot( enableLong ? longDevLineBelow4 : na, title="[4??] Bronze Dev. Below ", style=circles, join=false, transp=0 , color = colorBelowLong )
  566.  
  567.  
  568. //longAbove5 = plot( enableLong ? longDevLineAbove5 : na, title="[5??] Copper Dev. Above ", style=circles, join=false, transp=100, color=green )
  569. //longBelow5 = plot( enableLong ? longDevLineBelow5 : na, title="[5??] Copper Dev. Below ", style=circles, join=false, transp=100, color=colorBelowLong )
  570.  
  571.  
  572. // Short Deviation Lines
  573. shortAbove1 = plot( enableShort? shortDevLineAbove1 : na, title="[1??] Standard Deviation (SELL?)", style=circles, join=false, transp=0, color=grey50 )
  574. shortAbove2 = plot( enableShort? shortDevLineAbove2 : na, title="[2??] Golden Dev. Above ", style=circles, join=false, transp=0, color=colorAboveShort )
  575. shortAbove3 = plot( enableShort? shortDevLineAbove3 : na, title="[3??] Silver Dev. Above ", style=circles, join=false, transp=0, color=colorAboveShort )
  576. shortAbove4 = plot( enableShort? shortDevLineAbove4 : na, title="[4??] Bronze Dev. Above ", style=circles, join=false, transp=0, color=colorAboveShort )
  577.  
  578. shortBelow1 = plot( enableShort? shortDevLineBelow1 : na, title="[1??] Standard Deviation (BUY?)", style=circles, join=false, transp=0, color=grey50 )
  579. shortBelow2 = plot( enableShort? shortDevLineBelow2 : na, title="[2??] Golden Dev. Below ", style=circles, join=false, transp=0, color=colorBelowShort )
  580. shortBelow3 = plot( enableShort? shortDevLineBelow3 : na, title="[3??] Silver Dev. Below ", style=circles, join=false, transp=0, color=colorBelowShort )
  581. shortBelow4 = plot( enableShort? shortDevLineBelow4 : na, title="[4??] Bronze Dev. Below ", style=circles, join=false, transp=0, color=colorBelowShort )
  582.  
  583.  
  584. //shortAbove5 = plot( enableShort? shortDevLineAbove5 : na, title="[5??] Copper Dev. Above ", style=circles, join=false, transp=0, color=purple )
  585. //shortBelow5 = plot( enableShort? shortDevLineBelow5 : na, title="[5??] Copper Dev. Below ", style=circles, join=false, transp=0, color=colorBelowShort )
  586.  
  587.  
  588. //
  589. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  590. // FILL PLOT
  591. //
  592. //¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
  593.  
  594. // Long Bands Fill
  595. fill ( longBelow1, longAbove1, transp=90, color=longFillCenter , title="------ Fill: 1 SD Band around Long Mean ------")
  596. fill ( longAbove1, longAbove4, transp=80, color=fillLongAbove , title="------ Fill: 1 SD Band around Long Mean ------")
  597. fill ( longBelow1, longBelow4, transp=80, color=fillLongBelow, title="[2??] Long Oversold (Golden Band)" )
  598. //fill ( longAbove1, longAbove2, transp=80, color=fillLongAbove, title="[2??] Long Overbought (Golden Band)" )
  599. //fill ( longAbove2, longAbove3, transp=80, color=fillLongAbove, title="[3??] Long Overbought (Silver Band)" )
  600. //fill ( longAbove3, longAbove4, transp=80, color=fillLongAbove, title="[4??] Long Overbought (Bronze Band)" )
  601. //fill ( longAbove4, longAbove5, transp=80, color=fillLongAbove, title="[5??] Long Overbought (Copper Band)" )
  602. //fill ( longBelow2, longBelow3, transp=80, color=fillLongBelow, title="[3??] Long Oversold (Silver Band)" )
  603. //fill ( longBelow3, longBelow4, transp=80, color=fillLongBelow, title="[4??] Long Oversold (Bronze Band)" )
  604. //fill ( longBelow4, longBelow5, transp=80, color=fillLongBelow, title="[5??] Long Oversold (Copper Band)" )
  605.  
  606. // Short Bands fill
  607. fill ( shortBelow1, shortAbove1, transp=90, color=shortFillCenter , title="------ Fill 1 SD Band around Short Mean ------")
  608. fill ( shortAbove1, shortAbove4, transp=80, color=fillShortAbove, title="------ Fill 1 SD Band around Short Mean ------")
  609. fill ( shortBelow1, shortBelow4, transp=80, color=fillShortBelow, title="[2??] Short Oversold (Golden Band)" )
  610. //fill ( shortAbove1, shortAbove2, transp=80, color=fillShortAbove, title="[2??] Short Overbought (Golden Band)" )
  611. //fill ( shortAbove2, shortAbove3, transp=80, color=fillShortAbove, title="[3??] Short Overbought (Silver Band)" )
  612. //fill ( shortAbove3, shortAbove4, transp=80, color=fillShortAbove, title="[4??] Short Overbought (Bronze Band)" )
  613. //fill ( shortAbove4, shortAbove5, transp=80, color=fillShortAbove, title="[5??] Short Overbought (Copper Band)" )
  614. //fill ( shortBelow2, shortBelow3, transp=80, color=fillShortBelow, title="[3??] Short Oversold (Silver Band)" )
  615. //fill ( shortBelow3, shortBelow4, transp=80, color=fillShortBelow, title="[4??] Short Oversold (Bronze Band)" )
  616. //fill ( shortBelow4, shortBelow5, transp=80, color=fillShortBelow, title="[5??] Short Oversold (Copper Band)" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement