Advertisement
xmd79

Fair value bands

Jan 22nd, 2023
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.46 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © quantifytools
  3.  
  4. //@version=5
  5. indicator("Fair value bands", overlay=true, max_labels_count=500, max_lines_count=500)
  6.  
  7.  
  8. // Inputs
  9.  
  10. //Settings
  11. groupFair1 = "Fair value basis & bands"
  12.  
  13. i_btCheck = input.bool(false, "Highlight metric calculations", group=groupFair1, tooltip="Enables lot based coloring and time/volume distribution counters, found in Data Window tab.")
  14. i_boost = input.float(1, "Threshold band width", group=groupFair1, step=0.10, minval = 0)
  15. i_bandBoost = input.float(1, "Deviation band width", group=groupFair1, step=0.10, minval = 0)
  16. i_source = input.source(ohlc4, "", inline="source", group=groupFair1)
  17. i_smoothingType = input.string("SMA", "", options=["SMA", "EMA", "HMA", "RMA", "WMA", "VWMA", "Median"], inline="source", group=groupFair1)
  18. i_length = input.int(20, "", inline="source", group=groupFair1, minval=1, tooltip="Determine fair value basis using preferred price source, smoothing method and length.")
  19. i_trendMode = input.string("Cross", "", options=["Cross", "Direction"], inline="sourcecross", group=groupFair1)
  20. i_thresholdUpSrc = input.source(low, "▲", inline="sourcecross", group=groupFair1)
  21. i_thresholdDownSrc = input.source(high, "▼", inline="sourcecross", group=groupFair1, tooltip="Trend modes affect fair value basis color that indicates trend direction. Direction based trends consider direction of the fair value basis, e.g. fair value basis pointing up = uptrend. Cross based trends activate when selected price source has crossed fair value basis (and threshold band, if width set above 0).")
  22.  
  23. //Visual elements
  24. groupVisual = "Visuals"
  25.  
  26. i_upColorLine = input.color(color.new(color.white, 50), "Fair value basis ▲ / ▼", group=groupVisual, inline="line")
  27. i_downColorLine = input.color(color.new(color.red, 50), "", group=groupVisual, inline="line")
  28.  
  29. i_upColorFill = input.color(color.new(color.white, 97), "Threshold band ▲ / ▼", group=groupVisual, inline="fill")
  30. i_downColorFill = input.color(color.new(color.red, 97), "", group=groupVisual, inline="fill")
  31.  
  32. extremeDeviationUp = input.color(color.new(color.red, 10), "Deviation hue ▲ / ▼", group=groupVisual, inline="deviation")
  33. extremeDeviationDown = input.color(color.new(#3c699e, 10), "", group=groupVisual, inline="deviation")
  34.  
  35. extremeUpColor = input.color(color.new(color.red, 90), "Deviation bands extreme ▲ / ▼", group=groupVisual, inline="band")
  36. extremeDownColor = input.color(color.new(#205497, 90), "", group=groupVisual, inline="band")
  37. deviationBandColor = input.color(color.new(color.white, 95), "Deviation bands", group=groupVisual, inline="dev")
  38.  
  39.  
  40.  
  41.  
  42. // Fair value basis
  43.  
  44. //User defined source and smoothing
  45. smoothedValue(source, length) =>
  46. i_smoothingType == "SMA" ? ta.sma(source, length) : i_smoothingType == "EMA" ? ta.ema(source, length) :
  47. i_smoothingType == "HMA" ? ta.hma(source, length) : i_smoothingType == "RMA" ? ta.rma(source, length) :
  48. i_smoothingType == "VWMA" ? ta.vwma(source, length) : i_smoothingType == "Median" ? ta.median(source, length) : ta.wma(source, length)
  49.  
  50. //Fair value basis
  51. fairPriceSmooth = smoothedValue(i_source, i_length)
  52.  
  53.  
  54. // Threshold band
  55.  
  56. //Percentage distance between high/low and fair value basis
  57. lowSpread = low / fairPriceSmooth
  58. highSpread = high / fairPriceSmooth
  59.  
  60. //Calculate low/high deviations from fair value basis
  61. deviationDown = low < fairPriceSmooth and high > fairPriceSmooth ? lowSpread : na
  62. deviationUp = low < fairPriceSmooth and high > fairPriceSmooth ? highSpread : na
  63.  
  64. //Arrays for deviation values
  65. var deviationUpList = array.new_float(0, 0)
  66. var deviationDownList = array.new_float(0, 0)
  67.  
  68. //Array size
  69. deviationUpSize = array.size(deviationUpList)
  70. deviationDownSize = array.size(deviationDownList)
  71.  
  72. //Keeping array sizes fixed
  73. sizeLimitDev = 1000
  74.  
  75. if deviationUpSize > sizeLimitDev
  76. array.remove(deviationUpList, 0)
  77.  
  78. if deviationDownSize > sizeLimitDev
  79. array.remove(deviationDownList, 0)
  80.  
  81. //Populating arrays
  82. array.push(deviationUpList, deviationUp)
  83. array.push(deviationDownList, deviationDown)
  84.  
  85. //Median deviations
  86. medianUpDeviation = array.median(deviationUpList)
  87. medianDownDeviation = array.median(deviationDownList)
  88.  
  89. //Defining threshold band based on median deviations
  90. upperBand = fairPriceSmooth * medianUpDeviation
  91. lowerBand = fairPriceSmooth * medianDownDeviation
  92.  
  93. //Calculating band spread from fair value basis
  94. bandUpSpread = upperBand - fairPriceSmooth
  95. bandDownSpread = fairPriceSmooth - lowerBand
  96.  
  97. //Threshold band
  98. upperBandBoosted = fairPriceSmooth + (bandUpSpread * i_boost)
  99. lowerBandBoosted = fairPriceSmooth - (bandDownSpread * i_boost)
  100.  
  101.  
  102. // Fair value deviation bands
  103.  
  104. //Switch for trend logic
  105. var int dirSwitch = 0
  106.  
  107. //Trend rules up/down
  108. trendRuleUp = i_trendMode == "Cross" ? i_thresholdUpSrc > upperBandBoosted : fairPriceSmooth > fairPriceSmooth[1]
  109. trendRuleDown = i_trendMode == "Cross" ? i_thresholdDownSrc < lowerBandBoosted : fairPriceSmooth < fairPriceSmooth[1]
  110.  
  111. //Trend up/down switch as per user defined rules
  112. if trendRuleDown
  113. dirSwitch := -1
  114. else
  115. if trendRuleUp
  116. dirSwitch := 1
  117.  
  118. //Percentage spread between fair value basis and OHLC4
  119. ohlcSpread = ohlc4 / fairPriceSmooth
  120.  
  121. //Arrays for spread pivots
  122. var pivotUps = array.new_float(0, 0)
  123. var pivotDowns = array.new_float(0, 0)
  124.  
  125. //Array size
  126. pivotUpsSize = array.size(pivotUps)
  127. pivotDownsSize = array.size(pivotDowns)
  128.  
  129. //Keeping array sizes fixed
  130. sizeLimitBand = 2000
  131.  
  132. if array.size(pivotUps) > sizeLimitBand
  133. array.remove(pivotUps, 0)
  134.  
  135. if array.size(pivotDowns) > sizeLimitBand
  136. array.remove(pivotDowns, 0)
  137.  
  138. //Spread pivots
  139. pivotUp = ta.pivothigh(ohlcSpread, 5, 5)
  140. pivotDown = ta.pivotlow(ohlcSpread, 5, 5)
  141.  
  142. //Populating arrays. To exclude insignficant pivots, arrays are populated only when price is sufficently far away from the mean.
  143. if low > upperBand
  144. array.push(pivotUps, pivotUp)
  145. else
  146. if high < lowerBand
  147. array.push(pivotDowns, pivotDown)
  148.  
  149. //Calculating median pivots from arrays
  150. medianPivotUp = array.median(pivotUps)
  151. medianPivotDown = array.median(pivotDowns)
  152.  
  153. //Pivot bands 1x median
  154. pivotBandUpBase = fairPriceSmooth * (medianPivotUp)
  155. pivotBandDownBase = fairPriceSmooth * (medianPivotDown)
  156.  
  157. //Spread between pivot band and fair value basis
  158. pBandUpSpread = (pivotBandUpBase - fairPriceSmooth) * i_bandBoost
  159. pBandDownSpread = (fairPriceSmooth - pivotBandDownBase) * i_bandBoost
  160.  
  161. //Pivot bands 1x median
  162. pivotBandUp = fairPriceSmooth + pBandUpSpread
  163. pivotBandDown = fairPriceSmooth - pBandDownSpread
  164.  
  165. //Pivot bands 2x median
  166. pivotBandUp2 = pivotBandUp + pBandUpSpread
  167. pivotBandDown2 = pivotBandDown - pBandDownSpread
  168.  
  169. //Pivot bands 3x median
  170. pivotBandUp3 = pivotBandUp2 + pBandUpSpread
  171. pivotBandDown3 = pivotBandDown2 - pBandDownSpread
  172.  
  173.  
  174. // Metrics
  175.  
  176. //Volume relative to volume moving average (SMA 20)
  177. volSma = ta.sma(volume, 20)
  178. volMultiplier = na(volSma) ? 0 : volume / volSma
  179.  
  180. //Defining fair value deviation lots
  181. abovePos2 = (i_source > pivotBandUp2)
  182.  
  183. betweenPos1AndPos2 = (i_source > pivotBandUp) and (i_source <= pivotBandUp2)
  184. betweenMidAndPos1 = (i_source > fairPriceSmooth) and (i_source <= pivotBandUp)
  185. betweenMidAndNeg1 = (i_source < fairPriceSmooth) and (i_source >= pivotBandDown)
  186. betweenNeg1AndNeg2 = (i_source < pivotBandDown) and (i_source >= pivotBandDown2)
  187.  
  188. belowNeg2 = (i_source < pivotBandDown2)
  189.  
  190. //Counters for fair value deviation lots
  191. var int abovePos2Count = 0
  192. var float abovePos2Vol = 0
  193.  
  194. var int betweenPos1AndPos2Count = 0
  195. var float betweenPos1AndPos2Vol = 0
  196.  
  197. var int betweenMidAndPos1Count = 0
  198. var float betweenMidAndPos1Vol = 0
  199.  
  200. var int betweenMidAndNeg1Count = 0
  201. var float betweenMidAndNeg1Vol = 0
  202.  
  203. var int betweenNeg1AndNeg2Count = 0
  204. var float betweenNeg1AndNeg2Vol = 0
  205.  
  206. var int belowNeg2Count = 0
  207. var float belowNeg2Vol = 0
  208.  
  209. //Populating counters
  210. if abovePos2
  211. abovePos2Count += 1
  212. abovePos2Vol += volMultiplier
  213.  
  214. if betweenPos1AndPos2
  215. betweenPos1AndPos2Count += 1
  216. betweenPos1AndPos2Vol += volMultiplier
  217.  
  218. if betweenMidAndPos1
  219. betweenMidAndPos1Count += 1
  220. betweenMidAndPos1Vol += volMultiplier
  221.  
  222. if betweenMidAndNeg1
  223. betweenMidAndNeg1Count += 1
  224. betweenMidAndNeg1Vol += volMultiplier
  225.  
  226. if betweenNeg1AndNeg2
  227. betweenNeg1AndNeg2Count += 1
  228. betweenNeg1AndNeg2Vol += volMultiplier
  229.  
  230. if belowNeg2
  231. belowNeg2Count += 1
  232. belowNeg2Vol += volMultiplier
  233.  
  234. //All counts combined
  235. allCounts = belowNeg2Count + betweenPos1AndPos2Count + betweenMidAndPos1Count + betweenMidAndNeg1Count + betweenNeg1AndNeg2Count + abovePos2Count
  236.  
  237. //Time and volume distribution percentages
  238. above2PosPerc = math.round(abovePos2Count / allCounts, 3) * 100
  239. above2PosPercVol = math.round(abovePos2Vol / abovePos2Count, 2)
  240.  
  241. above1PosPerc = math.round(betweenPos1AndPos2Count / allCounts, 2) * 100
  242. above1PosPercVol = math.round(betweenPos1AndPos2Vol / betweenPos1AndPos2Count, 2)
  243.  
  244. aboveMidPosPerc = math.round(betweenMidAndPos1Count / allCounts, 2) * 100
  245. aboveMidPosPercVol = math.round(betweenMidAndPos1Vol / betweenMidAndPos1Count, 2)
  246.  
  247. belowMidNegPerc = math.round(betweenMidAndNeg1Count / allCounts, 2) * 100
  248. belowMidNegPercVol = math.round(betweenMidAndNeg1Vol / betweenMidAndNeg1Count, 2)
  249.  
  250. below1NegPerc = math.round(betweenNeg1AndNeg2Count / allCounts, 2) * 100
  251. below1NegPercVol = math.round(betweenNeg1AndNeg2Vol / betweenNeg1AndNeg2Count, 2)
  252.  
  253. below2NegPerc = math.round(belowNeg2Count / allCounts, 3) * 100
  254. below2NegPercVol = math.round(belowNeg2Vol / belowNeg2Count, 2)
  255.  
  256.  
  257. // Table
  258.  
  259. //Dividers
  260. n = "\n"
  261. l = "⎯⎯"
  262. vl = "|"
  263.  
  264. //Source to string function
  265. srcString(source) =>
  266. sourceString = source == open ? "Open" : source == low ? "Low" : source == high ? "High" : source == close ? "Close" :
  267. source == hl2 ? "HL2" : source == hlc3 ? "HLC3" : source == ohlc4 ? "OHLC4" : "HLCC4"
  268.  
  269. //Settings texts
  270. settingsText = "Settings" + n + "⎯⎯⎯⎯⎯⎯⎯⎯⎯" + n + srcString(i_source) + vl + i_smoothingType + vl + str.tostring(i_length) + n +
  271. (i_trendMode == "Cross" ? "Cross" + vl + "▲ " + srcString(i_thresholdUpSrc) + vl + "▼ " + srcString(i_thresholdDownSrc) : "Direction") + n +
  272. "Mid: " + str.tostring(i_boost) + vl + "Out: " + str.tostring(i_bandBoost)
  273.  
  274. //Initializing table
  275. var metricTable = table.new(position = position.top_right, columns = 50, rows = 50, bgcolor = color.new(color.black, 80), border_width = 3, border_color=color.rgb(23, 23, 23))
  276.  
  277. //Populating table
  278. table.cell(table_id = metricTable, column = 1, row = 0, text = "Position" + n + "⎯⎯⎯⎯" + n + "Time" + n + "⎯⎯⎯⎯" + n + "Volume", text_color=color.white, text_halign = text.align_left)
  279. table.cell(table_id = metricTable, column = 2, row = 0, text = "+3" + n + l + n + str.tostring(above2PosPerc) + "%" + n + l + n + str.tostring(above2PosPercVol) + "x" , text_color=color.white, text_halign = text.align_center, bgcolor=color.new(color.red, 70))
  280. table.cell(table_id = metricTable, column = 3, row = 0, text = "+2" + n + l + n + str.tostring(above1PosPerc) + "%" + n + l + n + str.tostring(above1PosPercVol) + "x", text_color=color.white, text_halign = text.align_center, bgcolor=color.new(color.red, 90))
  281. table.cell(table_id = metricTable, column = 4, row = 0, text = "+1" + n + l + n + str.tostring(aboveMidPosPerc) + "%" + n + l + n + str.tostring(aboveMidPosPercVol) + "x", text_color=color.white, text_halign = text.align_center, bgcolor=color.new(color.gray, 80))
  282. table.cell(table_id = metricTable, column = 6, row = 0, text = "-1 " + n + l + n + str.tostring(belowMidNegPerc) + "%" + n + l + n + str.tostring(belowMidNegPercVol) + "x", text_color=color.white, text_halign = text.align_center, bgcolor=color.new(color.gray, 80))
  283. table.cell(table_id = metricTable, column = 7, row = 0, text = "-2" + n + l + n + str.tostring(below1NegPerc) + "%" + n + l + n + str.tostring(below1NegPercVol) + "x", text_color=color.white, text_halign = text.align_center, bgcolor=color.new(color.blue, 90))
  284. table.cell(table_id = metricTable, column = 8, row = 0, text = "-3" + n + l + n + str.tostring(below2NegPerc) + "%" + n + l + n + str.tostring(below2NegPercVol) + "x", text_color=color.white, text_halign = text.align_center, bgcolor=color.new(color.blue, 70))
  285.  
  286. table.cell(table_id = metricTable, column = 10, row = 0, text = settingsText, text_color=color.white, text_halign = text.align_left, text_valign = text.align_top, bgcolor=color.new(#100e48, 80))
  287.  
  288.  
  289. // Plots
  290.  
  291. //Colors
  292. midColorLine = dirSwitch == 1 ? i_upColorLine : i_downColorLine
  293. midColorBand = dirSwitch == 1 ? i_upColorFill : i_downColorFill
  294. deviationColor = dirSwitch == 1 ? extremeDeviationUp : extremeDeviationDown
  295. extremeUpFill = extremeUpColor
  296. extremeDownFill = extremeDownColor
  297.  
  298. //Plots
  299. pOhlc = plot(ohlc4, "OHLC4", color=color.new(color.white, 100), display=display.all - display.status_line)
  300. pUpper = plot(upperBandBoosted, "Threshold band up", color=color.new(color.white, 100), style=plot.style_linebr, display=display.all - display.status_line)
  301. pLower = plot(lowerBandBoosted, "Threshold band down", color=color.new(color.white, 100), style=plot.style_linebr, display=display.all - display.status_line)
  302. pMid = plot(fairPriceSmooth, "Fair value basis", color=midColorLine, linewidth=1, display=display.all - display.status_line)
  303.  
  304. p1U = plot(pivotBandUp, "Fair value deviation band up 1x", color=deviationBandColor, display=display.all - display.status_line)
  305. p1D = plot(pivotBandDown, "Fair value deviation band down 1x", color=deviationBandColor, display=display.all - display.status_line)
  306.  
  307. p2U = plot(pivotBandUp2, "Fair value deviation band up 2x", color=deviationBandColor, display=display.all - display.status_line)
  308. p2D = plot(pivotBandDown2, "Fair value deviation band down 2x", color=deviationBandColor, display=display.all - display.status_line)
  309.  
  310. p3U = plot(pivotBandUp3, "Fair value deviation band up 3x", color=deviationBandColor, display=display.all - display.status_line)
  311. p3D = plot(pivotBandDown3, "Fair value deviation band down 3x", color=deviationBandColor, display=display.all - display.status_line)
  312.  
  313.  
  314. //Fills
  315. fill(p3U, p2U, color= extremeUpFill, title="Extreme fair value deviation band up fill")
  316. fill(p3D, p2D, color= extremeDownFill, title="Extreme fair value deviation band down fill")
  317.  
  318. fill(pOhlc, pLower, pivotBandDown3, lowerBandBoosted, extremeDeviationDown, color.new(color.gray, 100), title="Extreme fair value deviation up hue fill")
  319. fill(pOhlc, pUpper, pivotBandUp3, upperBandBoosted, extremeDeviationUp, color.new(color.gray, 100), title="Extreme fair value deviation down hue fill")
  320. fill(pUpper, pLower, color= midColorBand, title="Threshold band fill")
  321.  
  322.  
  323. // Metric plots
  324.  
  325. barcolor(i_btCheck and belowNeg2 ? color.blue : i_btCheck and betweenNeg1AndNeg2 ? color.rgb(124, 147, 239) :
  326. i_btCheck and betweenMidAndNeg1 ? color.aqua : i_btCheck and betweenMidAndPos1 ? color.yellow :
  327. i_btCheck and betweenPos1AndPos2 ? color.orange : i_btCheck and abovePos2 ? color.red : na)
  328.  
  329. plot(i_btCheck ? volMultiplier : na, title="Relative volume", color=color.new(color.fuchsia, 100), display=display.all - display.status_line)
  330. plot(i_btCheck ? allCounts : na, title="All time counts", color=color.new(color.fuchsia, 100), display=display.all - display.status_line)
  331.  
  332. plot(i_btCheck ? abovePos2Count : na, title="+3 time count", color=color.new(color.red, 100), display=display.all - display.status_line)
  333. plot(i_btCheck ? abovePos2Vol : na, title="+3 volume count cumulative", color=color.new(color.red, 100), display=display.all - display.status_line)
  334. plot(i_btCheck ? abovePos2Vol / abovePos2Count : na, title="+3 volume count average", color=color.new(color.red, 100), display=display.all - display.status_line)
  335.  
  336. plot(i_btCheck ? betweenPos1AndPos2Count : na, title="+2 time count", color=color.new(color.orange, 100), display=display.all - display.status_line)
  337. plot(i_btCheck ? betweenPos1AndPos2Vol : na, title="+2 volume count cumulative", color=color.new(color.orange, 100), display=display.all - display.status_line)
  338. plot(i_btCheck ? betweenPos1AndPos2Vol / betweenPos1AndPos2Count : na, title="+2 volume count average", color=color.new(color.orange, 100), display=display.all - display.status_line)
  339.  
  340. plot(i_btCheck ? betweenMidAndPos1Count : na, title="+1 time count", color=color.new(color.yellow, 100), display=display.all - display.status_line)
  341. plot(i_btCheck ? betweenMidAndPos1Vol : na, title="+1 volume count cumulative", color=color.new(color.yellow, 100), display=display.all - display.status_line)
  342. plot(i_btCheck ? betweenMidAndPos1Vol / betweenMidAndPos1Count : na, title="+1 volume count average", color=color.new(color.yellow, 100), display=display.all - display.status_line)
  343.  
  344. plot(i_btCheck ? betweenMidAndNeg1Count : na, title="-1 time count", color=color.new(color.aqua, 100), display=display.all - display.status_line)
  345. plot(i_btCheck ? betweenMidAndNeg1Vol : na, title="-1 volume count cumulative", color=color.new(color.aqua, 100), display=display.all - display.status_line)
  346. plot(i_btCheck ? betweenMidAndNeg1Vol / betweenMidAndNeg1Count : na, title="-1 volume count average", color=color.new(color.aqua, 100), display=display.all - display.status_line)
  347.  
  348. plot(i_btCheck ? betweenNeg1AndNeg2Count : na, title="-2 time count", color=color.new(color.rgb(124, 147, 239) , 100), display=display.all - display.status_line)
  349. plot(i_btCheck ? betweenNeg1AndNeg2Vol : na, title="-2 volume count cumulative", color=color.new(color.rgb(124, 147, 239) , 100), display=display.all - display.status_line)
  350. plot(i_btCheck ? betweenNeg1AndNeg2Vol / betweenNeg1AndNeg2Count : na, title="-2 volume count average", color=color.new(color.rgb(124, 147, 239) , 100), display=display.all - display.status_line)
  351.  
  352. plot(i_btCheck ? belowNeg2Count : na, title="-3 time count", color=color.new(color.blue, 100), display=display.all - display.status_line)
  353. plot(i_btCheck ? belowNeg2Vol : na, title="-3 volume count cumulative", color=color.new(color.blue, 100), display=display.all - display.status_line)
  354. plot(i_btCheck ? belowNeg2Vol / belowNeg2Count : na, title="-3 volume count average", color=color.new(color.blue, 100), display=display.all - display.status_line)
  355.  
  356.  
  357. // Alerts
  358.  
  359. //Band cross scenarios
  360. deviation1CrossUp = ta.crossover(high, pivotBandUp)
  361. deviation2CrossUp = ta.crossover(high, pivotBandUp2)
  362. deviation3CrossUp = ta.crossover(high, pivotBandUp3)
  363.  
  364. deviation1CrossDown = ta.crossunder(low, pivotBandDown)
  365. deviation2CrossDown = ta.crossunder(low, pivotBandDown2)
  366. deviation3CrossDown = ta.crossunder(low, pivotBandDown3)
  367.  
  368. //Price at fair value basis during trend scenarios
  369. fairPriceInUp = dirSwitch == 1 and low <= upperBandBoosted
  370. fairPriceInDown = dirSwitch == -1 and high >= lowerBandBoosted
  371.  
  372. //New trend scenarios
  373. newTrendUp = dirSwitch[1] == -1 and dirSwitch == 1 and barstate.isconfirmed
  374. newTrendDown = dirSwitch[1] == 1 and dirSwitch == -1 and barstate.isconfirmed
  375.  
  376. //Individual
  377. alertcondition(deviation1CrossUp, "Deviation band +1 cross", "High cross above +1 band detected.")
  378. alertcondition(deviation2CrossUp, "Deviation band +2 cross", "High cross above +2 band detected.")
  379. alertcondition(deviation3CrossUp, "Deviation band +3 cross", "High cross above +3 band detected.")
  380.  
  381. alertcondition(deviation1CrossDown, "Deviation band -1 cross", "Low cross below -1 band detected.")
  382. alertcondition(deviation2CrossDown, "Deviation band -2 cross", "Low cross below -2 band detected.")
  383. alertcondition(deviation3CrossDown, "Deviation band -3 cross", "Low cross below -3 band detected.")
  384.  
  385. alertcondition(fairPriceInUp, "Low at fair value basis in an uptrend", "Low at fair value basis in an uptrend detected.")
  386. alertcondition(fairPriceInDown, "High at fair value basis in a downtrend", "High at fair value basis in a downtrend detected.")
  387.  
  388. alertcondition(newTrendUp, "New trend up", "New trend up detected")
  389. alertcondition(newTrendDown, "New trend down", "New trend down detected")
  390.  
  391. //Grouped
  392. alertcondition(deviation1CrossDown or deviation1CrossUp, "Deviation band -1 cross or +1 cross", "Low cross below -1/high cross above +1 band detected.")
  393. alertcondition(deviation2CrossDown or deviation2CrossUp, "Deviation band -2 cross or +2 cross", "Low cross below -2/high cross above +2 band detected.")
  394. alertcondition(deviation3CrossDown or deviation3CrossUp, "Deviation band -3 cross or +3 cross", "Low cross below -3/high cross above +3 band detected.")
  395.  
  396. alertcondition(newTrendUp or newTrendDown, "New trend up or new trend down", "New trend up/down detected.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement