commit e24b73106d7ecd58376caa38b5d83554268f9dd4 Author: Hadi Khazaee Asl Date: Thu Jan 25 04:07:49 2024 +0330 Initial Commit ... diff --git a/.gitkeep b/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..7bb47bc --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# xPineScript + +this is a workspace which contains all requirements for implementing new indicators and oscillators on Tradingview platform using PineScript to satisfied SaherElm IT Center Trading Strategies. + +## Maintainer + +Hadi Khazaee asl + +[https://www.saherelm.ir](https://www.saherelm.ir) + +[hadi_khazaee_asl@yahoo.com](mailto:hadi_khazaee_asl@yahoo.com) diff --git a/xIndicators/x-saherelm.atr.stop.loss.pine b/xIndicators/x-saherelm.atr.stop.loss.pine new file mode 100644 index 0000000..60c8d8b --- /dev/null +++ b/xIndicators/x-saherelm.atr.stop.loss.pine @@ -0,0 +1,62 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center ATR StopLoss Indicator +// --------------------------------------------- +// saherelm implementation of above indicator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm ATR StopLoss Indicator", shorttitle = "XS_ATRSL_IND", overlay = true) + +// +// START Inputs .... +// +source = input(low, title = "Source") +length = input.int(defval = 14, minval = 1, title = "Period") +multiplier = input.float(defval = 1.6, minval = 0.1, step = 0.1, title = "Multiplier") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// END Functions .... +// + +// +// START Calculations .... +// +longStopLoss = source - ta.atr(length) * multiplier +shortStopLoss = source + ta.atr(length) * multiplier +// +// END Calculations .... +// + +// +// START Plots .... +// +plot(series = shortStopLoss, color = color.aqua, linewidth = 1, style = plot.style_stepline, title = "Short Stop Loss") +plot(series = longStopLoss, color = color.fuchsia, linewidth = 1, style = plot.style_stepline, title = "Long Stop Loss") +// +// END Plots .... +// + +// +// START Alerts ... +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.candle.recognition.types.pine b/xIndicators/x-saherelm.candle.recognition.types.pine new file mode 100644 index 0000000..a8c3c9e --- /dev/null +++ b/xIndicators/x-saherelm.candle.recognition.types.pine @@ -0,0 +1,466 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center XTrade XCRT_IND Indicator +// --------------------------------------------- +// Candle Recognition Types +// +// it is an indicator which going to find candle types +// and provides some usefull info based on them. +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm X-Candle Recognition Type Indicator", shorttitle = "XS_CRT_IND", overlay = true) + +// +// START Inputs .... +// +// +CRTShowCandleTypeLabel = input.bool(defval = false, title = "Show Recognized Candle Types Labels") + +// +CRTShowCandleTypeShape = input.bool(defval = true, title = "Show Recognized Candle Types Shapes") + +// +var CRTTrendRule1 = "Price 50 SMA" +var CRTTrendRule2 = "50 SMA and 200 SMA" +var CRTTrendRule = input.string(CRTTrendRule1, "Trend Detection Rule", options=[CRTTrendRule1, CRTTrendRule2, "None"]) +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// Determines candle is Green or not ... +isGreenCandle() => + if close > open + true + else + false + +// +// Retreive Lower Shadow of Candle ... +lowerShadow() => + if isGreenCandle() + open - low + else + close - low + +// +// Retrieve Upper Shadow of Candle ... +upperShadow() => + if isGreenCandle() + high - close + else + high - open + +// +// Retrieve Real Body Size of Candle ... +realBody() => + math.abs(close - open) + +// +// END Functions .... +// + +// +// START Calculations .... +// +CRTUpTrend = true +CRTDownTrend = true + +// +// Trend Rule 1 ... +if CRTTrendRule == CRTTrendRule1 + CRTPriceAvg = ta.sma(close, 50) + CRTDownTrend := close < CRTPriceAvg + CRTUpTrend := close > CRTPriceAvg + +// +// Trend Rule 2 ... +if CRTTrendRule == CRTTrendRule2 + CRTSma200 = ta.sma(close, 200) + CRTSma50 = ta.sma(close, 50) + CRTDownTrend := close < CRTSma200 and CRTSma50 < CRTSma200 + CRTUpTrend := close > CRTSma200 and CRTSma50 > CRTSma200 + +// +// ema depth for bodyAvg ... +CRTLen = 14 + +// +// size of shadows ... +CRTShadowPercent = 5.0 + +// +CRTShadowEqualsPercent = 100.0 +CRTDojiBodyPercent = 5.0 + +// +// shows the number of times the shadow dominates the candlestick body +CRTFactor = 2.0 + +// +CRTBodyHi = math.max(close, open) +CRTBodyLo = math.min(close, open) + +// +CRTBody = CRTBodyHi - CRTBodyLo +CRTBodyAvg = ta.ema(CRTBody, CRTLen) + +// +CRTLongBody = CRTBody > CRTBodyAvg +CRTSmallBody = CRTBody < CRTBodyAvg + +// +CRTUpShadow = high - CRTBodyHi +CRTDnShadow = CRTBodyLo - low +CRTHasUpShadow = CRTUpShadow > CRTShadowPercent / 100 * CRTBody +CRTHasDnShadow = CRTDnShadow > CRTShadowPercent / 100 * CRTBody + +// +CRTWhiteBody = open < close +CRTBlackBody = open > close +CRTRange = high-low + +// +CRTBodyMiddle = CRTBody / 2 + CRTBodyLo +CRTIsInsideBar = CRTBodyHi[1] > CRTBodyHi and CRTBodyLo[1] < CRTBodyLo +CRTIsDojiBody = CRTRange > 0 and CRTBody <= CRTRange * CRTDojiBodyPercent / 100 +CRTShadowEquals = CRTUpShadow == CRTDnShadow or (math.abs(CRTUpShadow - CRTDnShadow) / CRTDnShadow * 100) < CRTShadowEqualsPercent and (math.abs(CRTDnShadow - CRTUpShadow) / CRTUpShadow * 100) < CRTShadowEqualsPercent + +// +CRTDoji = CRTIsDojiBody and CRTShadowEquals + +// +CRTOAbandonedBaby = CRTUpTrend[2] and CRTWhiteBody[2] and CRTIsDojiBody[1] and high[2] < low[1] and CRTBlackBody and low[1] > high + +// +CRTOEngulfing = CRTUpTrend and CRTBlackBody and CRTLongBody and CRTWhiteBody[1] and CRTSmallBody[1] and close <= open[1] and open >= close[1] and (close < open[1] or open > close[1]) + +// +CRTOEveningStar = CRTLongBody[2] and CRTSmallBody[1] and CRTLongBody ? CRTUpTrend and CRTWhiteBody[2] and CRTBodyLo[1] > CRTBodyHi[2] and CRTBlackBody and CRTBodyLo <= CRTBodyMiddle[2] and CRTBodyLo > CRTBodyLo[2] and CRTBodyLo[1] > CRTBodyHi ? true : false : false + +// +CRTGravestoneDoji = CRTIsDojiBody and CRTDnShadow <= CRTBody + +// +CRTOHangingMan = CRTSmallBody and CRTBody > 0 and CRTBodyLo > hl2 and CRTDnShadow >= CRTFactor * CRTBody and not CRTHasUpShadow ? CRTUpTrend ? true : false : false + +// +CRTHarami = CRTLongBody[1] and CRTWhiteBody[1] and CRTUpTrend[1] and CRTIsDojiBody and CRTIsInsideBar + +// +CRTMarubozuShadowPercent = 5.0 +CRTMarubozu = CRTLongBody and CRTUpShadow <= CRTMarubozuShadowPercent / 100 * CRTBody and CRTDnShadow <= CRTMarubozuShadowPercent / 100 * CRTBody +CRTMarubozuWhite = CRTMarubozu and CRTWhiteBody +CRTMarubozuBlack = CRTMarubozu and CRTBlackBody +CRTKicking = CRTMarubozuWhite[1] and CRTMarubozuBlack and low[1] > high + +// +CRTLongShadowPercent = 75.0 +CRTLongUpperShadow = CRTUpShadow > CRTRange / 100 * CRTLongShadowPercent + +// +CRTOShootingStar = CRTSmallBody and CRTBody > 0 and CRTBodyHi < hl2 and CRTUpShadow >= CRTFactor * CRTBody and not CRTHasDnShadow ? CRTUpTrend ? true : false : false + +// +CRT3BCrwShadowPercent = 5.0 +CRT3BCrwHaveNotDnShadow = CRTRange * CRT3BCrwShadowPercent / 100 > CRTDnShadow + +// +CRTOThreeBlackCrows = CRTLongBody and CRTLongBody[1] and CRTLongBody[2] ? CRTBlackBody and CRTBlackBody[1] and CRTBlackBody[2] ? close < close[1] and close[1] < close[2] and open > close[1] and open < open[1] and open[1] > close[2] and open[1] < open[2] and CRT3BCrwHaveNotDnShadow and CRT3BCrwHaveNotDnShadow[1] and CRT3BCrwHaveNotDnShadow[2] : false : false + +// +CRT3Dojis = CRTDoji[2] and CRTDoji[1] and CRTDoji +CRTBodyGapUp = CRTBodyHi[1] < CRTBodyLo +CRTBodyGapDn = CRTBodyLo[1] > CRTBodyHi +CRTTriStar = CRT3Dojis and CRTUpTrend[2] and CRTBodyGapUp[1] and CRTBodyGapDn + +// +CRTOAbandonedBaby1 = CRTDownTrend[2] and CRTBlackBody[2] and CRTIsDojiBody[1] and low[2] > high[1] and CRTWhiteBody and high[1] < low + +// +CRTDragonflyDoji1 = CRTIsDojiBody and CRTUpShadow <= CRTBody + +// +CRTOEngulfing1 = CRTDownTrend and CRTWhiteBody and CRTLongBody and CRTBlackBody[1] and CRTSmallBody[1] and close >= open[1] and open <= close[1] and ( close > open[1] or open < close[1] ) + +// +CRTOHammer1 = CRTSmallBody and CRTBody > 0 and CRTBodyLo > hl2 and CRTDnShadow >= CRTFactor * CRTBody and not CRTHasUpShadow ? CRTDownTrend ? true : false : false + +// +CRTHarami1 = CRTLongBody[1] and CRTBlackBody[1] and CRTDownTrend[1] and CRTIsDojiBody and CRTIsInsideBar + +// +CRTKicking1 = CRTMarubozuBlack[1] and CRTMarubozuWhite and high[1] < low + +// +CRTOInvertedHammer = CRTSmallBody and CRTBody > 0 and CRTBodyHi < hl2 and CRTUpShadow >= CRTFactor * CRTBody and not CRTHasDnShadow ? CRTDownTrend ? true : false : false + +// +CRTLongLowerShadow1 = CRTDnShadow > CRTRange / 100 * CRTLongShadowPercent + +// +CRTMarubozuWhite1 = CRTMarubozu and CRTWhiteBody + +// +CRTOMorningStar1 = CRTLongBody[2] and CRTSmallBody[1] and CRTLongBody ? CRTDownTrend and CRTBlackBody[2] and CRTBodyHi[1] < CRTBodyLo[2] and CRTWhiteBody and CRTBodyHi >= CRTBodyMiddle[2] and CRTBodyHi < CRTBodyHi[2] and CRTBodyHi[1] < CRTBodyLo ? true : false : false + +// +CRT3WSldShadowPercent = 5.0 +CRT3WSldHaveNotUpShadow = CRTRange * CRT3WSldShadowPercent / 100 > CRTUpShadow + +// +CRTOThreeWhiteSoldiers = CRTLongBody and CRTLongBody[1] and CRTLongBody[2] ? CRTWhiteBody and CRTWhiteBody[1] and CRTWhiteBody[2] ? close > close[1] and close[1] > close[2] and open < close[1] and open > open[1] and open[1] < close[2] and open[1] > open[2] and CRT3WSldHaveNotUpShadow and CRT3WSldHaveNotUpShadow[1] and CRT3WSldHaveNotUpShadow[2] ? true : false : false : false + +// +CRTTriStar1 = CRT3Dojis and CRTDownTrend[2] and CRTBodyGapDn[1] and CRTBodyGapUp + +// +CRTDragonflyDoji = CRTIsDojiBody and CRTUpShadow <= CRTBody + +// +CRTSpinningTopPercent = 34.0 +CRTIsSpinningTop = CRTDnShadow >= CRTRange / 100 * CRTSpinningTopPercent and CRTUpShadow >= CRTRange / 100 * CRTSpinningTopPercent and not CRTIsDojiBody +CRTSpinningTopBlack = CRTIsSpinningTop and CRTBlackBody + +// +CRTSpinningTopWhite = CRTIsSpinningTop and CRTWhiteBody + +// +var bullishColor = color.lime +var bullishShape = shape.arrowup + +// +var bearishColor = color.red +var bearishShape = shape.arrowdown + +// +var neutralColor = color.gray +var neutralShape = shape.circle +// +// END Calculations .... +// + +// +// START Plots .... +// + +///////////////// +// Bearish ... +///////////////// + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOEngulfing : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTOEngulfing and CRTShowCandleTypeLabel + var tt = "Engulfing\nAt the end of a given uptrend, a reversal pattern will most likely appear. During the first day, this candlestick pattern uses a small body. It is then followed by a day where the candle body fully overtakes the body from the day before it and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to fully overtake the range (high to low), rather only the open and the close." + label.new(bar_index, low, yloc=yloc.abovebar, text="BE", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOEveningStar : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTOEveningStar and CRTShowCandleTypeLabel + var tt = "Evening Star\nThis candlestick pattern is bearish and continues an uptrend with a long-bodied, green candle day. It is then followed by a gapped and small-bodied candle day, and concludes with a downward close. The close would be below the first day’s midpoint." + label.new(bar_index, low, yloc=yloc.abovebar, text="ES", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTGravestoneDoji : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTGravestoneDoji and CRTShowCandleTypeLabel + var tt = "Gravestone Doji\nWhen a doji is at or is close to the day’s low point, a doji line will develop." + label.new(bar_index, low, yloc=yloc.abovebar, text="GD", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOHangingMan : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTOHangingMan and CRTShowCandleTypeLabel + var tt = "Hanging Man\nWhen a specified security notably moves lower after the open, but continues to rally to close above the intraday low, a Hanging Man candlestick will form. The candlestick will resemble a square, attached to a long stick-like figure. It is referred to as a Hanging Man if the candlestick forms during an advance." + label.new(bar_index, low, yloc=yloc.abovebar, text="HM", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTHarami : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTHarami and CRTShowCandleTypeLabel + var tt = "Harami\nThis is a two-day candlestick pattern with a small, red-bodied candle that is entirely encompassed within the range that was once a green-bodied candle." + label.new(bar_index, low, yloc=yloc.abovebar, text="BH", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTKicking : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTKicking and CRTShowCandleTypeLabel + var tt = "Kicking\nA bearish kicking pattern will occur, subsequently signaling a reversal for a new downtrend. The first day candlestick is a bullish marubozu. The second day gaps down extensively and opens below the opening price of the day before. There is a gap between day one and two’s bearish candlesticks." + label.new(bar_index, low, yloc=yloc.abovebar, text="K", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTLongUpperShadow : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTLongUpperShadow and CRTShowCandleTypeLabel + var tt = "Long Upper Shadow\nTo indicate buyer domination of the first part of a session, candlesticks will present with long upper shadows, as well as short lower shadows, consequently raising bidding prices." + label.new(bar_index, low, yloc=yloc.abovebar, text="LUS", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTMarubozuBlack : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTMarubozuBlack and CRTShowCandleTypeLabel + var tt = "Marubozu Black\nThis is a candlestick that has no shadow, which extends from the red-bodied candle at the open, the close, or even at both. In Japanese, the name means “close-cropped” or “close-cut.” The candlestick can also be referred to as Bald or Shaven Head." + label.new(bar_index, low, yloc=yloc.abovebar, text="MB", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOShootingStar : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTOShootingStar and CRTShowCandleTypeLabel + var tt = "Shooting Star\nThis single day pattern can appear during an uptrend and opens high, while it closes near its open. It trades much higher as well. It is bearish in nature, but looks like an Inverted Hammer." + label.new(bar_index, low, yloc=yloc.abovebar, text="SS", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOThreeBlackCrows : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTOThreeBlackCrows and CRTShowCandleTypeLabel + var tt = "Three Black Crows\nThis is a bearish reversal pattern that consists of three long, red-bodied candles in immediate succession. For each of these candles, each day opens within the body of the day before and closes either at or near its low." + label.new(bar_index, low, yloc=yloc.abovebar, text="3BC", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTTriStar : na, style = bearishShape, size = size.tiny, location = location.belowbar, color = bearishColor, editable = false) +if CRTTriStar and CRTShowCandleTypeLabel + var tt = "Tri-Star\nThis particular pattern can form when three doji candlesticks appear in immediate succession at the end of an extended uptrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility." + label.new(bar_index, low, yloc=yloc.abovebar, text="3S", style=label.style_label_down, color = bearishColor, textcolor=color.white, tooltip = tt) + +///////////////// +// Bullish ... +///////////////// + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOAbandonedBaby1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTOAbandonedBaby1 and CRTShowCandleTypeLabel + var tt = "Abandoned Baby\nThis candlestick pattern is quite rare as far as reversal patterns go. The first of the pattern is a large down candle. Next comes a doji candle that gaps below the candle before it. The doji candle is then followed by another candle that opens even higher and swiftly moves to the upside." + label.new(bar_index, low, yloc=yloc.belowbar, text="AB", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTDragonflyDoji1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTDragonflyDoji1 and CRTShowCandleTypeLabel + var tt = "Dragonfly Doji\nSimilar to other Doji days, this particular Doji also regularly appears at pivotal market moments. This is a specific Doji where both the open and close price are at the high of a given day." + label.new(bar_index, low, yloc=yloc.belowbar, text="DD", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOEngulfing1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTOEngulfing1 and CRTShowCandleTypeLabel + var tt = "Engulfing\nAt the end of a given downward trend, there will most likely be a reversal pattern. To distinguish the first day, this candlestick pattern uses a small body, followed by a day where the candle body fully overtakes the body from the day before, and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to completely overtake the range (high to low), rather only the open and the close." + label.new(bar_index, low, yloc=yloc.belowbar, text="BE", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOHammer1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTOHammer1 and CRTShowCandleTypeLabel + var tt = "Hammer\nHammer candlesticks form when a security moves lower after the open, but continues to rally into close above the intraday low. The candlestick that you are left with will look like a square attached to a long stick-like figure. This candlestick is called a Hammer if it happens to form during a decline." + label.new(bar_index, low, yloc=yloc.belowbar, text="H", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTHarami1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTHarami1 and CRTShowCandleTypeLabel + var tt = "Harami\nThis two-day candlestick pattern consists of a small-bodied green candle that is entirely encompassed within the range of what was once a red-bodied candle." + label.new(bar_index, low, yloc=yloc.belowbar, text="BH", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTKicking1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTKicking1 and CRTShowCandleTypeLabel + var tt = "Kicking\nThe first day candlestick is a bearish marubozu candlestick with next to no upper or lower shadow and where the price opens at the day’s high and closes at the day’s low. The second day is a bullish marubozu pattern, with next to no upper or lower shadow and where the price opens at the day’s low and closes at the day’s high. Additionally, the second day gaps up extensively and opens above the opening price of the day before. This gap or window, as the Japanese call it, lies between day one and day two’s bullish candlesticks." + label.new(bar_index, low, yloc=yloc.belowbar, text="K", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOInvertedHammer : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTOInvertedHammer and CRTShowCandleTypeLabel + var tt = "Inverted Hammer\nIf in a downtrend, then the open is lower. When it eventually trades higher, but closes near its open, it will look like an inverted version of the Hammer Candlestick. This is a one-day bullish reversal pattern." + label.new(bar_index, low, yloc=yloc.belowbar, text="IH", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTLongLowerShadow1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTLongLowerShadow1 and CRTShowCandleTypeLabel + var tt = "Long Lower Shadow\nTo indicate seller domination of the first part of a session, candlesticks will present with long lower shadows and short upper shadows, consequently lowering prices." + label.new(bar_index, low, yloc=yloc.belowbar, text="LLS", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTMarubozuWhite1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTMarubozuWhite1 and CRTShowCandleTypeLabel + var tt = "Marubozu White\nA Marubozu White Candle is a candlestick that does not have a shadow that extends from its candle body at either the open or the close. Marubozu is Japanese for “close-cropped” or “close-cut.” Other sources may call it a Bald or Shaven Head Candle." + label.new(bar_index, low, yloc=yloc.belowbar, text="MW", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOMorningStar1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTOMorningStar1 and CRTShowCandleTypeLabel + var tt = "Morning Star\nA three-day bullish reversal pattern, which consists of three candlesticks will look something like this: The first being a long-bodied red candle that extends the current downtrend. Next comes a short, middle candle that gaps down on the open. After comes a long-bodied green candle, which gaps up on the open and closes above the midpoint of the body of the first day." + label.new(bar_index, low, yloc=yloc.belowbar, text="MS", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTOThreeWhiteSoldiers : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTOThreeWhiteSoldiers and CRTShowCandleTypeLabel + var tt = "Three White Soldiers\nThis bullish reversal pattern is made up of three long-bodied, green candles in immediate succession. Each one opens within the body before it and the close is near to the daily high." + label.new(bar_index, low, yloc=yloc.belowbar, text="3WS", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTTriStar1 : na, style = bullishShape, size = size.tiny, location = location.belowbar, color = bullishColor, editable = false) +if CRTTriStar1 and CRTShowCandleTypeLabel + var tt = "Tri-Star\nA bullish TriStar candlestick pattern can form when three doji candlesticks materialize in immediate succession at the tail-end of an extended downtrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility." + label.new(bar_index, low, yloc=yloc.belowbar, text="3S", style=label.style_label_up, color = bullishColor, textcolor=color.white, tooltip = tt) + +///////////////// +// Neutral ... +///////////////// + +// +plotshape(series = CRTShowCandleTypeShape ? CRTDoji : na, style = neutralShape, size = size.tiny, location = location.belowbar, color = neutralColor, editable = false) +if CRTDoji and not CRTDragonflyDoji and not CRTGravestoneDoji and CRTShowCandleTypeLabel + var tt = "Doji\nWhen the open and close of a security are essentially equal to each other, a doji candle forms. The length of both upper and lower shadows may vary, causing the candlestick you are left with to either resemble a cross, an inverted cross, or a plus sign. Doji candles show the playout of buyer-seller indecision in a tug-of-war of sorts. As price moves either above or below the opening level during the session, the close is either at or near the opening level." + label.new(bar_index, low, yloc=yloc.belowbar, text="D", style=label.style_label_center, color = neutralColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTSpinningTopBlack : na, style = neutralShape, size = size.tiny, location = location.belowbar, color = neutralColor, editable = false) +if CRTSpinningTopBlack and CRTShowCandleTypeLabel + var tt = "Spinning Top Black\nBlack spinning tops are candlestick lines that are small, red-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision." + label.new(bar_index, low, yloc=yloc.belowbar, text="STB", style=label.style_label_center, color = neutralColor, textcolor=color.white, tooltip = tt) + +// +plotshape(series = CRTShowCandleTypeShape ? CRTSpinningTopWhite : na, style = neutralShape, size = size.tiny, location = location.belowbar, color = neutralColor, editable = false) +if CRTSpinningTopWhite and CRTShowCandleTypeLabel + var tt = "Spinning Top White\nWhite spinning tops are candlestick lines that are small, green-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision between buyer and seller." + label.new(bar_index, low, yloc=yloc.belowbar, text="STW", style=label.style_label_center, color = neutralColor, textcolor=color.white, tooltip = tt) +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(CRTOEngulfing, title = "Engulfing") +alertcondition(CRTOEveningStar, title = "Evening Star") +alertcondition(CRTGravestoneDoji, title = "Gravestone Doji") +alertcondition(CRTOHangingMan, title = "Hanging Man") +alertcondition(CRTHarami, title = "Harami") +alertcondition(CRTKicking, title = "Kicking") +alertcondition(CRTLongUpperShadow, title = "Long Upper Shadow") +alertcondition(CRTMarubozuBlack, title = "Marubozu Black") +alertcondition(CRTOShootingStar, title = "Shooting Star") +alertcondition(CRTOThreeBlackCrows, title = "Three Black Crows") +alertcondition(CRTTriStar, title = "Tri-Star") +alertcondition(CRTOAbandonedBaby1, title = "Abandoned Baby") +alertcondition(CRTDragonflyDoji1, title = "Dragonfly Doji") +alertcondition(CRTOEngulfing1, title = "Engulfing") +alertcondition(CRTOHammer1, title = "Hammer") +alertcondition(CRTHarami1, title = "Harami") +alertcondition(CRTKicking1, title = "Kicking") +alertcondition(CRTOInvertedHammer, title = "Inverted Hammer") +alertcondition(CRTLongLowerShadow1, title = "Long Lower Shadow") +alertcondition(CRTMarubozuWhite1, title = "Marubozu White") +alertcondition(CRTOMorningStar1, title = "Morning Star") +alertcondition(CRTOThreeWhiteSoldiers, title = "Three White Soldiers") +alertcondition(CRTTriStar1, title = "Tri-Star") +alertcondition(CRTDoji and not CRTDragonflyDoji and not CRTGravestoneDoji, title = "Doji") +alertcondition(CRTSpinningTopBlack, title = "Spinning Top Black") +alertcondition(CRTSpinningTopWhite, title = "Spinning Top White") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.hull.trend.pine b/xIndicators/x-saherelm.hull.trend.pine new file mode 100644 index 0000000..6609c2c --- /dev/null +++ b/xIndicators/x-saherelm.hull.trend.pine @@ -0,0 +1,83 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Hull Trend Indicator +// --------------------------------------------- +// saherelm implementation of above indicator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Hull Trend Indicator", shorttitle = "XS_HUTR_IND", overlay = true) + +// +// START Inputs .... +// +HUTRSrc = input.source(defval = hl2, title = "Source") +HUTRLength = input.int(defval = 23, title = "Length") +HUTRShowCross = input.bool(defval = true, title = "Show cross over/under") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +HUTRHma(src, length)=> + ta.wma((2 * ta.wma(src, length / 2)) - ta.wma(src, length), math.round(math.sqrt(length))) + +// +HUTRHma3(src, length)=> + p = length / 2 + ta.wma(ta.wma(close, p / 3) * 3 - ta.wma(close, p / 2) - ta.wma(close, p) ,p) +// +// END Functions .... +// + +// +// START Calculations .... +// +// +HUTRA = HUTRHma(HUTRSrc, HUTRLength) +HUTRB = HUTRHma3(HUTRSrc, HUTRLength) +HUTRColor = HUTRB > HUTRA ? color.lime : color.red + +// +HUTRCrossDown = HUTRA > HUTRB and HUTRA[1] < HUTRB[1] +HUTRCrossUp = HUTRB > HUTRA and HUTRB[1] < HUTRA[1] +// +// END Calculations .... +// + +// +// START Plots .... +// +HUTRP1 = plot(series = HUTRA, color = color.new(HUTRColor, 75), linewidth = 1, title = "Upper Line") +HUTRP2 = plot(series = HUTRB, color = color.new(HUTRColor, 75), linewidth = 1, title = "Downer Line") + +// +fill(HUTRP1, HUTRP2, color = color.new(HUTRColor, 55), title = "Cloud Fill") + +// +plotshape(HUTRShowCross and HUTRCrossDown ? HUTRA : na, location = location.absolute, style = shape.labeldown, color = color.red, size = size.tiny, text = "Sell", textcolor = color.white, offset=-1) +plotshape(HUTRShowCross and HUTRCrossUp ? HUTRA : na, location = location.absolute, style = shape.labelup, color = color.green, size = size.tiny, text = "Buy", textcolor = color.white, offset=-1) +// +// END Plots .... +// + +// +// START Alerts ... +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.leledc.level.pine b/xIndicators/x-saherelm.leledc.level.pine new file mode 100644 index 0000000..d9a9a02 --- /dev/null +++ b/xIndicators/x-saherelm.leledc.level.pine @@ -0,0 +1,135 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Leledc Level Indicator +// --------------------------------------------- +// saherelm implementation of above indicator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Leledc Levels Indicator", shorttitle = "XS_LL_IND", overlay = true) + +// +// START Inputs .... +// +exhaustionSwitch = input.bool(defval = true, title = "Show exhaustion Bar point (Arrows)") +levelSwitch = input.bool(defval = true, title = "Show exhaustion levels (Lines)") +length = input.int(defval = 40, title = "Exhaustions swing length") +bars = input.int(defval = 42, title = "Exhaustion bar count") +thicknesSwitch = input.int(defval = 7, title ="Line Thickness(Level thickness)") +// +// END Inputs .... +// + +// +// START Functions .... +// +Lelec(bars, len) => + // + result = 0 + bindex = int(na) + bindex := nz(bindex[1], 0) + sindex = int(na) + sindex := nz(sindex[1], 0) + + // + bindex := close > close[4] ? bindex + 1 : bindex + sindex := close < close[4] ? sindex + 1 : sindex + + // + lowest = ta.lowest(low, len) + highest = ta.highest(high, len) + + // + if bindex > bars and close < open and high >= highest + bindex := 0 + result := -1 + result + else + if sindex > bars and close > open and low <= lowest + sindex := 0 + result := 1 + result +// +// END Functions .... +// + +// +// START Calculations .... +// +// +// Out C ... +Lelex = Lelec(bars, length) + +// +// Out Bar ... +highlel = Lelex == -1 ? high : na +lowlel = Lelex == 1 ? low : na + +// +// Out level ... +resistance = float(na) +support = float(na) +resistance := close < open and Lelex ? high : resistance[1] +support := close > open and Lelex ? low : support[1] + +// +// Resistanse Color ... +resistanseColor = color.red +highColor = ta.change(resistance) == 0 ? resistanseColor : na + +// +// Support Color ... +supportColor = color.lime +lowColor = ta.change(support) == 0 ? supportColor : na + +// +// Has Signal ... +hasSignal = exhaustionSwitch + +// +// Up Signals ... +upSignal = hasSignal ? lowlel : na + +// +// Down Signals ... +downSignal = hasSignal ? highlel : na +// +// END Calculations .... +// + +// +// START Plots .... +// +// Plot Bar ... +plotshape(hasSignal ? upSignal : na, title = "Up", color = supportColor, location = location.belowbar, style = shape.triangleup, size = size.normal) +plotshape(hasSignal ? downSignal : na, title = "Down", color = resistanseColor, location = location.abovebar, style = shape.triangledown, size = size.normal) + +// +// Plot level ... +plot(levelSwitch ? resistance : na, title = "Reistance Level", style = plot.style_line, color = highColor, linewidth = thicknesSwitch) +plot(levelSwitch ? support : na, title = "Support Level", style = plot.style_line, color = lowColor, linewidth = thicknesSwitch) + +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(lowlel, "Up") +alertcondition(highlel, "Down") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.price.action.candle.recognition.pine b/xIndicators/x-saherelm.price.action.candle.recognition.pine new file mode 100644 index 0000000..e356a74 --- /dev/null +++ b/xIndicators/x-saherelm.price.action.candle.recognition.pine @@ -0,0 +1,145 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center XTrade XCRT_IND Indicator +// --------------------------------------------- +// Candle Recognition Types +// +// it is an indicator which going to find candle types +// and provides some usefull info based on them. +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm X-Price Action Candle Recognition Indicator", shorttitle = "XS_PA_CR_IND", overlay = true) + +// +// START Inputs .... +// +// +showCandleTypeLabel = input.bool(defval = false, title = "Show Recognized Candle Types Labels") +showCandleTypeTitlesAsTooltip = input.bool(defval = false, title = "Show Titles as Tooltip") + +// +// Candle Type Recognition Rules ... +var candleItselfRule = "Candle itself" +var candleByItsNeighborhoodRule = "Candle and it's prev Neighborhood" +candleRecognitionRule = input.string(defval = candleItselfRule, title = "Candle Recognition Rule", options = [candleItselfRule, candleByItsNeighborhoodRule]) + +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// Retrieve Specific Candle Height (based on low and high) ... +getCandleRange() => + high - low + +// +// Retrieve Candle Ranges Thirs Section ... +getCandleThird() => + getCandleRange() / 3 + +// +// Determines a Candle is Bullish or not ... +isBullishCandle() => + close > low + (getCandleThird() * 2) + +// +// Determines a Candle is Bearish or not ... +isNeutralCandle() => + close < low + (getCandleThird() * 2) and close > low + getCandleThird() + +// +// Determines a Candle is Neutral or not ... +isBearishCandle() => + close < low + getCandleThird() + +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var bullishColor = color.lime +var bullishShape = shape.arrowup +var bullishTitle = "Bullish" +var bullishType = 1 + +// +var bearishColor = color.red +var bearishShape = shape.arrowdown +var bearishTitle = "Bearish" +var bearishType = -1 + +// +var neutralColor = color.gray +var neutralShape = shape.circle +var neutralTitle = "Neutral" +var neutralType = 0 + +// +candleType = isBullishCandle() ? bullishType : isNeutralCandle() ? neutralType : isBearishCandle() ? bearishType : neutralType + +// +prevCandleType = not na(candleType[1]) ? candleType[1] : neutralType + +// +candleNeighborhoodBaseType = prevCandleType + candleType +candleNeighborhoodBaseTypeTitle = str.tostring(prevCandleType) + "," + str.tostring(candleType) +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Plot Range inside of indicator title ... +// plot(getCandleRange(), color = color.orange, title = "Bar Ranges") + +// +// Plot Range inside of indicator title ... +// plot(getCandleThird(), color = color.aqua, title = "Bar Thirds") + +// +// Plot Candle State ... +// +// Candle Type ... +if showCandleTypeLabel and candleRecognitionRule == candleItselfRule + candleTypeLabelStyle = candleType > 0 ? label.style_label_up : candleType == 0 ? label.style_label_center : candleType < 0 ? label.style_label_down : na + candleTypeLabelColor = candleType > 0 ? bullishColor : candleType == 0 ? neutralColor : candleType < 0 ? bearishColor : na + candleTypeLabel = label.new(x = bar_index, y = low, yloc = yloc.belowbar, style = candleTypeLabelStyle, text = showCandleTypeTitlesAsTooltip ? na : str.tostring(candleType), color = candleTypeLabelColor, textcolor = color.white, tooltip = showCandleTypeTitlesAsTooltip ? str.tostring(candleType) : na) + +// +// Candle Neighborhood Base Type ... +if showCandleTypeLabel and candleRecognitionRule == candleByItsNeighborhoodRule + candleTypeLabelStyle = candleNeighborhoodBaseType > 0 ? label.style_label_up : candleNeighborhoodBaseType == 0 ? label.style_label_center : candleNeighborhoodBaseType < 0 ? label.style_label_down : na + candleTypeLabelColor = candleNeighborhoodBaseType > 0 ? bullishColor : candleNeighborhoodBaseType == 0 ? neutralColor : candleNeighborhoodBaseType < 0 ? bearishColor : na + candleTypeLabel = label.new(x = bar_index, y = low, yloc = yloc.belowbar, style = candleTypeLabelStyle, text = showCandleTypeTitlesAsTooltip ? na : candleNeighborhoodBaseTypeTitle, color = candleTypeLabelColor, textcolor = color.white, tooltip = showCandleTypeTitlesAsTooltip ? candleNeighborhoodBaseTypeTitle : na) +// +// END Plots .... +// + +// +// START Alerts ... +// +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.range.filter.buy.sell.pine b/xIndicators/x-saherelm.range.filter.buy.sell.pine new file mode 100644 index 0000000..098b4f2 --- /dev/null +++ b/xIndicators/x-saherelm.range.filter.buy.sell.pine @@ -0,0 +1,143 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center ATR StopLoss Indicator +// --------------------------------------------- +// saherelm implementation of above indicator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Range Filter Buy Sell Indicator", shorttitle = "XS_RFBS_IND", overlay = true) + +// +// START Inputs .... +// +// Source +RFBSSrc = input.source(defval = close, title = "Source") + +// +// Sampling Period +RFBSPer = input.int(defval = 41, minval = 1, title = "Sampling Period") + +// +// Range Multiplier ... +RFBSMult = input.float(defval = 3.0, minval = 0.1, title = "Range Multiplier") +// +// END Inputs .... +// + +// +// START Functions .... +// +// Smooth Average Range +smoothAverageRange(x, t, m) => + wper = t * 2 - 1 + avrng = ta.ema(math.abs(x - x[1]), t) + result = ta.ema(avrng, wper) * m + result + +// +// Range Filter ... +rangeFilter(x, r) => + result = x + result := x > nz(result[1]) ? x - r < nz(result[1]) ? nz(result[1]) : x - r : x + r > nz(result[1]) ? nz(result[1]) : x + r + result +// +// END Functions .... +// + +// +// START Calculations .... +// + +// +// Color variables ... +RFBSUpColor = color.green +RFBSMidColor = color.blue +RFBSDownColor = color.red + +// +RFBSSmrng = smoothAverageRange(RFBSSrc, RFBSPer, RFBSMult) +RFBSFilt = rangeFilter(RFBSSrc, RFBSSmrng) + +// +// Filter UP Direction ... +RFBSUpward = 0.0 +RFBSUpward := RFBSFilt > RFBSFilt[1] ? nz(RFBSUpward[1]) + 1 : RFBSFilt < RFBSFilt[1] ? 0 : nz(RFBSUpward[1]) + +// +// Filter DOWN Direction ... +RFBSDownward = 0.0 +RFBSDownward := RFBSFilt < RFBSFilt[1] ? nz(RFBSDownward[1]) + 1 : RFBSFilt > RFBSFilt[1] ? 0 : nz(RFBSDownward[1]) + +// +// Target Bands +RFBSHband = RFBSFilt + RFBSSmrng +RFBSLband = RFBSFilt - RFBSSmrng + +// +// Colors +RFBSFiltcolor = RFBSUpward > 0 ? RFBSUpColor : RFBSDownward > 0 ? RFBSDownColor : RFBSMidColor +RFBSBarcolor = RFBSSrc > RFBSFilt and RFBSSrc > RFBSSrc[1] and RFBSUpward > 0 ? RFBSUpColor : RFBSSrc > RFBSFilt and RFBSSrc < RFBSSrc[1] and RFBSUpward > 0 ? RFBSUpColor : RFBSSrc < RFBSFilt and RFBSSrc < RFBSSrc[1] and RFBSDownward > 0 ? RFBSDownColor : RFBSSrc < RFBSFilt and RFBSSrc > RFBSSrc[1] and RFBSDownward > 0 ? RFBSDownColor : RFBSMidColor + +// +// Break Outs +RFBSLongCond = bool(na) +RFBSShortCond = bool(na) +RFBSLongCond := RFBSSrc > RFBSFilt and RFBSSrc > RFBSSrc[1] and RFBSUpward > 0 or RFBSSrc > RFBSFilt and RFBSSrc < RFBSSrc[1] and RFBSUpward > 0 +RFBSShortCond := RFBSSrc < RFBSFilt and RFBSSrc < RFBSSrc[1] and RFBSDownward > 0 or RFBSSrc < RFBSFilt and RFBSSrc > RFBSSrc[1] and RFBSDownward > 0 + +// +RFBSCondIni = 0 +RFBSCondIni := RFBSLongCond ? 1 : RFBSShortCond ? -1 : RFBSCondIni[1] +RFBSLongCondition = RFBSLongCond and RFBSCondIni[1] == -1 +RFBSShortCondition = RFBSShortCond and RFBSCondIni[1] == 1 +// +// END Calculations .... +// + +// +// START Plots .... +// +// Range Filter ... +RFBSFiltPlot = plot(series = RFBSFilt, color = RFBSFiltcolor, linewidth = 2, title = "RFBS > Range Filter") + +// +// Target ... +RFBSHbandPlot = plot(series = RFBSHband, color = color.new(RFBSUpColor, 70), title = "RFBS > High Target") +RFBSLbandPlot = plot(series = RFBSLband, color = color.new(RFBSDownColor, 70), title = "RFBS > Low Target") + +// +// Fills +fill(RFBSHbandPlot, RFBSFiltPlot, color = color.new(RFBSUpColor, 90), title = "RFBS > High Target Range") +fill(RFBSLbandPlot, RFBSFiltPlot, color = color.new(RFBSDownColor, 90), title = "RFBS > Low Target Range") + +// +// Bar Color +barcolor(RFBSBarcolor) + +// +// Plot Signal Labels ... +plotshape(series = RFBSLongCondition, title = "RFBS > Buy Signal", text = "Buy", textcolor = color.white, style = shape.labelup, size = size.small, location = location.belowbar, color = color.new(RFBSUpColor, 20)) +plotshape(series = RFBSShortCondition, title = "RFBS > Sell Signal", text = "Sell", textcolor = color.white, style = shape.labeldown, size = size.small, location = location.abovebar, color = color.new(RFBSDownColor, 20)) +// +// END Plots .... +// + +// +// START Alerts ... +// +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.rma.pine b/xIndicators/x-saherelm.rma.pine new file mode 100644 index 0000000..3f88b17 --- /dev/null +++ b/xIndicators/x-saherelm.rma.pine @@ -0,0 +1,59 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center RMA Indicator +// --------------------------------------------- +// saherelm implementation of above indicator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm RMA Indicator", shorttitle = "XS_RMA_IND", overlay = true) + +// +// START Inputs .... +// +source = input(close, title = "Source") +rmaLength = input.int(defval = 10, minval = 1, title = "Length") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// END Functions .... +// + +// +// START Calculations .... +// +rma = ta.rma(source, rmaLength) +// +// END Calculations .... +// + +// +// START Plots .... +// +plot(series = rma, color = color.fuchsia, linewidth = 1, style = plot.style_line, title = "RMA") +// +// END Plots .... +// + +// +// START Alerts ... +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.swing.stop.losses.pine b/xIndicators/x-saherelm.swing.stop.losses.pine new file mode 100644 index 0000000..b006345 --- /dev/null +++ b/xIndicators/x-saherelm.swing.stop.losses.pine @@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Swing Stop Losses Indicator +// --------------------------------------------- +// saherelm implementation of above indicator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Swing Stop Losses Indicator", shorttitle = "XS_SWSL_IND", overlay = true) + +// +// START Inputs .... +// +swingLoopback = input.int(defval = 7, title = "Swing Loopback Period") + +showLongStopLoss = input.bool(defval = true, title = "Show Long Stop Losses") +showShortStopLoss = input.bool(defval = true, title = "Show Short Stop Losses") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +lastMarketLowest = ta.lowest(low, swingLoopback) +lastMarketLowest2 = ta.lowest(low, swingLoopback * 2) +lastMarketLowest3 = ta.lowest(low, swingLoopback * 3) + +// +lastMarketHighest = ta.highest(high, swingLoopback) +lastMarketHighest2 = ta.highest(high, swingLoopback * 2) +lastMarketHighest3 = ta.highest(high, swingLoopback * 3) +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Stop Losses ... +plot(series = showLongStopLoss ? lastMarketLowest : na, color = color.fuchsia, linewidth = 1, style = plot.style_stepline, title = "Long Stop Loss") +plot(series = showShortStopLoss ? lastMarketHighest : na, color = color.aqua, linewidth = 1, style = plot.style_stepline, title = "Short Stop Loss") +// +// END Plots .... +// + +// +// START Alerts ... +// +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.trend.magic.pine b/xIndicators/x-saherelm.trend.magic.pine new file mode 100644 index 0000000..3188f0f --- /dev/null +++ b/xIndicators/x-saherelm.trend.magic.pine @@ -0,0 +1,69 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Trend Magic Indicator +// --------------------------------------------- +// saherelm implementation of above indicator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Trend Magic Indicator", shorttitle = "XS_TM_IND", overlay = true) + +// +// START Inputs .... +// +TMPeriod = input.int(defval = 20, title = "CCI period") +TMCoeff = input.int(defval = 1, title = "ATR Multiplier") +TMAP = input.int(defval = 5, title = "ATR Period") +TMATR = ta.sma(ta.tr,TMAP) +TMSrc = input.source(defval = close, title = "Source") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +TMUpT = low - TMATR * TMCoeff +TMDownT = high + TMATR * TMCoeff + +// +MagicTrend = 0.0 +MagicTrend := ta.cci(TMSrc, TMPeriod) >= 0 ? (TMUpT < nz(MagicTrend[1]) ? nz(MagicTrend[1]) : TMUpT) : (TMDownT > nz(MagicTrend[1]) ? nz(MagicTrend[1]) : TMDownT) +TMColor = ta.cci(TMSrc, TMPeriod) >= 0 ? color.blue : color.red +// +// END Calculations .... +// + +// +// START Plots .... +// +plot(series = MagicTrend, color = TMColor, linewidth = 3, title = "Trend Magic") +// +// END Plots .... +// + +// +// START Alerts ... +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xIndicators/x-saherelm.vbm.buy.sell.pine b/xIndicators/x-saherelm.vbm.buy.sell.pine new file mode 100644 index 0000000..8ec60d3 --- /dev/null +++ b/xIndicators/x-saherelm.vbm.buy.sell.pine @@ -0,0 +1,107 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center VBM Buy Sell Indicator +// --------------------------------------------- +// saherelm implementation of above indicator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm VBM Buy Sell Indicator", shorttitle = "XS_VBMBS_IND", overlay = true) + +// +// START Inputs .... +// +VBMBSFactor = input.int(defval = 4, minval = 1, maxval = 100, title = "Factor") +VBMBSPd = input.int(defval = 7, minval = 1, maxval = 100, title = "Period") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// END Functions .... +// + +// +// START Calculations .... +// +var bullishColor = color.lime +var bearishColor = color.red + +// +VBMBSUp = hl2 - (VBMBSFactor * ta.atr(VBMBSPd)) +VBMBSDown = hl2 + (VBMBSFactor * ta.atr(VBMBSPd)) + +// +// Trend Up ... +float VBMBSTrendUp = na +VBMBSTrendUp := close[1] > VBMBSTrendUp[1] ? math.max(VBMBSUp, VBMBSTrendUp[1]) : VBMBSUp + +// +// Trend Down ... +float VBMBSTrendDown = na +VBMBSTrendDown := close[1] < VBMBSTrendDown[1] ? math.min(VBMBSDown, VBMBSTrendDown[1]) : VBMBSDown + +// +float VBMBSTrend = na +VBMBSTrend := close > VBMBSTrendDown[1] ? 1 : close < VBMBSTrendUp[1] ? -1 : nz(VBMBSTrend[1], 1) + +// +VBMBSMACD = VBMBSTrend == 1 ? VBMBSTrendUp : VBMBSTrendDown + +// +VBMBSLinecolor = VBMBSTrend == 1 ? bullishColor : bearishColor + +// +VBMBSUpArrow = ta.cross(close, VBMBSMACD) and close > VBMBSMACD +VBMBSDownArrow = ta.cross(VBMBSMACD, close) and close < VBMBSMACD + +// +VBMBSLongSignal = VBMBSTrend == 1 and VBMBSTrend[1] == -1 ? VBMBSTrend : na +VBMBSHasLongSignal = not na (VBMBSLongSignal) + +// +VBMBSShortSignal = VBMBSTrend == -1 and VBMBSTrend[1] == 1 ? VBMBSTrend : na +VBMBSHasShortSignal = not na (VBMBSShortSignal) + +// +VBMBSHasSignal = VBMBSHasLongSignal or VBMBSHasShortSignal +// +// END Calculations .... +// + +// +// START Plots .... +// +plot(series = VBMBSMACD, color = VBMBSLinecolor , style = plot.style_line, linewidth = 2, title = "B/S Line") + +// +plotshape(series = VBMBSUpArrow, title = "Up Arrow", style = shape.triangleup, location = location.belowbar, color = bullishColor) +plotshape(series = VBMBSDownArrow, title = "Down Arrow", style = shape.triangledown, location = location.abovebar, color = bearishColor) + +// +plotarrow(series = VBMBSHasLongSignal ? VBMBSLongSignal : na, title = "Up Entry Arrow", colorup = bullishColor, maxheight = 40, minheight = 30) +plotarrow(series = VBMBSHasShortSignal ? VBMBSShortSignal : na, title = "Down Entry Arrow", colordown = bearishColor, maxheight = 40, minheight = 30) +// +// END Plots .... +// + +// +// START Alerts ... +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xOscillators/x-saherelm.cycle.channel.pine b/xOscillators/x-saherelm.cycle.channel.pine new file mode 100644 index 0000000..2b90186 --- /dev/null +++ b/xOscillators/x-saherelm.cycle.channel.pine @@ -0,0 +1,149 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Cycle Channel Oscillator +// --------------------------------------------- +// saherelm implementation of above oscillator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Cycle Channel Oscillator", shorttitle = "XS_CC_OSC", overlay = false) + +// +// START Inputs .... +// +scl_t = input.int(defval = 10, title = "Short Cycle Length") +mcl_t = input.int(defval = 30, title = "Medium Cycle Length") +scm = input.float(defval = 1.0, title = "Short Cycle Multiplier") +mcm = input.float(defval = 3.0, title = "Medium Cycle Multiplier") +src = input.source(defval = close, title = "Source") +ebc = input.bool(defval = false, title = "Enable bar colors") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +scl = scl_t / 2 +mcl = mcl_t / 2 +ma_scl = ta.rma(src, scl) +ma_mcl = ta.rma(src, mcl) +scm_off = scm * ta.atr(scl) +mcm_off = mcm * ta.atr(mcl) + +// +scl_2 = scl / 2 +mcl_2 = mcl / 2 +sct = nz(ma_scl[scl_2], src) + scm_off +scb = nz(ma_scl[scl_2], src) - scm_off +mct = nz(ma_mcl[mcl_2], src) + mcm_off +mcb = nz(ma_mcl[mcl_2], src) - mcm_off + +// +scmm = math.avg(sct,scb) + +// +omed = (scmm - mcb) / (mct - mcb) +oshort = (src - mcb) / (mct - mcb) + +// +bc = (oshort > 0.5) ? (oshort > 1.0 ? color.purple : (oshort > omed ? color.lime : color.green)) : (oshort < 0 ? color.purple : ( oshort < omed ? color.red : color.orange)) + +// +var bullishColor = color.aqua +var bearishColor = color.fuchsia + +// +showSignals = input.bool(defval = false, title = "Show Signals", group = "Signals") +showBullishSignals = input.bool(defval = false, title = "Show Bullish Signals", group = "Signals") +showBearishSignals = input.bool(defval = false, title = "Show Bearish Signals", group = "Signals") + +// +// RED ... +FastOSC = oshort + +// +// Green ... +SlowOSC = omed + +// +MIDOSC = FastOSC >= SlowOSC ? (FastOSC - SlowOSC) / 2 : (SlowOSC - FastOSC) / 2 + +// +isFastOSCCrossOverSlowOSC = ta.crossover(FastOSC, SlowOSC) +isFastOSCCrossUnderSlowOSC = ta.crossunder(FastOSC, SlowOSC) + +// +hasBullishSignal = isFastOSCCrossOverSlowOSC and MIDOSC >= 0.02 +hasBearishSignal = isFastOSCCrossUnderSlowOSC and MIDOSC >= 0.02 + +// +hasSignal = hasBullishSignal or hasBearishSignal +// +// END Calculations .... +// + +// +// START Plots .... +// +// Draw Area ... +// +upperLine = plot(1.0, title = "Upper Line", color = color.gray) +middleLine = plot(0.5, title = "Middle Line", color = color.gray) +lowerLine = plot(0.0, title = "Lower Line", color = color.gray) + +// +fill(lowerLine, middleLine, color = color.new(color.red, 95), title = "Lower Area Fill") +fill(upperLine, middleLine, color = color.new(color.green, 95), title = "Upper Area Fill") + +// +plot(series = omed >= 1.0 ? omed : na, histbase = 1.0, style = plot.style_histogram, color = color.purple, linewidth = 2, title = "Medium Cycle OB") +plot(series = omed <= 0.0 ? omed : na, histbase = 0.0, style = plot.style_histogram, color = color.purple, linewidth = 2, title = "Medium Cycle OS") + +// +plot(series = oshort >= 1.0 ? oshort : na, histbase = 1.0, style = plot.style_histogram, color = color.purple, linewidth = 2, title = "Short Cycle OB") +plot(series = oshort <= 0.0 ? oshort : na, histbase = 0.0, style = plot.style_histogram, color = color.purple, linewidth = 2, title = "Short Cycle OS") + +// +plot(series = oshort, color = color.red, linewidth = 2, title = "Fast Osc") +plot(series = omed, color = color.green, linewidth = 2, title = "Slow Osc") + +// +plot(series = MIDOSC, title = "Mid Osc", style = plot.style_histogram, color = color.yellow, linewidth = 2) + +// +plotshape(series = showSignals and showBullishSignals and hasBullishSignal ? FastOSC : na, title = "FastOSC CrossOver SlowOSC", location = location.bottom, style = shape.triangleup, color = bullishColor, size = size.small) +plotshape(series = showSignals and showBearishSignals and hasBearishSignal ? FastOSC : na, title = "FastOSC CrossUnder SlowOSC", location = location.top, style = shape.triangledown, color = bearishColor, size = size.small) +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(hasSignal, "XS_CC_OSC > Signal") +alertcondition(hasBullishSignal, "XS_CC_OSC > Long Signal") +alertcondition(hasBearishSignal, "XS_CC_OSC > Short Signal") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xOscillators/x-saherelm.hull.butterfly.pine b/xOscillators/x-saherelm.hull.butterfly.pine new file mode 100644 index 0000000..48dc9bc --- /dev/null +++ b/xOscillators/x-saherelm.hull.butterfly.pine @@ -0,0 +1,158 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Hull butterfly Oscillator +// --------------------------------------------- +// saherelm implementation of above oscillator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Hull butterfly Oscillator", shorttitle = "XS_HUBF_OSC", overlay = false) + +// +// START Inputs .... +// +// +HUBFSrc = input.source(defval = close, title = "Source") + +// +HUBFLength = input.int(defval = 11, title = "Length") + +// +HUBFMult = input.float(defval = 2.0, title = "Levels Multiplier") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var bullishColor = color.lime +var bullishColor1 = color.new(bullishColor, 50) + +// +var bearishColor = color.red +var bearishColor1 = color.new(bearishColor, 50) + +// +var HUBFShortLen = int(HUBFLength / 2) +var HUBFHullLen = int(math.sqrt(HUBFLength)) + +// +var HUBFDen1 = HUBFShortLen * (HUBFShortLen + 1) / 2 +var HUBFDen2 = HUBFLength * (HUBFLength + 1) / 2 +var HUBFDen3 = HUBFHullLen * (HUBFHullLen + 1) / 2 + +// +var HUBFLcwaCoeffs = array.new_float(HUBFHullLen, 0) +var HUBFHullCoeffs = array.new_float(0) + +// +if barstate.isfirst + // + // Linearly combined WMA coeffs ... + for i = 0 to HUBFLength - 1 + // + HUBFSum1 = math.max(HUBFShortLen - i, 0) + HUBFSum2 = HUBFLength - i + + // + array.unshift(HUBFLcwaCoeffs, 2 * (HUBFSum1 / HUBFDen1) - (HUBFSum2 / HUBFDen2)) + + // + // Zero padding of linearly combined WMA coeffs ... + for i = 0 to HUBFHullLen - 2 + array.unshift(HUBFLcwaCoeffs, 0) + + // + // WMA convolution of linearly combined WMA coeffs ... + for i = HUBFHullLen to array.size(HUBFLcwaCoeffs) - 1 + // + HUBFSum3 = 0.0 + for j = i - HUBFHullLen to i - 1 + HUBFSum3 += array.get(HUBFLcwaCoeffs, j) * (i - j) + + // + array.unshift(HUBFHullCoeffs, HUBFSum3 / HUBFDen3) + +// +var HUBFOs = 0 +var HUBFLen = array.size(HUBFHullCoeffs) - 1 + +// +HUBFHma = 0.0 +HUBFInvHma = 0.0 + +// +for i = 0 to HUBFLen + HUBFHma += HUBFSrc[i] * array.get(HUBFHullCoeffs, i) + HUBFInvHma += HUBFSrc[HUBFLen - i] * array.get(HUBFHullCoeffs, i) + +// +HUBFHso = HUBFHma - HUBFInvHma + +// +HUBFCmean = ta.cum(math.abs(HUBFHso)) / bar_index * HUBFMult + +// +HUBFOs := ta.cross(HUBFHso, HUBFCmean) or ta.cross(HUBFHso, - HUBFCmean) ? 0 : HUBFHso < HUBFHso[1] and HUBFHso > HUBFCmean ? -1 : HUBFHso > HUBFHso[1] and HUBFHso < -HUBFCmean ? 1 : HUBFOs + +// +HUBFCss0 = color.from_gradient(HUBFHso, 0, HUBFCmean, bullishColor1, bullishColor) +HUBFCss1 = color.from_gradient(HUBFHso, - HUBFCmean, 0, bearishColor, bearishColor1) +HUBFCss = HUBFHso > 0 ? HUBFCss0 : HUBFCss1 +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Oscillator line/histogram ... +plot(series = HUBFHso, title = "Hull Butterfly", color = HUBFCss, style = plot.style_histogram) +plot(series = HUBFHso, title = "Hull Butterfly", color = chart.fg_color) + +// +// Bullish Dots ... +plot(series = HUBFOs > HUBFOs[1] and HUBFOs == 1 ? HUBFHso : na, title = "Bullish Dot", color = bullishColor, linewidth = 2, style = plot.style_columns) + +// +// Bearish Dots ... +plot(series = HUBFOs < HUBFOs[1] and HUBFOs == -1 ? HUBFHso : na, title = "Bearish Dot", color = bearishColor, linewidth = 2, style = plot.style_columns) + +// +// Levels ... +plot(series = HUBFCmean, color = color.gray, editable = false) +plot(series = HUBFCmean / 2, color = color.gray, editable = false) +plot(series = -HUBFCmean / 2, color = color.gray, editable = false) +plot(series = -HUBFCmean, color = color.gray, editable = false) +// +// END Plots .... +// + +// +// START Alerts ... +// +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xOscillators/x-saherelm.impulse.macd.pine b/xOscillators/x-saherelm.impulse.macd.pine new file mode 100644 index 0000000..817bf7b --- /dev/null +++ b/xOscillators/x-saherelm.impulse.macd.pine @@ -0,0 +1,110 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Impulse MACD Oscillator +// ------------------------------------------------- +// saherelm implementation of above oscillator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Impulse MACD Oscillator", shorttitle = "XS_IMPMACD_OSC", overlay = false) + +// +// START Inputs .... +// +// +IMPMACDLengthMA = input.int(defval = 34, title = "LenghtMA") +IMPMACDLengthSignal = input.int(defval = 9, title = "Length Signal") +IMPMACDEbc = input.bool(defval = false, title = "Enable bar colors") + +// +IMPMACDShowSignals = input.bool(defval = false, title = "Show Signals", group = "Signals") +IMPMACDShowLongSignals = input.bool(defval = true, title = "Show Long Signals", group = "Signals") +IMPMACDShowShortSignals = input.bool(defval = true, title = "Show Show Signals", group = "Signals") +// +// END Inputs .... +// + +// +// START Functions .... +// +calc_smma(src, len) => + float result = na + rSma = ta.sma(src, len) + result := na(result[1]) ? rSma : (result[1] * (len - 1) + src) / len + result + +calc_zlema(src, length) => + ema1 = ta.ema(src, length) + ema2 = ta.ema(ema1, length) + d = ema1 - ema2 + result = ema1+d + result +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var bullishColor = color.lime +var bearishColor = color.red + +// +IMPMACDSrc = hlc3 +IMPMACDHi = calc_smma(high, IMPMACDLengthMA) +IMPMACDLo = calc_smma(low, IMPMACDLengthMA) +IMPMACDNi = calc_zlema(IMPMACDSrc, IMPMACDLengthMA) + +// +IMPMACDMd = (IMPMACDNi > IMPMACDHi) ? (IMPMACDNi - IMPMACDHi) : (IMPMACDNi < IMPMACDLo) ? (IMPMACDNi - IMPMACDLo) : 0.0 +IMPMACDSb = ta.sma(IMPMACDMd, IMPMACDLengthSignal) +IMPMACDSh = IMPMACDMd - IMPMACDSb + +// +IMPMACDIsBullish = (ta.crossunder(IMPMACDSb, IMPMACDMd) or ta.crossunder(IMPMACDSb[1], IMPMACDMd) or ta.crossunder(IMPMACDSb[2], IMPMACDMd)) and IMPMACDMd < 0 and IMPMACDSh > 0.1 and IMPMACDSb < IMPMACDMd and IMPMACDMd < -0.6 +IMPMACDIsBearish = (ta.crossover(IMPMACDSb, IMPMACDMd) or ta.crossover(IMPMACDSb[1], IMPMACDMd) or ta.crossover(IMPMACDSb[2], IMPMACDMd)) and IMPMACDMd > 0 and IMPMACDSh < -0.1 and IMPMACDSb > IMPMACDMd and IMPMACDMd > 0.6 + +// +IMPMACDMdc = IMPMACDSrc > IMPMACDNi ? IMPMACDSrc > IMPMACDHi ? color.lime : color.green : IMPMACDSrc < IMPMACDLo ? color.red : color.red +// +// END Calculations .... +// + +// +// START Plots .... +// +// +plot(series = 0, color = color.gray, linewidth = 1, title = "MidLine") +plot(series = IMPMACDMd, color = IMPMACDMdc, linewidth = 2, title = "ImpulseMACD", style = plot.style_columns) +plot(series = IMPMACDSh, color = color.yellow, linewidth = 2, title = "ImpulseHisto", style = plot.style_histogram) +plot(IMPMACDSb, color = color.maroon, linewidth = 2, title = "ImpulseMACDCDSignal") + +// +barcolor(IMPMACDEbc ? IMPMACDMdc : na) + +// +plotshape(series = IMPMACDShowSignals and IMPMACDShowLongSignals and IMPMACDIsBullish ? IMPMACDMd : na, title = "Bullish Signals", color = color.rgb(36, 206, 206), style = shape.arrowup, location = location.absolute, size = size.normal) +plotshape(series = IMPMACDShowSignals and IMPMACDShowShortSignals and IMPMACDIsBearish ? IMPMACDMd : na, title = "Bearish Signals", color = color.rgb(49, 39, 134), style = shape.arrowdown, location = location.absolute, size = size.normal) +// +// END Plots .... +// + +// +// START Alerts ... +// +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xOscillators/x-saherelm.multpile.strategies.pine b/xOscillators/x-saherelm.multpile.strategies.pine new file mode 100644 index 0000000..5b15114 --- /dev/null +++ b/xOscillators/x-saherelm.multpile.strategies.pine @@ -0,0 +1,156 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Multpile Strategies Oscillator +// ------------------------------------------------- +// saherelm implementation of above oscillator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Multpile Strategies Oscillator", shorttitle = "XS_MPS_OSC", overlay = false) + +// +// START Inputs .... +// +MPSScale = input.float(defval = 75.0, title = "General scale") + +// +// Momentum ... +MPSShowMomentum = input.bool(defval = true, title = "Show Squeeze Momentum", group = "Squeeze Momentum") +MPSLengthM = input.int(defval = 17, title = "MOM Length", minval = 1, step = 1, group = "Squeeze Momentum") +MPSSrcM = input.source(defval = close, title = "MOM Source", group = "Squeeze Momentum") +MPSLength = input.int(defval = 17, title = "SQZ Length", minval = 1, step = 1, group = "Squeeze Momentum") +MPSSrc = input.source(defval = close, title="SQZ Source", group = "Squeeze Momentum") + +// +// RSI ... +MPSShowRsi = input.bool(defval = true, title = "Show RSI", group = "RSI") +MPSShowRsiFondo = input.bool(defval = true, title = "Show RSI background", group = "RSI") +MPSRsiApart = input.int(defval = 0, title = "RSI Separation", group = "RSI") +MPSLen = input.int(defval = 14, minval = 1, title = "RSI Length", group = "RSI") +MPSUpperR = input.int(defval = 70, title = "RSI Upper Band", group = "RSI") +MPSMiddleR = input.int(defval = 50, title = "RSI Middle Band", group = "RSI") +MPSLowerR = input.int(defval = 30, title = "RSI Lower Band", group = "RSI") + +// +// RSI DIVERGENCE ... +MPSShowRsiDivergence = input.bool(defval = false, title = "Show RSI DIVERGENCE", group = "RSI") +MPSFarRSI = input.int(defval = 70, title = "Adjust RSI DIVERGENCE", group = "RSI") +MPSLenFast = input.int(defval = 5, minval = 1, title = "Fast RSI Length", group = "RSI") +MPSLenSlow = input.int(defval = 14, minval = 1, title = "Slow RSI Length", group = "RSI") +// +// END Inputs .... +// + +// +// START Functions .... +// +biggest(series) => + max = 0.0 + max := nz(max[1], series) + if series > max + max := series + max +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var bullishColor = color.lime +var bearishColor = color.red + +// +// Momentum ... +MPSSz = ta.linreg(MPSSrcM - math.avg(math.avg(ta.highest(high, MPSLengthM), ta.lowest(low, MPSLengthM)), ta.sma(close, MPSLengthM)), MPSLengthM, 0) +MPSNi = biggest(MPSSz) + +// +// Momentum Conditions ... +MPSSc1 = MPSSz >= 0 +MPSSc2 = MPSSz < 0 +MPSSc3 = MPSSz >= MPSSz[1] +MPSSc4 = MPSSz < MPSSz[1] + +// +// Momentum Identifiers ... +isMPSMomentumBullish = (MPSSc1 and MPSSc3) or (MPSSc1 and MPSSc4) +isMPSMomentumBearish = (MPSSc2 and MPSSc4) or (MPSSc2 and MPSSc3) + +// +MPSClr = isMPSMomentumBullish ? bullishColor : isMPSMomentumBearish ? bearishColor : color.gray + +// +// RSI ... +MPSRsi = ta.rsi(MPSSrc, MPSLen) +MPSRsiColor = MPSRsi <= MPSLowerR ? bullishColor : MPSRsi >= MPSUpperR ? bearishColor : #da00ff +MPSRsiScale = (MPSRsi + MPSRsiApart) * MPSNi / MPSScale + +// +MPSB1s = (MPSRsiApart + MPSUpperR) * MPSNi/MPSScale +MPSBm = (MPSRsiApart + MPSMiddleR) * MPSNi/MPSScale +MPSB0s = (MPSRsiApart + MPSLowerR) * MPSNi/MPSScale + +// +// RSI DIVERGENCE ... +MPSSrcSlow = close +MPSSrcFast = close + +// +MPSUpFast = ta.rma(math.max(ta.change(MPSSrcFast), 0), MPSLenFast) +MPSDownFast = ta.rma(-math.min(ta.change(MPSSrcFast), 0), MPSLenFast) +MPSRsiFast = MPSDownFast == 0 ? 100 : MPSUpFast == 0 ? 0 : 100 - (100 / (1 + MPSUpFast / MPSDownFast)) + +// +MPSUpSlow = ta.rma(math.max(ta.change(MPSSrcSlow), 0), MPSLenSlow) +MPSDownSlow = ta.rma(-math.min(ta.change(MPSSrcSlow), 0), MPSLenSlow) +MPSRsiSlow = MPSDownSlow == 0 ? 100 : MPSUpSlow == 0 ? 0 : 100 - (100 / (1 + MPSUpSlow / MPSDownSlow)) + +// +MPSDivergence = MPSRsiFast - MPSRsiSlow +MPSDivergenceScale = MPSDivergence * (MPSNi / MPSScale) + +// +MPSDivergenceColor = MPSDivergence > 0 ? bullishColor : bearishColor +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Momentum ... +plot(MPSShowMomentum ? MPSSz : na, title = "Squeeze Momentum", color = MPSClr, style = plot.style_area) + +// +// RSI ... +plot(MPSShowRsi ? MPSRsiScale : na, "RSI", color = MPSRsiColor) + +// +// Divergence ... +plot(MPSShowRsiDivergence ? MPSDivergenceScale + (MPSFarRSI * MPSNi / MPSScale) : na, "RSI Divergence", color = MPSDivergenceColor) + +// +// END Plots .... +// + +// +// START Alerts ... +// +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xOscillators/x-saherelm.stochastic.pine b/xOscillators/x-saherelm.stochastic.pine new file mode 100644 index 0000000..286800a --- /dev/null +++ b/xOscillators/x-saherelm.stochastic.pine @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center Stochastic Histogram +// --------------------------------------------- +// saherelm implementation of above oscillator ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm Stochastic Histogram", shorttitle = "XS_STHS_OSC", overlay = false) + +// +// START Inputs .... +// +STHSLength = input.int(defval= 14, minval = 1, title = "Length") +STHSSmoothK = input.int(defval = 3, minval = 1, title = "Smooth K") +// +// END Inputs .... +// + +// +// START Functions .... +// +// +// END Functions .... +// + +// +// START Calculations .... +// +STHSK = (ta.sma(ta.stoch(close, high, low, STHSLength), STHSSmoothK) - 50) +STHSColor = (STHSK > 0) ? color.green : (STHSK < 0) ? color.red : color.black +// +// +// END Calculations .... +// + +// +// START Plots .... +// +// Draw Area ... +// +plot(series = STHSK, style = plot.style_histogram, color = STHSColor, title = "Histogram") +plot(series = STHSK, color = color.black, title = "Histogram Line") +// +// END Plots .... +// + +// +// START Alerts ... +// +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xSamples/indicators/all-candlestick.patterns.pine b/xSamples/indicators/all-candlestick.patterns.pine new file mode 100644 index 0000000..7e03be2 --- /dev/null +++ b/xSamples/indicators/all-candlestick.patterns.pine @@ -0,0 +1,514 @@ +//@version=5 +indicator("*All Candlestick Patterns*", shorttitle = "All Patterns", overlay=true) + +C_DownTrend = true +C_UpTrend = true +var trendRule1 = "SMA50" +var trendRule2 = "SMA50, SMA200" +var trendRule = input.string(trendRule1, "Detect Trend Based On", options=[trendRule1, trendRule2, "No detection"]) + +if trendRule == trendRule1 + priceAvg = ta.sma(close, 50) + C_DownTrend := close < priceAvg + C_UpTrend := close > priceAvg + +if trendRule == trendRule2 + sma200 = ta.sma(close, 200) + sma50 = ta.sma(close, 50) + C_DownTrend := close < sma50 and sma50 < sma200 + C_UpTrend := close > sma50 and sma50 > sma200 +C_Len = 14 // ta.ema depth for bodyAvg +C_ShadowPercent = 5.0 // size of shadows +C_ShadowEqualsPercent = 100.0 +C_DojiBodyPercent = 5.0 +C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body + +C_BodyHi = math.max(close, open) +C_BodyLo = math.min(close, open) +C_Body = C_BodyHi - C_BodyLo +C_BodyAvg = ta.ema(C_Body, C_Len) +C_SmallBody = C_Body < C_BodyAvg +C_LongBody = C_Body > C_BodyAvg +C_UpShadow = high - C_BodyHi +C_DnShadow = C_BodyLo - low +C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body +C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body +C_WhiteBody = open < close +C_BlackBody = open > close +C_Range = high-low +C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo +C_BodyMiddle = C_Body / 2 + C_BodyLo +C_ShadowEquals = C_UpShadow == C_DnShadow or (math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent +C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 +C_Doji = C_IsDojiBody and C_ShadowEquals + +patternLabelPosLow = low - (ta.atr(30) * 0.6) +patternLabelPosHigh = high + (ta.atr(30) * 0.6) + +label_color_bullish = input(color.blue, "Label Color Bullish") +label_color_bearish = input(color.red, "Label Color Bearish") +label_color_neutral = input(color.gray, "Label Color Neutral") +CandleType = input.string(title = "Pattern Type", defval="Both", options=["Bullish", "Bearish", "Both"]) + +AbandonedBabyInput = input(title = "Abandoned Baby" ,defval=true) + +DarkCloudCoverInput = input(title = "Dark Cloud Cover" ,defval=false) + +DojiInput = input(title = "Doji" ,defval=true) + +DojiStarInput = input(title = "Doji Star" ,defval=false) + +DownsideTasukiGapInput = input(title = "Downside Tasuki Gap" ,defval=false) + +DragonflyDojiInput = input(title = "Dragonfly Doji" ,defval=true) + +EngulfingInput = input(title = "Engulfing" ,defval=true) + +EveningDojiStarInput = input(title = "Evening Doji Star" ,defval=false) + +EveningStarInput = input(title = "Evening Star" ,defval=false) + +FallingThreeMethodsInput = input(title = "Falling Three Methods" ,defval=false) + +FallingWindowInput = input(title = "Falling Window" ,defval=false) + +GravestoneDojiInput = input(title = "Gravestone Doji" ,defval=false) + +HammerInput = input(title = "Hammer" ,defval=true) + +HangingManInput = input(title = "Hanging Man" ,defval=false) + +HaramiCrossInput = input(title = "Harami Cross" ,defval=false) + +HaramiInput = input(title = "Harami" ,defval=false) + +InvertedHammerInput = input(title = "Inverted Hammer" ,defval=false) + +KickingInput = input(title = "Kicking" ,defval=false) + +LongLowerShadowInput = input(title = "Long Lower Shadow" ,defval=false) + +LongUpperShadowInput = input(title = "Long Upper Shadow" ,defval=false) + +MarubozuBlackInput = input(title = "Marubozu Black" ,defval=false) + +MarubozuWhiteInput = input(title = "Marubozu White" ,defval=false) + +MorningDojiStarInput = input(title = "Morning Doji Star" ,defval=false) + +MorningStarInput = input(title = "Morning Star" ,defval=false) + +OnNeckInput = input(title = "On Neck" ,defval=false) + +PiercingInput = input(title = "Piercing" ,defval=false) + +RisingThreeMethodsInput = input(title = "Rising Three Methods" ,defval=false) + +RisingWindowInput = input(title = "Rising Window" ,defval=false) + +ShootingStarInput = input(title = "Shooting Star" ,defval=false) + +SpinningTopBlackInput = input(title = "Spinning Top Black" ,defval=false) + +SpinningTopWhiteInput = input(title = "Spinning Top White" ,defval=false) + +ThreeBlackCrowsInput = input(title = "Three Black Crows" ,defval=false) + +ThreeWhiteSoldiersInput = input(title = "Three White Soldiers" ,defval=false) + +TriStarInput = input(title = "Tri-Star" ,defval=false) + +TweezerBottomInput = input(title = "Tweezer Bottom" ,defval=false) + +TweezerTopInput = input(title = "Tweezer Top" ,defval=false) + +UpsideTasukiGapInput = input(title = "Upside Tasuki Gap" ,defval=false) + +C_OnNeckBearishNumberOfCandles = 2 +C_OnNeckBearish = false +if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_WhiteBody and open < close[1] and C_SmallBody and C_Range!=0 and math.abs(close-low[1])<=C_BodyAvg*0.05 + C_OnNeckBearish := true +alertcondition(C_OnNeckBearish, title = "On Neck – Bearish", message = "New On Neck – Bearish pattern detected") +if C_OnNeckBearish and OnNeckInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishOnNeck = "On Neck\nOn Neck is a two-line continuation pattern found in a downtrend. The first candle is long and red, the second candle is short and has a green body. The closing price of the second candle is close or equal to the first candle's low price. The pattern hints at a continuation of a downtrend, and penetrating the low of the green candlestick is sometimes considered a confirmation. " + label.new(bar_index, patternLabelPosHigh, text="ON", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishOnNeck) +C_RisingWindowBullishNumberOfCandles = 2 +C_RisingWindowBullish = false +if C_UpTrend[1] and (C_Range!=0 and C_Range[1]!=0) and low > high[1] + C_RisingWindowBullish := true +alertcondition(C_RisingWindowBullish, title = "Rising Window – Bullish", message = "New Rising Window – Bullish pattern detected") +if C_RisingWindowBullish and RisingWindowInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishRisingWindow = "Rising Window\nRising Window is a two-candle bullish continuation pattern that forms during an uptrend. Both candles in the pattern can be of any type with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle's high and the second candle's low. That gap (window) between two bars signifies support against the selling pressure." + label.new(bar_index, patternLabelPosLow, text="RW", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishRisingWindow) +C_FallingWindowBearishNumberOfCandles = 2 +C_FallingWindowBearish = false +if C_DownTrend[1] and (C_Range!=0 and C_Range[1]!=0) and high < low[1] + C_FallingWindowBearish := true +alertcondition(C_FallingWindowBearish, title = "Falling Window – Bearish", message = "New Falling Window – Bearish pattern detected") +if C_FallingWindowBearish and FallingWindowInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishFallingWindow = "Falling Window\nFalling Window is a two-candle bearish continuation pattern that forms during a downtrend. Both candles in the pattern can be of any type, with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle's low and the second candle's high. The existence of this gap (window) means that the bearish trend is expected to continue." + label.new(bar_index, patternLabelPosHigh, text="FW", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishFallingWindow) +C_FallingThreeMethodsBearishNumberOfCandles = 5 +C_FallingThreeMethodsBearish = false +if C_DownTrend[4] and (C_LongBody[4] and C_BlackBody[4]) and (C_SmallBody[3] and C_WhiteBody[3] and open[3]>low[4] and close[3]low[4] and close[2]low[4] and close[1]low[4]) and (C_SmallBody[2] and C_BlackBody[2] and open[2]low[4]) and (C_SmallBody[1] and C_BlackBody[1] and open[1]low[4]) and (C_LongBody and C_WhiteBody and close>close[4]) + C_RisingThreeMethodsBullish := true +alertcondition(C_RisingThreeMethodsBullish, title = "Rising Three Methods – Bullish", message = "New Rising Three Methods – Bullish pattern detected") +if C_RisingThreeMethodsBullish and RisingThreeMethodsInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishRisingThreeMethods = "Rising Three Methods\nRising Three Methods is a five-candle bullish pattern that signifies a continuation of an existing uptrend. The first candle is long and green, followed by three short red candles with bodies inside the range of the first candle. The last candle is also green and long and it closes above the close of the first candle. This decisive fifth strongly bullish candle hints that bears could not reverse the prior uptrend and that bulls have regained control of the market." + label.new(bar_index, patternLabelPosLow, text="RTM", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishRisingThreeMethods) +C_TweezerTopBearishNumberOfCandles = 2 +C_TweezerTopBearish = false +if C_UpTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and math.abs(high-high[1]) <= C_BodyAvg*0.05 and C_WhiteBody[1] and C_BlackBody and C_LongBody[1] + C_TweezerTopBearish := true +alertcondition(C_TweezerTopBearish, title = "Tweezer Top – Bearish", message = "New Tweezer Top – Bearish pattern detected") +if C_TweezerTopBearish and TweezerTopInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishTweezerTop = "Tweezer Top\nTweezer Top is a two-candle pattern that signifies a potential bearish reversal. The pattern is found during an uptrend. The first candle is long and green, the second candle is red, and its high is nearly identical to the high of the previous candle. The virtually identical highs, together with the inverted directions, hint that bears might be taking over the market." + label.new(bar_index, patternLabelPosHigh, text="TT", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishTweezerTop) +C_TweezerBottomBullishNumberOfCandles = 2 +C_TweezerBottomBullish = false +if C_DownTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and math.abs(low-low[1]) <= C_BodyAvg*0.05 and C_BlackBody[1] and C_WhiteBody and C_LongBody[1] + C_TweezerBottomBullish := true +alertcondition(C_TweezerBottomBullish, title = "Tweezer Bottom – Bullish", message = "New Tweezer Bottom – Bullish pattern detected") +if C_TweezerBottomBullish and TweezerBottomInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishTweezerBottom = "Tweezer Bottom\nTweezer Bottom is a two-candle pattern that signifies a potential bullish reversal. The pattern is found during a downtrend. The first candle is long and red, the second candle is green, its lows nearly identical to the low of the previous candle. The virtually identical lows together with the inverted directions hint that bulls might be taking over the market." + label.new(bar_index, patternLabelPosLow, text="TB", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishTweezerBottom) +C_DarkCloudCoverBearishNumberOfCandles = 2 +C_DarkCloudCoverBearish = false +if (C_UpTrend[1] and C_WhiteBody[1] and C_LongBody[1]) and (C_BlackBody and open >= high[1] and close < C_BodyMiddle[1] and close > open[1]) + C_DarkCloudCoverBearish := true +alertcondition(C_DarkCloudCoverBearish, title = "Dark Cloud Cover – Bearish", message = "New Dark Cloud Cover – Bearish pattern detected") +if C_DarkCloudCoverBearish and DarkCloudCoverInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishDarkCloudCover = "Dark Cloud Cover\nDark Cloud Cover is a two-candle bearish reversal candlestick pattern found in an uptrend. The first candle is green and has a larger than average body. The second candle is red and opens above the high of the prior candle, creating a gap, and then closes below the midpoint of the first candle. The pattern shows a possible shift in the momentum from the upside to the downside, indicating that a reversal might happen soon." + label.new(bar_index, patternLabelPosHigh, text="DCC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDarkCloudCover) +C_DownsideTasukiGapBearishNumberOfCandles = 3 +C_DownsideTasukiGapBearish = false +if C_LongBody[2] and C_SmallBody[1] and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_BlackBody[1] and C_WhiteBody and C_BodyHi <= C_BodyLo[2] and C_BodyHi >= C_BodyHi[1] + C_DownsideTasukiGapBearish := true +alertcondition(C_DownsideTasukiGapBearish, title = "Downside Tasuki Gap – Bearish", message = "New Downside Tasuki Gap – Bearish pattern detected") +if C_DownsideTasukiGapBearish and DownsideTasukiGapInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishDownsideTasukiGap = "Downside Tasuki Gap\nDownside Tasuki Gap is a three-candle pattern found in a downtrend that usually hints at the continuation of the downtrend. The first candle is long and red, followed by a smaller red candle with its opening price that gaps below the body of the previous candle. The third candle is green and it closes inside the gap created by the first two candles, unable to close it fully. The bull’s inability to close that gap hints that the downtrend might continue." + label.new(bar_index, patternLabelPosHigh, text="DTG", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDownsideTasukiGap) +C_UpsideTasukiGapBullishNumberOfCandles = 3 +C_UpsideTasukiGapBullish = false +if C_LongBody[2] and C_SmallBody[1] and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_WhiteBody[1] and C_BlackBody and C_BodyLo >= C_BodyHi[2] and C_BodyLo <= C_BodyLo[1] + C_UpsideTasukiGapBullish := true +alertcondition(C_UpsideTasukiGapBullish, title = "Upside Tasuki Gap – Bullish", message = "New Upside Tasuki Gap – Bullish pattern detected") +if C_UpsideTasukiGapBullish and UpsideTasukiGapInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishUpsideTasukiGap = "Upside Tasuki Gap\nUpside Tasuki Gap is a three-candle pattern found in an uptrend that usually hints at the continuation of the uptrend. The first candle is long and green, followed by a smaller green candle with its opening price that gaps above the body of the previous candle. The third candle is red and it closes inside the gap created by the first two candles, unable to close it fully. The bear’s inability to close the gap hints that the uptrend might continue." + label.new(bar_index, patternLabelPosLow, text="UTG", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishUpsideTasukiGap) +C_EveningDojiStarBearishNumberOfCandles = 3 +C_EveningDojiStarBearish = false +if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi + C_EveningDojiStarBearish := true +alertcondition(C_EveningDojiStarBearish, title = "Evening Doji Star – Bearish", message = "New Evening Doji Star – Bearish pattern detected") +if C_EveningDojiStarBearish and EveningDojiStarInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishEveningDojiStar = "Evening Doji Star\nThis candlestick pattern is a variation of the Evening Star pattern. It is bearish and continues an uptrend with a long-bodied, green candle day. It is then followed by a gap and a Doji candle and concludes with a downward close. The close would be below the first day’s midpoint. It is more bearish than the regular evening star pattern because of the existence of the Doji." + label.new(bar_index, patternLabelPosHigh, text="EDS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEveningDojiStar) +C_DojiStarBearishNumberOfCandles = 2 +C_DojiStarBearish = false +if C_UpTrend and C_WhiteBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyLo > C_BodyHi[1] + C_DojiStarBearish := true +alertcondition(C_DojiStarBearish, title = "Doji Star – Bearish", message = "New Doji Star – Bearish pattern detected") +if C_DojiStarBearish and DojiStarInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishDojiStar = "Doji Star\nThis is a bearish reversal candlestick pattern that is found in an uptrend and consists of two candles. First comes a long green candle, followed by a Doji candle (except 4-Price Doji) that opens above the body of the first one, creating a gap. It is considered a reversal signal with confirmation during the next trading day." + label.new(bar_index, patternLabelPosHigh, text="DS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDojiStar) +C_DojiStarBullishNumberOfCandles = 2 +C_DojiStarBullish = false +if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyHi < C_BodyLo[1] + C_DojiStarBullish := true +alertcondition(C_DojiStarBullish, title = "Doji Star – Bullish", message = "New Doji Star – Bullish pattern detected") +if C_DojiStarBullish and DojiStarInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishDojiStar = "Doji Star\nThis is a bullish reversal candlestick pattern that is found in a downtrend and consists of two candles. First comes a long red candle, followed by a Doji candle (except 4-Price Doji) that opens below the body of the first one, creating a gap. It is considered a reversal signal with confirmation during the next trading day." + label.new(bar_index, patternLabelPosLow, text="DS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishDojiStar) +C_MorningDojiStarBullishNumberOfCandles = 3 +C_MorningDojiStarBullish = false +if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo + C_MorningDojiStarBullish := true +alertcondition(C_MorningDojiStarBullish, title = "Morning Doji Star – Bullish", message = "New Morning Doji Star – Bullish pattern detected") +if C_MorningDojiStarBullish and MorningDojiStarInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishMorningDojiStar = "Morning Doji Star\nThis candlestick pattern is a variation of the Morning Star pattern. A three-day bullish reversal pattern, which consists of three candlesticks will look something like this: The first being a long-bodied red candle that extends the current downtrend. Next comes a Doji that gaps down on the open. After that comes a long-bodied green candle, which gaps up on the open and closes above the midpoint of the body of the first day. It is more bullish than the regular morning star pattern because of the existence of the Doji." + label.new(bar_index, patternLabelPosLow, text="MDS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMorningDojiStar) +C_PiercingBullishNumberOfCandles = 2 +C_PiercingBullish = false +if (C_DownTrend[1] and C_BlackBody[1] and C_LongBody[1]) and (C_WhiteBody and open <= low[1] and close > C_BodyMiddle[1] and close < open[1]) + C_PiercingBullish := true +alertcondition(C_PiercingBullish, title = "Piercing – Bullish", message = "New Piercing – Bullish pattern detected") +if C_PiercingBullish and PiercingInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishPiercing = "Piercing\nPiercing is a two-candle bullish reversal candlestick pattern found in a downtrend. The first candle is red and has a larger than average body. The second candle is green and opens below the low of the prior candle, creating a gap, and then closes above the midpoint of the first candle. The pattern shows a possible shift in the momentum from the downside to the upside, indicating that a reversal might happen soon." + label.new(bar_index, patternLabelPosLow, text="P", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishPiercing) +C_HammerBullishNumberOfCandles = 1 +C_HammerBullish = false +if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow + if C_DownTrend + C_HammerBullish := true +alertcondition(C_HammerBullish, title = "Hammer – Bullish", message = "New Hammer – Bullish pattern detected") +if C_HammerBullish and HammerInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishHammer = "Hammer\nHammer candlesticks form when a security moves lower after the open, but continues to rally into close above the intraday low. The candlestick that you are left with will look like a square attached to a long stick-like figure. This candlestick is called a Hammer if it happens to form during a decline." + label.new(bar_index, patternLabelPosLow, text="H", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHammer) +C_HangingManBearishNumberOfCandles = 1 +C_HangingManBearish = false +if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow + if C_UpTrend + C_HangingManBearish := true +alertcondition(C_HangingManBearish, title = "Hanging Man – Bearish", message = "New Hanging Man – Bearish pattern detected") +if C_HangingManBearish and HangingManInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishHangingMan = "Hanging Man\nWhen a specified security notably moves lower after the open, but continues to rally to close above the intraday low, a Hanging Man candlestick will form. The candlestick will resemble a square, attached to a long stick-like figure. It is referred to as a Hanging Man if the candlestick forms during an advance." + label.new(bar_index, patternLabelPosHigh, text="HM", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHangingMan) +C_ShootingStarBearishNumberOfCandles = 1 +C_ShootingStarBearish = false +if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow + if C_UpTrend + C_ShootingStarBearish := true +alertcondition(C_ShootingStarBearish, title = "Shooting Star – Bearish", message = "New Shooting Star – Bearish pattern detected") +if C_ShootingStarBearish and ShootingStarInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishShootingStar = "Shooting Star\nThis single day pattern can appear during an uptrend and opens high, while it closes near its open. It trades much higher as well. It is bearish in nature, but looks like an Inverted Hammer." + label.new(bar_index, patternLabelPosHigh, text="SS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishShootingStar) +C_InvertedHammerBullishNumberOfCandles = 1 +C_InvertedHammerBullish = false +if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow + if C_DownTrend + C_InvertedHammerBullish := true +alertcondition(C_InvertedHammerBullish, title = "Inverted Hammer – Bullish", message = "New Inverted Hammer – Bullish pattern detected") +if C_InvertedHammerBullish and InvertedHammerInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishInvertedHammer = "Inverted Hammer\nIf in a downtrend, then the open is lower. When it eventually trades higher, but closes near its open, it will look like an inverted version of the Hammer Candlestick. This is a one-day bullish reversal pattern." + label.new(bar_index, patternLabelPosLow, text="IH", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishInvertedHammer) +C_MorningStarBullishNumberOfCandles = 3 +C_MorningStarBullish = false +if C_LongBody[2] and C_SmallBody[1] and C_LongBody + if C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo + C_MorningStarBullish := true +alertcondition(C_MorningStarBullish, title = "Morning Star – Bullish", message = "New Morning Star – Bullish pattern detected") +if C_MorningStarBullish and MorningStarInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishMorningStar = "Morning Star\nA three-day bullish reversal pattern, which consists of three candlesticks will look something like this: The first being a long-bodied red candle that extends the current downtrend. Next comes a short, middle candle that gaps down on the open. After comes a long-bodied green candle, which gaps up on the open and closes above the midpoint of the body of the first day." + label.new(bar_index, patternLabelPosLow, text="MS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMorningStar) +C_EveningStarBearishNumberOfCandles = 3 +C_EveningStarBearish = false +if C_LongBody[2] and C_SmallBody[1] and C_LongBody + if C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi + C_EveningStarBearish := true +alertcondition(C_EveningStarBearish, title = "Evening Star – Bearish", message = "New Evening Star – Bearish pattern detected") +if C_EveningStarBearish and EveningStarInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishEveningStar = "Evening Star\nThis candlestick pattern is bearish and continues an uptrend with a long-bodied, green candle day. It is then followed by a gapped and small-bodied candle day, and concludes with a downward close. The close would be below the first day’s midpoint." + label.new(bar_index, patternLabelPosHigh, text="ES", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEveningStar) +C_MarubozuWhiteBullishNumberOfCandles = 1 +C_MarubozuShadowPercentWhite = 5.0 +C_MarubozuWhiteBullish = C_WhiteBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_DnShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_WhiteBody +alertcondition(C_MarubozuWhiteBullish, title = "Marubozu White – Bullish", message = "New Marubozu White – Bullish pattern detected") +if C_MarubozuWhiteBullish and MarubozuWhiteInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishMarubozuWhite = "Marubozu White\nA Marubozu White Candle is a candlestick that does not have a shadow that extends from its candle body at either the open or the close. Marubozu is Japanese for “close-cropped” or “close-cut.” Other sources may call it a Bald or Shaven Head Candle." + label.new(bar_index, patternLabelPosLow, text="MW", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMarubozuWhite) +C_MarubozuBlackBearishNumberOfCandles = 1 +C_MarubozuShadowPercentBearish = 5.0 +C_MarubozuBlackBearish = C_BlackBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_DnShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_BlackBody +alertcondition(C_MarubozuBlackBearish, title = "Marubozu Black – Bearish", message = "New Marubozu Black – Bearish pattern detected") +if C_MarubozuBlackBearish and MarubozuBlackInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishMarubozuBlack = "Marubozu Black\nThis is a candlestick that has no shadow, which extends from the red-bodied candle at the open, the close, or even at both. In Japanese, the name means “close-cropped” or “close-cut.” The candlestick can also be referred to as Bald or Shaven Head." + label.new(bar_index, patternLabelPosHigh, text="MB", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishMarubozuBlack) +C_DojiNumberOfCandles = 1 +C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body +C_GravestoneDojiOne = C_IsDojiBody and C_DnShadow <= C_Body +alertcondition(C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne, title = "Doji", message = "New Doji pattern detected") +if C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne and DojiInput + var ttDoji = "Doji\nWhen the open and close of a security are essentially equal to each other, a doji candle forms. The length of both upper and lower shadows may vary, causing the candlestick you are left with to either resemble a cross, an inverted cross, or a plus sign. Doji candles show the playout of buyer-seller indecision in a tug-of-war of sorts. As price moves either above or below the opening level during the session, the close is either at or near the opening level." + label.new(bar_index, patternLabelPosLow, text="D", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttDoji) +C_GravestoneDojiBearishNumberOfCandles = 1 +C_GravestoneDojiBearish = C_IsDojiBody and C_DnShadow <= C_Body +alertcondition(C_GravestoneDojiBearish, title = "Gravestone Doji – Bearish", message = "New Gravestone Doji – Bearish pattern detected") +if C_GravestoneDojiBearish and GravestoneDojiInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishGravestoneDoji = "Gravestone Doji\nWhen a doji is at or is close to the day’s low point, a doji line will develop." + label.new(bar_index, patternLabelPosHigh, text="GD", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishGravestoneDoji) +C_DragonflyDojiBullishNumberOfCandles = 1 +C_DragonflyDojiBullish = C_IsDojiBody and C_UpShadow <= C_Body +alertcondition(C_DragonflyDojiBullish, title = "Dragonfly Doji – Bullish", message = "New Dragonfly Doji – Bullish pattern detected") +if C_DragonflyDojiBullish and DragonflyDojiInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishDragonflyDoji = "Dragonfly Doji\nSimilar to other Doji days, this particular Doji also regularly appears at pivotal market moments. This is a specific Doji where both the open and close price are at the high of a given day." + label.new(bar_index, patternLabelPosLow, text="DD", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishDragonflyDoji) +C_HaramiCrossBullishNumberOfCandles = 2 +C_HaramiCrossBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] +alertcondition(C_HaramiCrossBullish, title = "Harami Cross – Bullish", message = "New Harami Cross – Bullish pattern detected") +if C_HaramiCrossBullish and HaramiCrossInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishHaramiCross = "Harami Cross\nThis candlestick pattern is a variation of the Harami Bullish pattern. It is found during a downtrend. The two-day candlestick pattern consists of a Doji candle that is entirely encompassed within the body of what was once a red-bodied candle." + label.new(bar_index, patternLabelPosLow, text="HC", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHaramiCross) +C_HaramiCrossBearishNumberOfCandles = 2 +C_HaramiCrossBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] +alertcondition(C_HaramiCrossBearish, title = "Harami Cross – Bearish", message = "New Harami Cross – Bearish pattern detected") +if C_HaramiCrossBearish and HaramiCrossInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishHaramiCross = "Harami Cross\nThis candlestick pattern is a variation of the Harami Bearish pattern. It is found during an uptrend. This is a two-day candlestick pattern with a Doji candle that is entirely encompassed within the body that was once a green-bodied candle. The Doji shows that some indecision has entered the minds of sellers, and the pattern hints that the trend might reverse." + label.new(bar_index, patternLabelPosHigh, text="HC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHaramiCross) +C_HaramiBullishNumberOfCandles = 2 +C_HaramiBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_WhiteBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] +alertcondition(C_HaramiBullish, title = "Harami – Bullish", message = "New Harami – Bullish pattern detected") +if C_HaramiBullish and HaramiInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishHarami = "Harami\nThis two-day candlestick pattern consists of a small-bodied green candle that is entirely encompassed within the body of what was once a red-bodied candle." + label.new(bar_index, patternLabelPosLow, text="BH", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHarami) +C_HaramiBearishNumberOfCandles = 2 +C_HaramiBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_BlackBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] +alertcondition(C_HaramiBearish, title = "Harami – Bearish", message = "New Harami – Bearish pattern detected") +if C_HaramiBearish and HaramiInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishHarami = "Harami\nThis is a two-day candlestick pattern with a small, red-bodied candle that is entirely encompassed within the body that was once a green-bodied candle." + label.new(bar_index, patternLabelPosHigh, text="BH", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHarami) +C_LongLowerShadowBullishNumberOfCandles = 1 +C_LongLowerShadowPercent = 75.0 +C_LongLowerShadowBullish = C_DnShadow > C_Range/100*C_LongLowerShadowPercent +alertcondition(C_LongLowerShadowBullish, title = "Long Lower Shadow – Bullish", message = "New Long Lower Shadow – Bullish pattern detected") +if C_LongLowerShadowBullish and LongLowerShadowInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishLongLowerShadow = "Long Lower Shadow\nTo indicate seller domination of the first part of a session, candlesticks will present with long lower shadows and short upper shadows, consequently lowering prices." + label.new(bar_index, patternLabelPosLow, text="LLS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishLongLowerShadow) +C_LongUpperShadowBearishNumberOfCandles = 1 +C_LongShadowPercent = 75.0 +C_LongUpperShadowBearish = C_UpShadow > C_Range/100*C_LongShadowPercent +alertcondition(C_LongUpperShadowBearish, title = "Long Upper Shadow – Bearish", message = "New Long Upper Shadow – Bearish pattern detected") +if C_LongUpperShadowBearish and LongUpperShadowInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishLongUpperShadow = "Long Upper Shadow\nTo indicate buyer domination of the first part of a session, candlesticks will present with long upper shadows, as well as short lower shadows, consequently raising bidding prices." + label.new(bar_index, patternLabelPosHigh, text="LUS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishLongUpperShadow) +C_SpinningTopWhiteNumberOfCandles = 1 +C_SpinningTopWhitePercent = 34.0 +C_IsSpinningTopWhite = C_DnShadow >= C_Range / 100 * C_SpinningTopWhitePercent and C_UpShadow >= C_Range / 100 * C_SpinningTopWhitePercent and not C_IsDojiBody +C_SpinningTopWhite = C_IsSpinningTopWhite and C_WhiteBody +alertcondition(C_SpinningTopWhite, title = "Spinning Top White", message = "New Spinning Top White pattern detected") +if C_SpinningTopWhite and SpinningTopWhiteInput + var ttSpinningTopWhite = "Spinning Top White\nWhite spinning tops are candlestick lines that are small, green-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision between buyer and seller." + label.new(bar_index, patternLabelPosLow, text="STW", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttSpinningTopWhite) +C_SpinningTopBlackNumberOfCandles = 1 +C_SpinningTopBlackPercent = 34.0 +C_IsSpinningTop = C_DnShadow >= C_Range / 100 * C_SpinningTopBlackPercent and C_UpShadow >= C_Range / 100 * C_SpinningTopBlackPercent and not C_IsDojiBody +C_SpinningTopBlack = C_IsSpinningTop and C_BlackBody +alertcondition(C_SpinningTopBlack, title = "Spinning Top Black", message = "New Spinning Top Black pattern detected") +if C_SpinningTopBlack and SpinningTopBlackInput + var ttSpinningTopBlack = "Spinning Top Black\nBlack spinning tops are candlestick lines that are small, red-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision." + label.new(bar_index, patternLabelPosLow, text="STB", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttSpinningTopBlack) +C_ThreeWhiteSoldiersBullishNumberOfCandles = 3 +C_3WSld_ShadowPercent = 5.0 +C_3WSld_HaveNotUpShadow = C_Range * C_3WSld_ShadowPercent / 100 > C_UpShadow +C_ThreeWhiteSoldiersBullish = false +if C_LongBody and C_LongBody[1] and C_LongBody[2] + if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2] + C_ThreeWhiteSoldiersBullish := close > close[1] and close[1] > close[2] and open < close[1] and open > open[1] and open[1] < close[2] and open[1] > open[2] and C_3WSld_HaveNotUpShadow and C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2] +alertcondition(C_ThreeWhiteSoldiersBullish, title = "Three White Soldiers – Bullish", message = "New Three White Soldiers – Bullish pattern detected") +if C_ThreeWhiteSoldiersBullish and ThreeWhiteSoldiersInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishThreeWhiteSoldiers = "Three White Soldiers\nThis bullish reversal pattern is made up of three long-bodied, green candles in immediate succession. Each one opens within the body before it and the close is near to the daily high." + label.new(bar_index, patternLabelPosLow, text="3WS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishThreeWhiteSoldiers) +C_ThreeBlackCrowsBearishNumberOfCandles = 3 +C_3BCrw_ShadowPercent = 5.0 +C_3BCrw_HaveNotDnShadow = C_Range * C_3BCrw_ShadowPercent / 100 > C_DnShadow +C_ThreeBlackCrowsBearish = false +if C_LongBody and C_LongBody[1] and C_LongBody[2] + if C_BlackBody and C_BlackBody[1] and C_BlackBody[2] + C_ThreeBlackCrowsBearish := close < close[1] and close[1] < close[2] and open > close[1] and open < open[1] and open[1] > close[2] and open[1] < open[2] and C_3BCrw_HaveNotDnShadow and C_3BCrw_HaveNotDnShadow[1] and C_3BCrw_HaveNotDnShadow[2] +alertcondition(C_ThreeBlackCrowsBearish, title = "Three Black Crows – Bearish", message = "New Three Black Crows – Bearish pattern detected") +if C_ThreeBlackCrowsBearish and ThreeBlackCrowsInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishThreeBlackCrows = "Three Black Crows\nThis is a bearish reversal pattern that consists of three long, red-bodied candles in immediate succession. For each of these candles, each day opens within the body of the day before and closes either at or near its low." + label.new(bar_index, patternLabelPosHigh, text="3BC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishThreeBlackCrows) +C_EngulfingBullishNumberOfCandles = 2 +C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and C_SmallBody[1] and close >= open[1] and open <= close[1] and ( close > open[1] or open < close[1] ) +alertcondition(C_EngulfingBullish, title = "Engulfing – Bullish", message = "New Engulfing – Bullish pattern detected") +if C_EngulfingBullish and EngulfingInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishEngulfing = "Engulfing\nAt the end of a given downward trend, there will most likely be a reversal pattern. To distinguish the first day, this candlestick pattern uses a small body, followed by a day where the candle body fully overtakes the body from the day before, and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to completely overtake the range (high to low), rather only the open and the close." + label.new(bar_index, patternLabelPosLow, text="BE", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishEngulfing) +C_EngulfingBearishNumberOfCandles = 2 +C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and C_SmallBody[1] and close <= open[1] and open >= close[1] and ( close < open[1] or open > close[1] ) +alertcondition(C_EngulfingBearish, title = "Engulfing – Bearish", message = "New Engulfing – Bearish pattern detected") +if C_EngulfingBearish and EngulfingInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishEngulfing = "Engulfing\nAt the end of a given uptrend, a reversal pattern will most likely appear. During the first day, this candlestick pattern uses a small body. It is then followed by a day where the candle body fully overtakes the body from the day before it and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to fully overtake the range (high to low), rather only the open and the close." + label.new(bar_index, patternLabelPosHigh, text="BE", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEngulfing) +C_AbandonedBabyBullishNumberOfCandles = 3 +C_AbandonedBabyBullish = C_DownTrend[2] and C_BlackBody[2] and C_IsDojiBody[1] and low[2] > high[1] and C_WhiteBody and high[1] < low +alertcondition(C_AbandonedBabyBullish, title = "Abandoned Baby – Bullish", message = "New Abandoned Baby – Bullish pattern detected") +if C_AbandonedBabyBullish and AbandonedBabyInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishAbandonedBaby = "Abandoned Baby\nThis candlestick pattern is quite rare as far as reversal patterns go. The first of the pattern is a large down candle. Next comes a doji candle that gaps below the candle before it. The doji candle is then followed by another candle that opens even higher and swiftly moves to the upside." + label.new(bar_index, patternLabelPosLow, text="AB", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishAbandonedBaby) +C_AbandonedBabyBearishNumberOfCandles = 3 +C_AbandonedBabyBearish = C_UpTrend[2] and C_WhiteBody[2] and C_IsDojiBody[1] and high[2] < low[1] and C_BlackBody and low[1] > high +alertcondition(C_AbandonedBabyBearish, title = "Abandoned Baby – Bearish", message = "New Abandoned Baby – Bearish pattern detected") +if C_AbandonedBabyBearish and AbandonedBabyInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishAbandonedBaby = "Abandoned Baby\nA bearish abandoned baby is a specific candlestick pattern that often signals a downward reversal trend in terms of security price. It is formed when a gap appears between the lowest price of a doji-like candle and the candlestick of the day before. The earlier candlestick is green, tall, and has small shadows. The doji candle is also tailed by a gap between its lowest price point and the highest price point of the candle that comes next, which is red, tall and also has small shadows. The doji candle shadows must completely gap either below or above the shadows of the first and third day in order to have the abandoned baby pattern effect." + label.new(bar_index, patternLabelPosHigh, text="AB", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishAbandonedBaby) +C_TriStarBullishNumberOfCandles = 3 +C_3DojisBullish = C_Doji[2] and C_Doji[1] and C_Doji +C_BodyGapUpBullish = C_BodyHi[1] < C_BodyLo +C_BodyGapDnBullish = C_BodyLo[1] > C_BodyHi +C_TriStarBullish = C_3DojisBullish and C_DownTrend[2] and C_BodyGapDnBullish[1] and C_BodyGapUpBullish +alertcondition(C_TriStarBullish, title = "Tri-Star – Bullish", message = "New Tri-Star – Bullish pattern detected") +if C_TriStarBullish and TriStarInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishTriStar = "Tri-Star\nA bullish TriStar candlestick pattern can form when three doji candlesticks materialize in immediate succession at the tail-end of an extended downtrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility." + label.new(bar_index, patternLabelPosLow, text="3S", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishTriStar) +C_TriStarBearishNumberOfCandles = 3 +C_3Dojis = C_Doji[2] and C_Doji[1] and C_Doji +C_BodyGapUp = C_BodyHi[1] < C_BodyLo +C_BodyGapDn = C_BodyLo[1] > C_BodyHi +C_TriStarBearish = C_3Dojis and C_UpTrend[2] and C_BodyGapUp[1] and C_BodyGapDn +alertcondition(C_TriStarBearish, title = "Tri-Star – Bearish", message = "New Tri-Star – Bearish pattern detected") +if C_TriStarBearish and TriStarInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishTriStar = "Tri-Star\nThis particular pattern can form when three doji candlesticks appear in immediate succession at the end of an extended uptrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility." + label.new(bar_index, patternLabelPosHigh, text="3S", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishTriStar) +C_KickingBullishNumberOfCandles = 2 +C_MarubozuShadowPercent = 5.0 +C_Marubozu = C_LongBody and C_UpShadow <= C_MarubozuShadowPercent/100*C_Body and C_DnShadow <= C_MarubozuShadowPercent/100*C_Body +C_MarubozuWhiteBullishKicking = C_Marubozu and C_WhiteBody +C_MarubozuBlackBullish = C_Marubozu and C_BlackBody +C_KickingBullish = C_MarubozuBlackBullish[1] and C_MarubozuWhiteBullishKicking and high[1] < low +alertcondition(C_KickingBullish, title = "Kicking – Bullish", message = "New Kicking – Bullish pattern detected") +if C_KickingBullish and KickingInput and (("Bullish" == CandleType) or CandleType == "Both") + + var ttBullishKicking = "Kicking\nThe first day candlestick is a bearish marubozu candlestick with next to no upper or lower shadow and where the price opens at the day’s high and closes at the day’s low. The second day is a bullish marubozu pattern, with next to no upper or lower shadow and where the price opens at the day’s low and closes at the day’s high. Additionally, the second day gaps up extensively and opens above the opening price of the day before. This gap or window, as the Japanese call it, lies between day one and day two’s bullish candlesticks." + label.new(bar_index, patternLabelPosLow, text="K", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishKicking) +C_KickingBearishNumberOfCandles = 2 +C_MarubozuBullishShadowPercent = 5.0 +C_MarubozuBearishKicking = C_LongBody and C_UpShadow <= C_MarubozuBullishShadowPercent/100*C_Body and C_DnShadow <= C_MarubozuBullishShadowPercent/100*C_Body +C_MarubozuWhiteBearish = C_MarubozuBearishKicking and C_WhiteBody +C_MarubozuBlackBearishKicking = C_MarubozuBearishKicking and C_BlackBody +C_KickingBearish = C_MarubozuWhiteBearish[1] and C_MarubozuBlackBearishKicking and low[1] > high +alertcondition(C_KickingBearish, title = "Kicking – Bearish", message = "New Kicking – Bearish pattern detected") +if C_KickingBearish and KickingInput and (("Bearish" == CandleType) or CandleType == "Both") + + var ttBearishKicking = "Kicking\nA bearish kicking pattern will occur, subsequently signaling a reversal for a new downtrend. The first day candlestick is a bullish marubozu. The second day gaps down extensively and opens below the opening price of the day before. There is a gap between day one and two’s bearish candlesticks." + label.new(bar_index, patternLabelPosHigh, text="K", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishKicking) + var ttAllCandlestickPatterns = "All Candlestick Patterns\n" + label.new(bar_index, patternLabelPosLow, text="Collection", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttAllCandlestickPatterns) \ No newline at end of file diff --git a/xSamples/indicators/atr.stop.loss.pine b/xSamples/indicators/atr.stop.loss.pine new file mode 100644 index 0000000..7080a57 --- /dev/null +++ b/xSamples/indicators/atr.stop.loss.pine @@ -0,0 +1,9 @@ +//@version=3 +study(title="ATR Stop-Loss", shorttitle="ATR-SL", overlay=true) +source = input(close, title="Source") +length = input(14, minval=1, title="Period") +multiplier = input(1.6, minval=0.1, step=0.1, title="Multiplier") +shortStopLoss = source + atr(length) * multiplier +longStopLoss = source - atr(length) * multiplier +plot(shortStopLoss, color=aqua, transp=0, linewidth=1, style=stepline, title="Short Stop Loss") +plot(longStopLoss, color=fuchsia, transp=0, linewidth=1, style=stepline, title="Long Stop Loss") \ No newline at end of file diff --git a/xSamples/indicators/auto-fibonaci.pine b/xSamples/indicators/auto-fibonaci.pine new file mode 100644 index 0000000..3963255 --- /dev/null +++ b/xSamples/indicators/auto-fibonaci.pine @@ -0,0 +1,205 @@ +//@version=5 +indicator("Auto Fib Retracement", overlay=true) + +devTooltip = "Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot." +depthTooltip = "The minimum number of bars that will be taken into account when calculating the indicator." +// pivots threshold +threshold_multiplier = input.float(title="Deviation", defval=3, minval=0, tooltip=devTooltip) +depth = input.int(title="Depth", defval=10, minval=2, tooltip=depthTooltip) +reverse = input(false, "Reverse") +var extendLeft = input(false, "Extend Left    |    Extend Right", inline = "Extend Lines") +var extendRight = input(true, "", inline = "Extend Lines") +var extending = extend.none +if extendLeft and extendRight + extending := extend.both +if extendLeft and not extendRight + extending := extend.left +if not extendLeft and extendRight + extending := extend.right +prices = input(true, "Show Prices") +levels = input(true, "Show Levels", inline = "Levels") +levelsFormat = input.string("Values", "", options = ["Values", "Percent"], inline = "Levels") +labelsPosition = input.string("Left", "Labels Position", options = ["Left", "Right"]) +var int backgroundTransparency = input.int(85, "Background Transparency", minval = 0, maxval = 100) + +import TradingView/ZigZag/5 as zigzag + +update()=> + var settings = zigzag.Settings.new(threshold_multiplier, depth, color(na), false, false, false, false, "Absolute", true) + var zigzag.ZigZag zigZag = zigzag.newInstance(settings) + var zigzag.Pivot lastP = na + var float startPrice = na + var float height = na + settings.devThreshold := ta.atr(10) / close * 100 * threshold_multiplier + if zigZag.update() + lastP := zigZag.lastPivot() + if not na(lastP) + var line lineLast = na + if na(lineLast) + lineLast := line.new(lastP.start.tm, lastP.start.price, lastP.end.tm, lastP.end.price, xloc=xloc.bar_time, color=color.gray, width=1, style=line.style_dashed) + else + line.set_xy1(lineLast, lastP.start.tm, lastP.start.price) + line.set_xy2(lineLast, lastP.end.tm, lastP.end.price) + + startPrice := reverse ? lastP.start.price : lastP.end.price + endPrice = reverse ? lastP.end.price : lastP.start.price + height := (startPrice > endPrice ? -1 : 1) * math.abs(startPrice - endPrice) + [lastP, startPrice, height] + +[lastP, startPrice, height] = update() + +_draw_line(price, col) => + var id = line.new(lastP.start.tm, lastP.start.price, time, price, xloc=xloc.bar_time, color=col, width=1, extend=extending) + line.set_xy1(id, lastP.start.tm, price) + line.set_xy2(id, lastP.end.tm, price) + id + + +_draw_label(price, txt, txtColor) => + x = labelsPosition == "Left" ? lastP.start.tm : not extendRight ? lastP.end.tm : time + labelStyle = labelsPosition == "Left" ? label.style_label_right : label.style_label_left + align = labelsPosition == "Left" ? text.align_right : text.align_left + labelsAlignStrLeft = txt + '\n ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ \n' + labelsAlignStrRight = ' ' + txt + '\n ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ \n' + labelsAlignStr = labelsPosition == "Left" ? labelsAlignStrLeft : labelsAlignStrRight + var id = label.new(x=x, y=price, xloc=xloc.bar_time, text=labelsAlignStr, textcolor=txtColor, style=labelStyle, textalign=align, color=#00000000) + label.set_xy(id, x, price) + label.set_text(id, labelsAlignStr) + label.set_textcolor(id, txtColor) + +_wrap(txt) => + "(" + str.tostring(txt, format.mintick) + ")" + +_label_txt(level, price) => + l = levelsFormat == "Values" ? str.tostring(level) : str.tostring(level * 100) + "%" + (levels ? l : "") + (prices ? _wrap(price) : "") + +_crossing_level(series float sr, series float r) => + (r > sr and r < sr[1]) or (r < sr and r > sr[1]) + +processLevel(bool show, float value, color colorL, line lineIdOther) => + float m = value + r = startPrice + height * m + crossed = _crossing_level(close, r) + if show and not na(lastP) + lineId = _draw_line(r, colorL) + _draw_label(r, _label_txt(m, r), colorL) + if crossed + alert("Autofib: " + syminfo.ticker + " crossing level " + str.tostring(value)) + if not na(lineIdOther) + linefill.new(lineId, lineIdOther, color = color.new(colorL, backgroundTransparency)) + lineId + else + lineIdOther + +show_0 = input(true, "", inline = "Level0") +value_0 = input(0, "", inline = "Level0") +color_0 = input(#787b86, "", inline = "Level0") + +show_0_236 = input(true, "", inline = "Level0") +value_0_236 = input(0.236, "", inline = "Level0") +color_0_236 = input(#f44336, "", inline = "Level0") + +show_0_382 = input(true, "", inline = "Level1") +value_0_382 = input(0.382, "", inline = "Level1") +color_0_382 = input(#81c784, "", inline = "Level1") + +show_0_5 = input(true, "", inline = "Level1") +value_0_5 = input(0.5, "", inline = "Level1") +color_0_5 = input(#4caf50, "", inline = "Level1") + +show_0_618 = input(true, "", inline = "Level2") +value_0_618 = input(0.618, "", inline = "Level2") +color_0_618 = input(#009688, "", inline = "Level2") + +show_0_65 = input(false, "", inline = "Level2") +value_0_65 = input(0.65, "", inline = "Level2") +color_0_65 = input(#009688, "", inline = "Level2") + +show_0_786 = input(true, "", inline = "Level3") +value_0_786 = input(0.786, "", inline = "Level3") +color_0_786 = input(#64b5f6, "", inline = "Level3") + +show_1 = input(true, "", inline = "Level3") +value_1 = input(1, "", inline = "Level3") +color_1 = input(#787b86, "", inline = "Level3") + +show_1_272 = input(false, "", inline = "Level4") +value_1_272 = input(1.272, "", inline = "Level4") +color_1_272 = input(#81c784, "", inline = "Level4") + +show_1_414 = input(false, "", inline = "Level4") +value_1_414 = input(1.414, "", inline = "Level4") +color_1_414 = input(#f44336, "", inline = "Level4") + +show_1_618 = input(true, "", inline = "Level5") +value_1_618 = input(1.618, "", inline = "Level5") +color_1_618 = input(#2962ff, "", inline = "Level5") + +show_1_65 = input(false, "", inline = "Level5") +value_1_65 = input(1.65, "", inline = "Level5") +color_1_65 = input(#2962ff, "", inline = "Level5") + +show_2_618 = input(true, "", inline = "Level6") +value_2_618 = input(2.618, "", inline = "Level6") +color_2_618 = input(#f44336, "", inline = "Level6") + +show_2_65 = input(false, "", inline = "Level6") +value_2_65 = input(2.65, "", inline = "Level6") +color_2_65 = input(#f44336, "", inline = "Level6") + +show_3_618 = input(true, "", inline = "Level7") +value_3_618 = input(3.618, "", inline = "Level7") +color_3_618 = input(#9c27b0, "", inline = "Level7") + +show_3_65 = input(false, "", inline = "Level7") +value_3_65 = input(3.65, "", inline = "Level7") +color_3_65 = input(#9c27b0, "", inline = "Level7") + +show_4_236 = input(true, "", inline = "Level8") +value_4_236 = input(4.236, "", inline = "Level8") +color_4_236 = input(#e91e63, "", inline = "Level8") + +show_4_618 = input(false, "", inline = "Level8") +value_4_618 = input(4.618, "", inline = "Level8") +color_4_618 = input(#81c784, "", inline = "Level8") + +show_neg_0_236 = input(false, "", inline = "Level9") +value_neg_0_236 = input(-0.236, "", inline = "Level9") +color_neg_0_236 = input(#f44336, "", inline = "Level9") + +show_neg_0_382 = input(false, "", inline = "Level9") +value_neg_0_382 = input(-0.382, "", inline = "Level9") +color_neg_0_382 = input(#81c784, "", inline = "Level9") + +show_neg_0_618 = input(false, "", inline = "Level10") +value_neg_0_618 = input(-0.618, "", inline = "Level10") +color_neg_0_618 = input(#009688, "", inline = "Level10") + +show_neg_0_65 = input(false, "", inline = "Level10") +value_neg_0_65 = input(-0.65, "", inline = "Level10") +color_neg_0_65 = input(#009688, "", inline = "Level10") + + +lineId0 = processLevel(show_neg_0_65, value_neg_0_65, color_neg_0_65, line(na)) +lineId1 = processLevel(show_neg_0_618, value_neg_0_618, color_neg_0_618, lineId0) +lineId2 = processLevel(show_neg_0_382, value_neg_0_382, color_neg_0_382, lineId1) +lineId3 = processLevel(show_neg_0_236, value_neg_0_236, color_neg_0_236, lineId2) +lineId4 = processLevel(show_0, value_0, color_0, lineId3) +lineId5 = processLevel(show_0_236, value_0_236, color_0_236, lineId4) +lineId6 = processLevel(show_0_382, value_0_382, color_0_382, lineId5) +lineId7 = processLevel(show_0_5, value_0_5, color_0_5, lineId6) +lineId8 = processLevel(show_0_618, value_0_618, color_0_618, lineId7) +lineId9 = processLevel(show_0_65, value_0_65, color_0_65, lineId8) +lineId10 = processLevel(show_0_786, value_0_786, color_0_786, lineId9) +lineId11 = processLevel(show_1, value_1, color_1, lineId10) +lineId12 = processLevel(show_1_272, value_1_272, color_1_272, lineId11) +lineId13 = processLevel(show_1_414, value_1_414, color_1_414, lineId12) +lineId14 = processLevel(show_1_618, value_1_618, color_1_618, lineId13) +lineId15 = processLevel(show_1_65, value_1_65, color_1_65, lineId14) +lineId16 = processLevel(show_2_618, value_2_618, color_2_618, lineId15) +lineId17 = processLevel(show_2_65, value_2_65, color_2_65, lineId16) +lineId18 = processLevel(show_3_618, value_3_618, color_3_618, lineId17) +lineId19 = processLevel(show_3_65, value_3_65, color_3_65, lineId18) +lineId20 = processLevel(show_4_236, value_4_236, color_4_236, lineId19) +lineId21 = processLevel(show_4_618, value_4_618, color_4_618, lineId20) diff --git a/xSamples/indicators/candle_patterns.pine b/xSamples/indicators/candle_patterns.pine new file mode 100644 index 0000000..4597a12 --- /dev/null +++ b/xSamples/indicators/candle_patterns.pine @@ -0,0 +1,244 @@ +// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ +// © BlockchainSpecialists + +//@version=4 +study("Candlestick Pattern - All Patterns", overlay=true) + +C_DownTrend = true +C_UpTrend = true +var trendRule1 = "Price 50 SMA" +var trendRule2 = "50 SMA and 200 SMA" +var trendRule = input(trendRule1, "Trend Detection Rule", options=[trendRule1, trendRule2, "None"]) + +if trendRule == trendRule1 + priceAvg = sma(close, 50) + C_DownTrend := close < priceAvg + C_UpTrend := close > priceAvg + +if trendRule == trendRule2 + sma200 = sma(close, 200) + sma50 = sma(close, 50) + C_DownTrend := close < sma200 and sma50 < sma200 + C_UpTrend := close > sma200 and sma50 > sma200 +C_Len = 14 // ema depth for bodyAvg +C_ShadowPercent = 5.0 // size of shadows +C_ShadowEqualsPercent = 100.0 +C_DojiBodyPercent = 5.0 +C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body + +C_BodyHi = max(close, open) +C_BodyLo = min(close, open) +C_Body = C_BodyHi - C_BodyLo +C_BodyAvg = ema(C_Body, C_Len) +C_SmallBody = C_Body < C_BodyAvg +C_LongBody = C_Body > C_BodyAvg +C_UpShadow = high - C_BodyHi +C_DnShadow = C_BodyLo - low +C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body +C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body +C_WhiteBody = open < close +C_BlackBody = open > close +C_Range = high-low +C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo +C_BodyMiddle = C_Body / 2 + C_BodyLo +C_ShadowEquals = C_UpShadow == C_DnShadow or (abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent +C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 +C_Doji = C_IsDojiBody and C_ShadowEquals +C_oAbandonedBaby = C_UpTrend[2] and C_WhiteBody[2] and C_IsDojiBody[1] and high[2] < low[1] and C_BlackBody and low[1] > high +alertcondition(C_oAbandonedBaby, title = "Abandoned Baby") +if C_oAbandonedBaby + var tt = "Abandoned Baby\nA bearish abandoned baby is a specific candlestick pattern that often signals a downward reversal trend in terms of security price. It is formed when a gap appears between the lowest price of a doji-like candle and the candlestick of the day before. The earlier candlestick is green, tall, and has small shadows. The doji candle is also tailed by a gap between its lowest price point and the highest price point of the candle that comes next, which is red, tall and also has small shadows. The doji candle shadows must completely gap either below or above the shadows of the first and third day in order to have the abandoned baby pattern effect." + label.new(bar_index, low, yloc=yloc.abovebar, text="AB", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_oEngulfing = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and C_SmallBody[1] and close <= open[1] and open >= close[1] and ( close < open[1] or open > close[1] ) +alertcondition(C_oEngulfing, title = "Engulfing") +if C_oEngulfing + var tt = "Engulfing\nAt the end of a given uptrend, a reversal pattern will most likely appear. During the first day, this candlestick pattern uses a small body. It is then followed by a day where the candle body fully overtakes the body from the day before it and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to fully overtake the range (high to low), rather only the open and the close." + label.new(bar_index, low, yloc=yloc.abovebar, text="BE", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_oEveningStar = false +if C_LongBody[2] and C_SmallBody[1] and C_LongBody + if C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi + C_oEveningStar := true +alertcondition(C_oEveningStar, title = "Evening Star") +if C_oEveningStar + var tt = "Evening Star\nThis candlestick pattern is bearish and continues an uptrend with a long-bodied, green candle day. It is then followed by a gapped and small-bodied candle day, and concludes with a downward close. The close would be below the first day’s midpoint." + label.new(bar_index, low, yloc=yloc.abovebar, text="ES", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_GravestoneDoji = C_IsDojiBody and C_DnShadow <= C_Body +alertcondition(C_GravestoneDoji, title = "Gravestone Doji") +if C_GravestoneDoji + var tt = "Gravestone Doji\nWhen a doji is at or is close to the day’s low point, a doji line will develop." + label.new(bar_index, low, yloc=yloc.abovebar, text="GD", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_oHangingMan = false +if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow + if C_UpTrend + C_oHangingMan := true +alertcondition(C_oHangingMan, title = "Hanging Man") +if C_oHangingMan + var tt = "Hanging Man\nWhen a specified security notably moves lower after the open, but continues to rally to close above the intraday low, a Hanging Man candlestick will form. The candlestick will resemble a square, attached to a long stick-like figure. It is referred to as a Hanging Man if the candlestick forms during an advance." + label.new(bar_index, low, yloc=yloc.abovebar, text="HM", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_Harami = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_IsDojiBody and C_IsInsideBar +alertcondition(C_Harami, title = "Harami") +if C_Harami + var tt = "Harami\nThis is a two-day candlestick pattern with a small, red-bodied candle that is entirely encompassed within the range that was once a green-bodied candle." + label.new(bar_index, low, yloc=yloc.abovebar, text="BH", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_MarubozuShadowPercent = 5.0 +C_Marubozu = C_LongBody and C_UpShadow <= C_MarubozuShadowPercent/100*C_Body and C_DnShadow <= C_MarubozuShadowPercent/100*C_Body +C_MarubozuWhite = C_Marubozu and C_WhiteBody +C_MarubozuBlack = C_Marubozu and C_BlackBody +C_Kicking = C_MarubozuWhite[1] and C_MarubozuBlack and low[1] > high +alertcondition(C_Kicking, title = "Kicking") +if C_Kicking + var tt = "Kicking\nA bearish kicking pattern will occur, subsequently signaling a reversal for a new downtrend. The first day candlestick is a bullish marubozu. The second day gaps down extensively and opens below the opening price of the day before. There is a gap between day one and two’s bearish candlesticks." + label.new(bar_index, low, yloc=yloc.abovebar, text="K", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_LongShadowPercent = 75.0 +C_LongUpperShadow = C_UpShadow > C_Range/100*C_LongShadowPercent +alertcondition(C_LongUpperShadow, title = "Long Upper Shadow") +if C_LongUpperShadow + var tt = "Long Upper Shadow\nTo indicate buyer domination of the first part of a session, candlesticks will present with long upper shadows, as well as short lower shadows, consequently raising bidding prices." + label.new(bar_index, low, yloc=yloc.abovebar, text="LUS", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +alertcondition(C_MarubozuBlack, title = "Marubozu Black") +if C_MarubozuBlack + var tt = "Marubozu Black\nThis is a candlestick that has no shadow, which extends from the red-bodied candle at the open, the close, or even at both. In Japanese, the name means “close-cropped” or “close-cut.” The candlestick can also be referred to as Bald or Shaven Head." + label.new(bar_index, low, yloc=yloc.abovebar, text="MB", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_oShootingStar = false +if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow + if C_UpTrend + C_oShootingStar := true +alertcondition(C_oShootingStar, title = "Shooting Star") +if C_oShootingStar + var tt = "Shooting Star\nThis single day pattern can appear during an uptrend and opens high, while it closes near its open. It trades much higher as well. It is bearish in nature, but looks like an Inverted Hammer." + label.new(bar_index, low, yloc=yloc.abovebar, text="SS", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_3BCrw_ShadowPercent = 5.0 +C_3BCrw_HaveNotDnShadow = C_Range * C_3BCrw_ShadowPercent / 100 > C_DnShadow +C_oThreeBlackCrows = false +if C_LongBody and C_LongBody[1] and C_LongBody[2] + if C_BlackBody and C_BlackBody[1] and C_BlackBody[2] + C_oThreeBlackCrows := close < close[1] and close[1] < close[2] and open > close[1] and open < open[1] and open[1] > close[2] and open[1] < open[2] and C_3BCrw_HaveNotDnShadow and C_3BCrw_HaveNotDnShadow[1] and C_3BCrw_HaveNotDnShadow[2] +alertcondition(C_oThreeBlackCrows, title = "Three Black Crows") +if C_oThreeBlackCrows + var tt = "Three Black Crows\nThis is a bearish reversal pattern that consists of three long, red-bodied candles in immediate succession. For each of these candles, each day opens within the body of the day before and closes either at or near its low." + label.new(bar_index, low, yloc=yloc.abovebar, text="3BC", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_3Dojis = C_Doji[2] and C_Doji[1] and C_Doji +C_BodyGapUp = C_BodyHi[1] < C_BodyLo +C_BodyGapDn = C_BodyLo[1] > C_BodyHi +C_TriStar = C_3Dojis and C_UpTrend[2] and C_BodyGapUp[1] and C_BodyGapDn +alertcondition(C_TriStar, title = "Tri-Star") +if C_TriStar + var tt = "Tri-Star\nThis particular pattern can form when three doji candlesticks appear in immediate succession at the end of an extended uptrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility." + label.new(bar_index, low, yloc=yloc.abovebar, text="3S", style=label.style_label_down, color = color.red, textcolor=color.white, tooltip = tt) + +C_oAbandonedBaby1 = C_DownTrend[2] and C_BlackBody[2] and C_IsDojiBody[1] and low[2] > high[1] and C_WhiteBody and high[1] < low +alertcondition(C_oAbandonedBaby1, title = "Abandoned Baby") +if C_oAbandonedBaby1 + var tt = "Abandoned Baby\nThis candlestick pattern is quite rare as far as reversal patterns go. The first of the pattern is a large down candle. Next comes a doji candle that gaps below the candle before it. The doji candle is then followed by another candle that opens even higher and swiftly moves to the upside." + label.new(bar_index, low, yloc=yloc.belowbar, text="AB", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_DragonflyDoji1 = C_IsDojiBody and C_UpShadow <= C_Body +alertcondition(C_DragonflyDoji1, title = "Dragonfly Doji") +if C_DragonflyDoji1 + var tt = "Dragonfly Doji\nSimilar to other Doji days, this particular Doji also regularly appears at pivotal market moments. This is a specific Doji where both the open and close price are at the high of a given day." + label.new(bar_index, low, yloc=yloc.belowbar, text="DD", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_oEngulfing1 = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and C_SmallBody[1] and close >= open[1] and open <= close[1] and ( close > open[1] or open < close[1] ) +alertcondition(C_oEngulfing1, title = "Engulfing") +if C_oEngulfing1 + var tt = "Engulfing\nAt the end of a given downward trend, there will most likely be a reversal pattern. To distinguish the first day, this candlestick pattern uses a small body, followed by a day where the candle body fully overtakes the body from the day before, and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to completely overtake the range (high to low), rather only the open and the close." + label.new(bar_index, low, yloc=yloc.belowbar, text="BE", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_oHammer1 = false +if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow + if C_DownTrend + C_oHammer1 := true +alertcondition(C_oHammer1, title = "Hammer") +if C_oHammer1 + var tt = "Hammer\nHammer candlesticks form when a security moves lower after the open, but continues to rally into close above the intraday low. The candlestick that you are left with will look like a square attached to a long stick-like figure. This candlestick is called a Hammer if it happens to form during a decline." + label.new(bar_index, low, yloc=yloc.belowbar, text="H", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_Harami1 = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_IsDojiBody and C_IsInsideBar +alertcondition(C_Harami1, title = "Harami") +if C_Harami1 + var tt = "Harami\nThis two-day candlestick pattern consists of a small-bodied green candle that is entirely encompassed within the range of what was once a red-bodied candle." + label.new(bar_index, low, yloc=yloc.belowbar, text="BH", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_Kicking1 = C_MarubozuBlack[1] and C_MarubozuWhite and high[1] < low +alertcondition(C_Kicking1, title = "Kicking") +if C_Kicking1 + var tt = "Kicking\nThe first day candlestick is a bearish marubozu candlestick with next to no upper or lower shadow and where the price opens at the day’s high and closes at the day’s low. The second day is a bullish marubozu pattern, with next to no upper or lower shadow and where the price opens at the day’s low and closes at the day’s high. Additionally, the second day gaps up extensively and opens above the opening price of the day before. This gap or window, as the Japanese call it, lies between day one and day two’s bullish candlesticks." + label.new(bar_index, low, yloc=yloc.belowbar, text="K", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_oInvertedHammer = false +if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow + if C_DownTrend + C_oInvertedHammer := true +alertcondition(C_oInvertedHammer, title = "Inverted Hammer") +if C_oInvertedHammer + var tt = "Inverted Hammer\nIf in a downtrend, then the open is lower. When it eventually trades higher, but closes near its open, it will look like an inverted version of the Hammer Candlestick. This is a one-day bullish reversal pattern." + label.new(bar_index, low, yloc=yloc.belowbar, text="IH", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_LongLowerShadow1 = C_DnShadow > C_Range/100*C_LongShadowPercent +alertcondition(C_LongLowerShadow1, title = "Long Lower Shadow") +if C_LongLowerShadow1 + var tt = "Long Lower Shadow\nTo indicate seller domination of the first part of a session, candlesticks will present with long lower shadows and short upper shadows, consequently lowering prices." + label.new(bar_index, low, yloc=yloc.belowbar, text="LLS", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_MarubozuWhite1 = C_Marubozu and C_WhiteBody +alertcondition(C_MarubozuWhite1, title = "Marubozu White") +if C_MarubozuWhite1 + var tt = "Marubozu White\nA Marubozu White Candle is a candlestick that does not have a shadow that extends from its candle body at either the open or the close. Marubozu is Japanese for “close-cropped” or “close-cut.” Other sources may call it a Bald or Shaven Head Candle." + label.new(bar_index, low, yloc=yloc.belowbar, text="MW", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_oMorningStar1 = false +if C_LongBody[2] and C_SmallBody[1] and C_LongBody + if C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo + C_oMorningStar1 := true +alertcondition(C_oMorningStar1, title = "Morning Star") +if C_oMorningStar1 + var tt = "Morning Star\nA three-day bullish reversal pattern, which consists of three candlesticks will look something like this: The first being a long-bodied red candle that extends the current downtrend. Next comes a short, middle candle that gaps down on the open. After comes a long-bodied green candle, which gaps up on the open and closes above the midpoint of the body of the first day." + label.new(bar_index, low, yloc=yloc.belowbar, text="MS", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_3WSld_ShadowPercent = 5.0 +C_3WSld_HaveNotUpShadow = C_Range * C_3WSld_ShadowPercent / 100 > C_UpShadow +C_oThreeWhiteSoldiers = false +if C_LongBody and C_LongBody[1] and C_LongBody[2] + if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2] + C_oThreeWhiteSoldiers := close > close[1] and close[1] > close[2] and open < close[1] and open > open[1] and open[1] < close[2] and open[1] > open[2] and C_3WSld_HaveNotUpShadow and C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2] +alertcondition(C_oThreeWhiteSoldiers, title = "Three White Soldiers") +if C_oThreeWhiteSoldiers + var tt = "Three White Soldiers\nThis bullish reversal pattern is made up of three long-bodied, green candles in immediate succession. Each one opens within the body before it and the close is near to the daily high." + label.new(bar_index, low, yloc=yloc.belowbar, text="3WS", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_TriStar1 = C_3Dojis and C_DownTrend[2] and C_BodyGapDn[1] and C_BodyGapUp +alertcondition(C_TriStar1, title = "Tri-Star") +if C_TriStar1 + var tt = "Tri-Star\nA bullish TriStar candlestick pattern can form when three doji candlesticks materialize in immediate succession at the tail-end of an extended downtrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility." + label.new(bar_index, low, yloc=yloc.belowbar, text="3S", style=label.style_label_up, color = color.blue, textcolor=color.white, tooltip = tt) + +C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body +alertcondition(C_Doji and not C_DragonflyDoji and not C_GravestoneDoji, title = "Doji") +if C_Doji and not C_DragonflyDoji and not C_GravestoneDoji + var tt = "Doji\nWhen the open and close of a security are essentially equal to each other, a doji candle forms. The length of both upper and lower shadows may vary, causing the candlestick you are left with to either resemble a cross, an inverted cross, or a plus sign. Doji candles show the playout of buyer-seller indecision in a tug-of-war of sorts. As price moves either above or below the opening level during the session, the close is either at or near the opening level." + label.new(bar_index, low, yloc=yloc.belowbar, text="D", style=label.style_label_center, color = color.gray, textcolor=color.white, tooltip = tt) + +C_SpinningTopPercent = 34.0 +C_IsSpinningTop = C_DnShadow >= C_Range / 100 * C_SpinningTopPercent and C_UpShadow >= C_Range / 100 * C_SpinningTopPercent and not C_IsDojiBody +C_SpinningTopBlack = C_IsSpinningTop and C_BlackBody +alertcondition(C_SpinningTopBlack, title = "Spinning Top Black") +if C_SpinningTopBlack + var tt = "Spinning Top Black\nBlack spinning tops are candlestick lines that are small, red-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision." + label.new(bar_index, low, yloc=yloc.belowbar, text="STB", style=label.style_label_center, color = color.gray, textcolor=color.white, tooltip = tt) + +C_SpinningTopWhite = C_IsSpinningTop and C_WhiteBody +alertcondition(C_SpinningTopWhite, title = "Spinning Top White") +if C_SpinningTopWhite + var tt = "Spinning Top White\nWhite spinning tops are candlestick lines that are small, green-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision between buyer and seller." + label.new(bar_index, low, yloc=yloc.belowbar, text="STW", style=label.style_label_center, color = color.gray, textcolor=color.white, tooltip = tt) \ No newline at end of file diff --git a/xSamples/indicators/candlestick.pattern.recognition.pine b/xSamples/indicators/candlestick.pattern.recognition.pine new file mode 100644 index 0000000..70c479e --- /dev/null +++ b/xSamples/indicators/candlestick.pattern.recognition.pine @@ -0,0 +1,58 @@ +// Created by Robert N. 030715 +// Updated 031115 +// Candle labels +study(title = "Candles", overlay = true) + +DojiSize = input(0.05, minval=0.01, title="Doji size") +data=(abs(open - close) <= (high - low) * DojiSize) +plotchar(data, title="Doji", text='Doji', color=white) + +data2=(close[2] > open[2] and min(open[1], close[1]) > close[2] and open < min(open[1], close[1]) and close < open ) +plotshape(data2, title= "Evening Star", color=red, style=shape.arrowdown, text="Evening\nStar") + +data3=(close[2] < open[2] and max(open[1], close[1]) < close[2] and open > max(open[1], close[1]) and close > open ) +plotshape(data3, title= "Morning Star", location=location.belowbar, color=lime, style=shape.arrowup, text="Morning\nStar") + +data4=(open[1] < close[1] and open > close[1] and high - max(open, close) >= abs(open - close) * 3 and min(close, open) - low <= abs(open - close)) +plotshape(data4, title= "Shooting Star", color=red, style=shape.arrowdown, text="Shooting\nStar") + +data5=(((high - low)>3*(open -close)) and ((close - low)/(.001 + high - low) > 0.6) and ((open - low)/(.001 + high - low) > 0.6)) +plotshape(data5, title= "Hammer", location=location.belowbar, color=white, style=shape.diamond, text="H") + +data5b=(((high - low)>3*(open -close)) and ((high - close)/(.001 + high - low) > 0.6) and ((high - open)/(.001 + high - low) > 0.6)) +plotshape(data5b, title= "Inverted Hammer", location=location.belowbar, color=white, style=shape.diamond, text="IH") + + +data6=(close[1] > open[1] and open > close and open <= close[1] and open[1] <= close and open - close < close[1] - open[1] ) +plotshape(data6, title= "Bearish Harami", color=red, style=shape.arrowdown, text="Bearish\nHarami") + +data7=(open[1] > close[1] and close > open and close <= open[1] and close[1] <= open and close - open < open[1] - close[1] ) +plotshape(data7, title= "Bullish Harami", location=location.belowbar, color=lime, style=shape.arrowup, text="Bullish\nHarami") + +data8=(close[1] > open[1] and open > close and open >= close[1] and open[1] >= close and open - close > close[1] - open[1] ) +plotshape(data8, title= "Bearish Engulfing", color=red, style=shape.arrowdown, text="Bearish\nEngulfing") + +data9=(open[1] > close[1] and close > open and close >= open[1] and close[1] >= open and close - open > open[1] - close[1] ) +plotshape(data9, title= "Bullish Engulfing", location=location.belowbar, color=lime, style=shape.arrowup, text="Bullish\nEngulfling") + +upper = highest(10)[1] +data10=(close[1] < open[1] and open < low[1] and close > close[1] + ((open[1] - close[1])/2) and close < open[1]) +plotshape(data10, title= "Piercing Line", location=location.belowbar, color=lime, style=shape.arrowup, text="Piercing\nLine") + +lower = lowest(10)[1] +data11=(low == open and open < lower and open < close and close > ((high[1] - low[1]) / 2) + low[1]) +plotshape(data11, title= "Bullish Belt", location=location.belowbar, color=lime, style=shape.arrowup, text="Bullish\nBelt") + +data12=(open[1]>close[1] and open>=open[1] and close>open) +plotshape(data12, title= "Bullish Kicker", location=location.belowbar, color=lime, style=shape.arrowup, text="Bullish\nKicker") + +data13=(open[1]4*(open-close))and((close-low)/(.001+high-low)>=0.75)and((open-low)/(.001+high-low)>=0.75)) and high[1] < open and high[2] < open) +plotshape(data14, title= "Hanging Man", color=red, style=shape.arrowdown, text="Hanging\nMan") + +data15=((close[1]>open[1])and(((close[1]+open[1])/2)>close)and(open>close)and(open>close[1])and(close>open[1])and((open-close)/(.001+(high-low))>0.6)) +plotshape(data15, title= "Dark Cloud Cover", color=red, style=shape.arrowdown, text="Dark\nCloudCover") + + diff --git a/xSamples/indicators/candlestick.trend.pine b/xSamples/indicators/candlestick.trend.pine new file mode 100644 index 0000000..ce9758d --- /dev/null +++ b/xSamples/indicators/candlestick.trend.pine @@ -0,0 +1,257 @@ +//@version2 +// Name: Candlestick Trend Indicator v0.5 by JustUncleL +// By: JustUncleL +// Date: 12-Aug-2016 +// Version: v0.5 +// +// Description: +// This is a trend following indicator+stategy for Binary Options +// based on Candlestick patterns and trend line - +// NOTE: original system was a forex trading system. +// This code combines a number of indicators to create an overall +// trading strategy. +// The indicator recognises and displays some useful candle named +// defined patterns that are used to support trend continuation: +// - Bearish + Bullish PinBars +// - Dark Cloud Cover +// - Piecing Line +// - Bullish + Bearish Harami +// - Bullish + Bearish Engulfing Candle +// - Bullish + Bearish Fractal S/R break +// Also recognises price action candles from ChrisMoody (CM), +// Four(4) price action patterns colored bars: +// Yellow = Inside Bar - breakout/continuance +// Orange = Outside Bar - breakout/continuance +// Aqua/Fuschia = Up/Down Shaved Bars - Buying/Selling pressure +// Red/Green = Possible reversal PinBars - Reverse Down / reverse Up. +// +// The highlighted candles (maroon and darker green) are the +// other patterns that are confirmed bars following the current +// trend direction that is indicated by the Hull MA(20) line +// (can select a different type of MA) and confirmed by MACD direction. +// An alert generated for the alert condition of the alarming system. +// The fractal upper/lower break lines are also draw, if the last +// fractal break line is broken by a highlighted bar then this +// indicates a stronger trend conformation. +// The MACD indicator MACD DEUTER 2 colour(12,26,9) you can visually see the MACD histogram +// colours with MACD direction - needs "MACD DEUTER 2 colour" indicator. +// +// This multi-indicator set up is suitable for 1hr, 4hr and daily charts +// with 1-4 candle expiry. +// +// references: +// - [RS]Fractal Levels by RicardoSantos +// - Almost Zero Lag EMA [LazyBear] +// - Candlestick Patterns With EMA by rmwaddelljr +// - CM_Price-Action-Bars by ChrisMoody +// - http://www.forexstrategiesresources.com/candlestick-forex-strategies/1-candlestick-trend/ +// - "Scalp Jockey - MTF MA Cross Visual Strategizer by JayRogers" +// +// Modifications: +// 0.5 Added Option to select what pattern types will be displayed +// and used in setting the confirmed alert condition. +// Added option to select a different moving average type. (31-Oct-16) +// Modified some default settings, using HullMA instead of Zero Lag MA +// and standard MACD settings(12,26,9). +// 0.4.1 Added fractal break as a named Price Action bar. (21-Oct-16) +// 0.4 - Corrected input double up on Reversal Pin Bars. +// Added optional coloured Circle dots at bottom of screen to indicate when +// alert condition is set, only after bar closed. +// Added optional MACD filtering on alert condition, saves checking alert against +// MACD histogram. +// 0.3 - Corrected PinBar calculation for trend direction support. +// Modified Engulfing and Harami candles calculatios to be more accurately identified. +// Added optional reversal pin bars (red/green bars), so possible change in +// direction can be identified, this not part of the original alert though. +// Added option to show only bar patterns that are supporting current trend. +// Added option to enable Price action bars individually. +// Returned Dark Cloud Cover, Piecing Line and Pin Bars back into the named +// candle patterns. +// 0.2 - Removed all candle patterns except Harami and Engulfing candle patterns. +// Added and highlighted price action candles from CM for extra indication. +// Changed default ZEMA length from 15 to 20. +// Bug fixes. (14-Aug-2016) +// 0.1 - original beta release. +// +study(title="Candlestick Trend Indicator v0.5 by JustUncleL", shorttitle="CDLTRD v0.5 by JustUncleL", overlay=true, scale=scale.right) +// +// this section based on Almost Zero Lag EMA [LazyBear] +// Fast MA - type, length +matype = input(defval="HullMA", title="Fast MA Type: SMA, EMA, WMA, VWMA, SMMA, DEMA, TEMA, HullMA, TMA, ZEMA ( case sensitive )", type=string) +malength = input(defval=20, title="Moving Average Length", minval=1) +src = input(close,title="Moving average Source") + +// Returns MA input selection variant, default to SMA if blank or typo. +variant(type, src, len) => + v1 = sma(src, len) // Simple + v2 = ema(src, len) // Exponential + v3 = wma(src, len) // Weighted + v4 = vwma(src, len) // Volume Weighted + v5 = na(v5[1]) ? sma(src, len) : (v5[1] * (len - 1) + src) / len // Smoothed + v6 = 2 * v2 - ema(v2, len) // Double Exponential + v7 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len) // Triple Exponential + v8 = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) // Hull + ema1 = ema(src, len) + ema2 = ema(ema1, len) + v10 = ema1+(ema1-ema2) // Zero Lag Exponential + v11 = sma(sma(src,len),len) // Trianglular + // return variant, defaults to SMA if input invalid. + type=="EMA"?v2 : type=="WMA"?v3 : type=="VWMA"?v4 : type=="SMMA"?v5 : type=="DEMA"?v6 : type=="TEMA"?v7 : type=="HullMA"?v8 : type=="ZEMA"?v10 : type=="TMA"?v11 : v1 + +// Calculate selected MA and get direction of trend from it. +zlema= variant(matype,src,malength) +col = zlema > zlema[1] ? green : red +up = zlema > zlema[1] ? 1 : 0 +down = zlema < zlema[1] ? 1 : 0 +plot(zlema,color=col, style=line, linewidth=4, transp=0) + +// Find all Fractals. +// This section based on [RS]Fractal Levels by RicardoSantos +hidefractals = input(false) +hidelevels = input(false) +topfractal = high[2] > high[1] and high[2] > high and high[2] > high[3] and high[2] > high[4] +botfractal = low[2] < low[1] and low[2] < low and low[2] < low[3] and low[2] < low[4] + +plotshape(hidefractals ? na : topfractal, color=green, transp=0, style=shape.triangleup, location=location.abovebar, offset=-2, size=size.tiny) +plotshape(hidefractals ? na : botfractal, color=red, transp=0, style=shape.triangledown, location=location.belowbar, offset=-2, size=size.tiny) + +topfractals = topfractal ? high[2] : topfractals[1] +botfractals = botfractal ? low[2] : botfractals[1] + +topfcolor = topfractals != topfractals[1] ? na : green +botfcolor = botfractals != botfractals[1] ? na : red + +plot(hidelevels ? na : topfractals, color=topfcolor, transp=0, linewidth=2) +plot(hidelevels ? na : botfractals, color=botfcolor, transp=0, linewidth=2) + +// +// This section based on Candlestick Patterns With EMA by rmwaddelljr +// +ufb = input(false, title="Use Fractal S/R Cross Patterns") +udc = input(true, title="Use Dark Cloud Cover Patterns" ) +upl = input(true, title="Use Piecing Line Patterns" ) +ube = input(true, title="Use Engulfing Candle Patterns" ) +ubh = input(true, title="Use Harami Candle Patterns" ) +upb = input(true, title="Use Defined PinBar Patterns") +pctP = input(66, minval=1, maxval=99, title="Directional PBars, % of Range of Candle the Long Wick Has To Be") +// This section based on CM_Price-Action-Bars by ChrisMoody +// Change the pin bar calculation, so can be used for market direction. +urpb= input(false, title="Use CM Price Action Reversal Pin Bars") +usb = input(false, title="Use CM Price Action Shaved Bars") +uob = input(false, title="Use CM Price Action Outside Bars") +uib = input(false, title="Use CM Price Action Inside Bars") +pctRP = input(72, minval=1, maxval=99, title="CM Reversal PBars, % of Range of Candle the Long Wick Has To Be") +pctS = input(5, minval=1, maxval=99, title="CM Shaved Bars, % of Range it Has To Close On The Lows or Highs") +pblb =input(6,minval=1,title="CM Reversal Pin Bar Lookback Length") +// +stnd = input(true, title="Alert Only Patterns Following Trend") +// +// Get MACD for Alert Filtering +umacd = input(true,title="Alert Only Patterns Confirmed by MACD") +fastMA = input(title="MACD Fast MA Length", type = integer, defval = 12, minval = 2) +slowMA = input(title="MACD Slow MA Length", type = integer, defval = 26, minval = 7) +signal = input(title="MACD Signal Length",type=integer,defval=9,minval=1) + +// +sgb = input(false, title="Check Box To Turn Bars Gray") +salc = input(true, title="Show Alert condition Dot") +// +[currMacd,_,_] = macd(close[0], fastMA, slowMA, signal) +[prevMacd,_,_] = macd(close[1], fastMA, slowMA, signal) +plotColor = currMacd > 0 + ? currMacd > prevMacd ? green : red + : currMacd < prevMacd ? red : green + +// Show alert on this bar? +sbarUp = (not umacd or plotColor==green) and (not stnd or up) +sbarDn = (not umacd or plotColor==red) and (not stnd or down) + +//PBar Percentages +pctCp = pctP * .01 + +//Shaved Bars Percentages +pctCs = pctS * .01 +pctSPO = pctCs +//ma50 = sma(close,50) + +range = high - low + +///Reversal PinBars +pctCRp = pctRP * .01 +pctCRPO = 1 - pctCRp +// +//pBarRUp= upb and open high - (range * pctCRPO) and close > high - (range * pctCRPO) and low <= lowest(pblb) ? 1 : 0 +//pBarRDn = upb and open>close and open < high - (range * pctCRp) and close < high-(range * pctCRp) and high >= highest(pblb) ? 1 : 0 +pBarRUp = urpb and open > high - (range * pctCRPO) and close > high - (range * pctCRPO) and low <= lowest(pblb) ? 1 : 0 +pBarRDn = urpb and open < high - (range * pctCRp) and close < high-(range * pctCRp) and high >= highest(pblb) ? 1 : 0 + +//Shaved Bars filter to the MA50 line +sBarUp = usb and (close >= (high - (range * pctCs))) // and close>ma50 +sBarDown = usb and (close <= (low + (range * pctCs))) // and close low[1]) +insideBarDn = uib and (high < high[1] and low > low[1]) +outsideBarUp= uob and (high > high[1] and low < low[1]) +outsideBarDn= uob and (high > high[1] and low < low[1]) + +// PinBars representing possible change in trend direction +barcolor(pBarRUp ? green : na) +barcolor(pBarRDn ? red : na) + +//Shaved Bars +barcolor(sBarDown ? fuchsia : na) +barcolor(sBarUp ? aqua : na) + +//Inside and Outside Bars +barcolor((insideBarUp or insideBarDn)? yellow : na ) +barcolor((outsideBarUp or outsideBarDn) ? orange : na ) + + +//Long shadow PinBars supporting market direction +///PinBars Long Upper Shadow represent selling pressure +pBarDn = upb and open < high - (range * pctCp) and close < high - (range * pctCp) +plotshape(pBarDn and (not pBarRUp and not pBarRDn), title= "Bearish Pin Bar", color=red, style=shape.arrowdown, text="Bearish\nPinBar") +///PinBars with Long Lower Shadow represent buying pressure +pBarUp = upb and open > low + (range * pctCp) and close > low + (range * pctCp) +plotshape(pBarUp and (not pBarRUp and not pBarRDn), title= "Bullish Pin Bar", location=location.belowbar, color=green, style=shape.arrowup, text="Bullish\nPinBar") + +dcc = udc and (close[1]>open[1] and abs(close[1]-open[1])/range[1]>=0.7 and close=0.7 and open>=close[1] and close>open[1] and close<((open[1]+close[1])/2)) +plotshape(dcc, title="Dark Cloud Cover",text='DarkCloud\nCover',color=red, style=shape.arrowdown,location=location.abovebar) + +pln= upl and (close[1]=0.7 and close>open and abs(close-open)/range>=0.7 and open<=close[1] and close((open[1]+close[1])/2)) +plotshape(pln, title="Piercieng Line",text="Piercing\nLine",color=green, style=shape.arrowup,location=location.belowbar) + +beh = ubh and (close[1] > open[1] and open > close and open <= close[1] and low >= open[1] and open - close < close[1] - open[1] and (high < high[1] and low > low[1])) +plotshape(beh and not dcc, title= "Bearish Harami", color=red, style=shape.arrowdown, text="Bear\nHarami") + +blh = ubh and (open[1] > close[1] and close > open and close <= open[1] and high <= open[1] and close - open < open[1] - close[1] and (high < high[1] and low > low[1])) +plotshape(blh and not pln, title= "Bullish Harami", location=location.belowbar, color=green, style=shape.arrowup, text="Bull\nHarami") + +bee = ube and (close[1] > open[1] and close < open and close<=low[1] and open>= close[1]) +plotshape(bee, title= "Bearish Engulfing", color=red, style=shape.arrowdown, text="Bearish\nEngulf") + +ble = ube and (close[1] < open[1] and close > open and close >= high[1] and open<=close[1]) +plotshape(ble, title= "Bullish Engulfing", location=location.belowbar, color=green, style=shape.arrowup, text="Bullish\nEngulf") + +blfr = ufb and crossover(close,topfractals) +plotshape(blfr and not ble and not blh and not sBarUp, title= "Bullish Fractal Cross", location=location.belowbar, color=green, style=shape.arrowup, text="Fractal\nCross") +befr = ufb and crossunder(close,botfractals) +plotshape(befr and not bee and not beh and not sBarDown, title= "Bearish Fractal Cross", color=red, style=shape.arrowdown, text="Fractal\nCross") + +// +bcolorDn = sbarDn and not(pBarRDn or pBarRUp or sBarDown or insideBarDn or outsideBarDn) and (beh or bee or dcc or befr or pBarDn) +bcolorUp = sbarUp and not(pBarRDn or pBarRUp or sBarUp or insideBarUp or outsideBarUp) and (blh or ble or pln or blfr or pBarUp) +barcolor(bcolorDn ? maroon : na) +barcolor(bcolorUp ? lime : na) +// +barcolor(sgb and close ? gray : na) + +// +barAlertDn = (sbarDn and (befr or bee or beh or pBarDn or dcc)) or (sbarDn and (insideBarDn or outsideBarDn or sBarDown)) or pBarRDn +barAlertUp = (sbarUp and (blfr or ble or blh or pBarUp or pln)) or (sbarUp and (insideBarUp or outsideBarUp or sBarUp)) or pBarRUp +barAlert = barAlertDn or barAlertUp +alertcondition(barAlert,title="CDLTRD Alert", message="CDLTRD Bar Alert") +// show only when alert condition is met and bar closed. +plotshape(salc and barAlert[1],title= "Alert Indicator Closed", location=location.bottom, color=barAlertDn[1]?red:green, transp=0, style=shape.circle,offset=-1) +//EOF \ No newline at end of file diff --git a/xSamples/indicators/chandelier-exit.pine b/xSamples/indicators/chandelier-exit.pine new file mode 100644 index 0000000..1f61808 --- /dev/null +++ b/xSamples/indicators/chandelier-exit.pine @@ -0,0 +1,48 @@ +//@version=4 +// Copyright (c) 2019-present, Alex Orekhov (everget) +// Chandelier Exit script may be freely distributed under the terms of the GPL-3.0 license. +study("Chandelier Exit", shorttitle="CE", overlay=true) + +length = input(title="ATR Period", type=input.integer, defval=22) +mult = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0) +showLabels = input(title="Show Buy/Sell Labels ?", type=input.bool, defval=true) +useClose = input(title="Use Close Price for Extremums ?", type=input.bool, defval=true) +highlightState = input(title="Highlight State ?", type=input.bool, defval=true) + +atr = mult * atr(length) + +longStop = (useClose ? highest(close, length) : highest(length)) - atr +longStopPrev = nz(longStop[1], longStop) +longStop := close[1] > longStopPrev ? max(longStop, longStopPrev) : longStop + +shortStop = (useClose ? lowest(close, length) : lowest(length)) + atr +shortStopPrev = nz(shortStop[1], shortStop) +shortStop := close[1] < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop + +var int dir = 1 +dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir + +var color longColor = color.green +var color shortColor = color.red + +longStopPlot = plot(dir == 1 ? longStop : na, title="Long Stop", style=plot.style_linebr, linewidth=2, color=longColor) +buySignal = dir == 1 and dir[1] == -1 +plotshape(buySignal ? longStop : na, title="Long Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=longColor, transp=0) +plotshape(buySignal and showLabels ? longStop : na, title="Buy Label", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=longColor, textcolor=color.white, transp=0) + +shortStopPlot = plot(dir == 1 ? na : shortStop, title="Short Stop", style=plot.style_linebr, linewidth=2, color=shortColor) +sellSignal = dir == -1 and dir[1] == 1 +plotshape(sellSignal ? shortStop : na, title="Short Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=shortColor, transp=0) +plotshape(sellSignal and showLabels ? shortStop : na, title="Sell Label", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=shortColor, textcolor=color.white, transp=0) + +midPricePlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0, display=display.none, editable=false) + +longFillColor = highlightState ? (dir == 1 ? longColor : na) : na +shortFillColor = highlightState ? (dir == -1 ? shortColor : na) : na +fill(midPricePlot, longStopPlot, title="Long State Filling", color=longFillColor) +fill(midPricePlot, shortStopPlot, title="Short State Filling", color=shortFillColor) + +changeCond = dir != dir[1] +alertcondition(changeCond, title="Alert: CE Direction Change", message="Chandelier Exit has changed direction!") +alertcondition(buySignal, title="Alert: CE Buy", message="Chandelier Exit Buy!") +alertcondition(sellSignal, title="Alert: CE Sell", message="Chandelier Exit Sell!") diff --git a/xSamples/indicators/chandelier-stop.pine b/xSamples/indicators/chandelier-stop.pine new file mode 100644 index 0000000..5288cff --- /dev/null +++ b/xSamples/indicators/chandelier-stop.pine @@ -0,0 +1,33 @@ +//+------------------------------------------------------------------+ +//| Edited original VStop Script from LazyBear using info from | +//| ChandelierStops_v1.mq4 | +//| Copyright © 2006, Forex-TSD.com | +//| Written by IgorAD,igorad2003@yahoo.co.uk | +//| http://finance.groups.yahoo.com/group/TrendLaboratory | +//+------------------------------------------------------------------+ + +study("Chandelier Stop", overlay=true) + +//input variables +Length=input(title="Look Back Period", type=integer, defval=22) +ATRPeriod=input(title="ATR Period", type=integer, defval=22) +Mult=input(title="ATR Multiplier", type=integer, defval=3) + +//calculate stop value +short_stop = lowest(Length)+Mult*atr(ATRPeriod) +long_stop = highest(Length)-Mult*atr(ATRPeriod) + +shortvs=na(shortvs[1]) ? short_stop : iff(close>shortvs[1], short_stop , min(short_stop,shortvs[1])) +longvs=na(longvs[1]) ? long_stop : iff(close=shortvs[1] and close[1]longvs[1] , 1 , 0) + +direction= iff(na(direction[1]), 0, + iff (direction[1]<=0 and longswitch, 1, + iff (direction[1]>=0 and shortswitch, -1, direction[1]))) + +pc=direction>0?longvs:shortvs + +plot(pc, color=direction>0?aqua:fuchsia, style=circles, linewidth=2) +plot(pc, color=direction>0?aqua:fuchsia, style=line, linewidth=2) \ No newline at end of file diff --git a/xSamples/indicators/high-low-channel-swing.pine b/xSamples/indicators/high-low-channel-swing.pine new file mode 100644 index 0000000..e68ad85 --- /dev/null +++ b/xSamples/indicators/high-low-channel-swing.pine @@ -0,0 +1,84 @@ +// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ +// © exlux99 + +//@version=4 + +strategy(title="High/Low channel swing", shorttitle="Multi MA swing", overlay=true) + + +fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31) +fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12) +fromYear = input(defval = 2000, title = "From Year", minval = 1970) + //monday and session +// To Date Inputs +toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31) +toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12) +toYear = input(defval = 2021, title = "To Year", minval = 1970) + +startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00) +finishDate = timestamp(toYear, toMonth, toDay, 00, 00) +time_cond = time >= startDate and time <= finishDate + +////// +length_ma= input(defval=12, title="Length Moving averages", minval=1) + +////////////////////////////////SETUP/////////////////////////////////////////// + +sma_high = sma(high, length_ma) +ema_high = ema(high, length_ma) +wma_high = wma(high, length_ma) +alma_high = alma(high,length_ma, 0.85, 6) +smma_high = rma(high,length_ma) +lsma_high = linreg(high, length_ma, 0) +vwma_high = vwma(high,length_ma) + + + +avg_high = (sma_high+ema_high+wma_high+alma_high+smma_high+lsma_high+vwma_high)/7 + +/////////////////////////////////////////// + +sma_low = sma(low, length_ma) +ema_low = ema(low, length_ma) +wma_low = wma(low, length_ma) +alma_low = alma(low,length_ma, 0.85, 6) +smma_low = rma(low,length_ma) +lsma_low = linreg(low, length_ma, 0) +vwma_low = vwma(low,length_ma) + + + +avg_low = (sma_low+ema_low+wma_low+alma_low+smma_low+lsma_low+vwma_low)/7 + +////////////////////////////PLOTTING//////////////////////////////////////////// + + +plot(avg_high , title="avg", color=color.green, linewidth = 4) +plot(avg_low , title="avg", color=color.red, linewidth = 4) + +long= close > avg_high +short = close < avg_low + +tplong=input(0.06, title="TP Long", step=0.01) +sllong=input(0.05, title="SL Long", step=0.01) + +tpshort=input(0.045, title="TP Short", step=0.01) +slshort=input(0.05, title="SL Short", step=0.01) + +if(time_cond) + strategy.entry("long",1,when=long) + strategy.exit("closelong", "long" , profit = close * tplong / syminfo.mintick, loss = close * sllong / syminfo.mintick, alert_message = "closelong") + strategy.close("long", when=crossunder(low,avg_low)) + + + strategy.entry("short",0,when=short) + strategy.exit("closeshort", "short" , profit = close * tpshort / syminfo.mintick, loss = close * slshort / syminfo.mintick, alert_message = "closeshort") + strategy.close("short",when=crossover(high,avg_high)) + + + + + + + + diff --git a/xSamples/indicators/hull.trend.pine b/xSamples/indicators/hull.trend.pine new file mode 100644 index 0000000..6ac33ab --- /dev/null +++ b/xSamples/indicators/hull.trend.pine @@ -0,0 +1,24 @@ +//@version=4 +study("Hull Trend", shorttitle="HMA Trend",overlay=true) +length = input(24) +src = input(hl2) +showcross = input(true, "Show cross over/under") + +hma(_src, _length)=> + wma((2 * wma(_src, _length / 2)) - wma(_src, _length), round(sqrt(_length))) + +hma3(_src, _length)=> + p = length/2 + wma(wma(close,p/3)*3 - wma(close,p/2) - wma(close,p),p) + + +a = hma(src, length) +b = hma3(src, length) +c = b > a ? color.lime : color.red +p1 = plot(a,color=c,linewidth=1,transp=75) +p2 = plot(b,color=c,linewidth=1,transp=75) +fill(p1,p2,color=c,transp=55) +crossdn = a > b and a[1] < b[1] +crossup = b > a and b[1] < a[1] +plotshape(showcross and crossdn ? a : na, location=location.absolute, style=shape.labeldown, color=color.red, size=size.tiny, text="Sell", textcolor=color.white, transp=0, offset=-1) +plotshape(showcross and crossup ? a : na, location=location.absolute, style=shape.labelup, color=color.green, size=size.tiny, text="Buy", textcolor=color.white, transp=0, offset=-1) \ No newline at end of file diff --git a/xSamples/indicators/ichimoku.pine b/xSamples/indicators/ichimoku.pine new file mode 100644 index 0000000..8fd9635 --- /dev/null +++ b/xSamples/indicators/ichimoku.pine @@ -0,0 +1,21 @@ +//@version=5 +indicator(title="Ichimoku Cloud", shorttitle="Ichimoku", overlay=true) +conversionPeriods = input.int(9, minval=1, title="Conversion Line Length") +basePeriods = input.int(26, minval=1, title="Base Line Length") +laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length") +displacement = input.int(26, minval=1, title="Lagging Span") +donchian(len) => math.avg(ta.lowest(len), ta.highest(len)) +conversionLine = donchian(conversionPeriods) +baseLine = donchian(basePeriods) +leadLine1 = math.avg(conversionLine, baseLine) +leadLine2 = donchian(laggingSpan2Periods) +plot(conversionLine, color=#2962FF, title="Conversion Line") +plot(baseLine, color=#B71C1C, title="Base Line") +plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span") +p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7, + title="Leading Span A") +p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A, + title="Leading Span B") +plot(leadLine1 > leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1, title = "Kumo Cloud Upper Line", display = display.none) +plot(leadLine1 < leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1, title = "Kumo Cloud Lower Line", display = display.none) +fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90)) \ No newline at end of file diff --git a/xSamples/indicators/leledc.levels.pine b/xSamples/indicators/leledc.levels.pine new file mode 100644 index 0000000..2c1f60c --- /dev/null +++ b/xSamples/indicators/leledc.levels.pine @@ -0,0 +1,60 @@ +//@version=4 +//©InSilico +//Extension/Mod for - https://www.tradingview.com/script/2rZDPyaC-Leledc-Exhaustion-Bar/ +study(title='Exhaustion levels (InSilico)',shorttitle="LeveLeledc (InSilico)",overlay=true) + +//Input +exhaustionSwitch= input(true,title="Show exhaustion Bar point (Arrows)") +levelSwitch= input(true,title="Show exhaustion levels (Lines)") +length= input(40,"Exhaustions swing length") +bars= input(10,"Exhaustion bar count") +thicknesSwitch = input(2, title="Line Thickness(Level thickness)") + +//Fun Lele +Lelec(bars, len) => + bindex = int(na) + bindex := nz(bindex[1], 0) + sindex = int(na) + sindex := nz(sindex[1], 0) + return = 0 + bindex := close > close[4] ? bindex + 1 : bindex + sindex := close < close[4] ? sindex + 1 : sindex + if bindex > bars and close < open and high >= highest(high, len) + bindex := 0 + return := -1 + return + else + if sindex > bars and close > open and low <= lowest(low, len) + sindex := 0 + return := 1 + return + +//Out C +Lelex = Lelec(bars, length) + +//Out Bar +highlel = Lelex == -1 ? high : na +lowlel = Lelex == 1 ? low : na + +//Out level +resistance = float(na) +support = float(na) +resistance := close < open and Lelex ? high : resistance[1] +support := close > open and Lelex ? low : support[1] + +//Color +rescol=color.new(#ff0000, 1) +highcol = change(resistance) == 0 ? rescol: na +supcol=color.new(#138484, 1) +lowcol = change(support) == 0 ? supcol : na + +//Plot Bar +plotshape(exhaustionSwitch ? lowlel : na,title="Up", color=color.new(#00ff00,1), location=location.belowbar, style=shape.triangleup, size=size.normal) +plotshape(exhaustionSwitch ? highlel: na,title="Down", color=color.new(#ff0000, 1), location=location.abovebar, style=shape.triangledown, size=size.normal) + +//Plot level +plot(levelSwitch ? resistance :na, title="Reistance Level", style=plot.style_line, color=highcol, linewidth=thicknesSwitch) +plot(levelSwitch ? support :na, title="Support Level", style=plot.style_line, color=lowcol, linewidth=thicknesSwitch) + +alertcondition(lowlel, "Up") +alertcondition(highlel, "Down") \ No newline at end of file diff --git a/xSamples/indicators/log.pine b/xSamples/indicators/log.pine new file mode 100644 index 0000000..f8c9495 --- /dev/null +++ b/xSamples/indicators/log.pine @@ -0,0 +1,88 @@ +//@version=5 +indicator('Logging in PineScript', overlay=true) + +//////////// +// INPUTS // + +// Pivot Points Input +leftBars = input.int(5, group='Pivot Points') +rightBars = input.int(5, group='Pivot Points') + +log_show = input.bool(true, title='Show Log?', group='Log') +log_show_msg = input.int(10, title='# of message to show', group='Log') +log_offset = input.int(0, title='# of messages to offset', group='Log', step=1) + +////////////////////////// +// 1. Logging Funtions /// + +var bar_arr = array.new_int(0) +var time_arr = array.new_string(0) +var msg_arr = array.new_string(0) +var type_arr = array.new_string(0) + +log_msg(message, type) => + array.push(bar_arr, bar_index) + array.push(time_arr, str.tostring(year) + '-' + str.tostring(month) + '-' + str.tostring(dayofmonth) + ' ' + str.tostring(hour) + ':' + str.tostring(minute) + ':' + str.tostring(second)) + array.push(msg_arr, message) + array.push(type_arr, type) + +// PIVOT POINTS // + +swh = ta.pivothigh(leftBars, rightBars) +swl = ta.pivotlow(leftBars, rightBars) + +hprice = 0.0 +hprice := not na(swh) ? swh : hprice[1] + +lprice = 0.0 +lprice := not na(swl) ? swl : lprice[1] + +plot(hprice, color=color.new(color.green, 0), linewidth=2) +plot(lprice, color=color.new(color.red, 0), linewidth=2) + +// Pivot Points Messages // + +if not na(swh) + log_msg('New Pivot High: ' + str.tostring(hprice), 'message') + +if not na(swh) and hprice > hprice[1] + log_msg('New Pivot Higher High: ' + str.tostring(hprice), 'warning') + +if ta.crossover(close, hprice) + log_msg('Pivot High Cross !!', 'error') + +if not na(swl) + log_msg('New Pivot Low: ' + str.tostring(lprice), 'message') + +if not na(swl) and lprice < lprice[1] + log_msg('New Pivot Lower Low: ' + str.tostring(lprice), 'warning') + +if ta.crossunder(close, lprice) + log_msg('Pivot Low Cross !!', 'error') + + +/////////////////////////////////// +// 2. Create and fill log table // + +var log_tbl = table.new(position.bottom_left, 3, log_show_msg + 1, border_width=1) + +if barstate.islast and log_show + + table.cell(log_tbl, 0, 0, 'Bar #', bgcolor=color.gray, text_size=size.small) + table.cell(log_tbl, 1, 0, 'Time', bgcolor=color.gray, text_size=size.small) + table.cell(log_tbl, 2, 0, 'Message', bgcolor=color.gray, text_size=size.small) + + for i = 1 to log_show_msg by 1 + arr_i = array.size(msg_arr) - log_show_msg + i - 1 - log_offset + + if arr_i < 0 + break + + type = array.get(type_arr, arr_i) + + msg_color = type == 'message' ? #cccccc : type == 'warning' ? #F5AC4E : type == 'error' ? #DD4224 : na + + table.cell(log_tbl, 0, i, str.tostring(array.get(bar_arr, arr_i)), bgcolor=msg_color, text_size=size.small) + table.cell(log_tbl, 1, i, array.get(time_arr, arr_i), bgcolor=msg_color, text_size=size.small) + table.cell(log_tbl, 2, i, array.get(msg_arr, arr_i), bgcolor=msg_color, text_size=size.small) + diff --git a/xSamples/indicators/ma-cross.pine b/xSamples/indicators/ma-cross.pine new file mode 100644 index 0000000..fa29ea8 --- /dev/null +++ b/xSamples/indicators/ma-cross.pine @@ -0,0 +1,9 @@ +//@version=5 +indicator(title="MA Cross", overlay=true, timeframe="", timeframe_gaps=true) +shortlen = input.int(9, "Short MA Length", minval=1) +longlen = input.int(21, "Long MA Length", minval=1) +short = ta.sma(close, shortlen) +long = ta.sma(close, longlen) +plot(short, color = #FF6D00) +plot(long, color = #43A047) +plot(ta.cross(short, long) ? short : na, color=#2962FF, style = plot.style_cross, linewidth = 4) \ No newline at end of file diff --git a/xSamples/indicators/range.filter.buy.and.sell.pine b/xSamples/indicators/range.filter.buy.and.sell.pine new file mode 100644 index 0000000..6b59c8a --- /dev/null +++ b/xSamples/indicators/range.filter.buy.and.sell.pine @@ -0,0 +1,120 @@ +//@version=5 +indicator(title="Range Filter Buy and Sell 5min", shorttitle="Range Filter", overlay=true) + +// Original Script > @DonovanWall +// Adapted Version > @guikroth +// +// Updated PineScript to version 5 +// Republished by > @tvenn + +////////////////////////////////////////////////////////////////////////// +// Settings for 5min chart, BTCUSDC. For Other coin, change the parameters +////////////////////////////////////////////////////////////////////////// + +// Color variables +upColor = color.white +midColor = #90bff9 +downColor = color.blue + +// Source +src = input(defval=close, title="Source") + +// Sampling Period +// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters +per = input.int(defval=100, minval=1, title="Sampling Period") + +// Range Multiplier +mult = input.float(defval=3.0, minval=0.1, title="Range Multiplier") + +// Smooth Average Range +smoothrng(x, t, m) => + wper = t * 2 - 1 + avrng = ta.ema(math.abs(x - x[1]), t) + smoothrng = ta.ema(avrng, wper) * m + smoothrng +smrng = smoothrng(src, per, mult) + +// Range Filter +rngfilt(x, r) => + rngfilt = x + rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : + x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r + rngfilt +filt = rngfilt(src, smrng) + +// Filter Direction +upward = 0.0 +upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1]) +downward = 0.0 +downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1]) + +// Target Bands +hband = filt + smrng +lband = filt - smrng + +// Colors +filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor +barcolor = src > filt and src > src[1] and upward > 0 ? upColor : + src > filt and src < src[1] and upward > 0 ? upColor : + src < filt and src < src[1] and downward > 0 ? downColor : + src < filt and src > src[1] and downward > 0 ? downColor : midColor + +filtplot = plot(filt, color=filtcolor, linewidth=2, title="Range Filter") + +// Target +hbandplot = plot(hband, color=color.new(upColor, 70), title="High Target") +lbandplot = plot(lband, color=color.new(downColor, 70), title="Low Target") + +// Fills +fill(hbandplot, filtplot, color=color.new(upColor, 90), title="High Target Range") +fill(lbandplot, filtplot, color=color.new(downColor, 90), title="Low Target Range") + +// Bar Color +barcolor(barcolor) + +// Break Outs +longCond = bool(na) +shortCond = bool(na) +longCond := src > filt and src > src[1] and upward > 0 or + src > filt and src < src[1] and upward > 0 +shortCond := src < filt and src < src[1] and downward > 0 or + src < filt and src > src[1] and downward > 0 + +CondIni = 0 +CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1] +longCondition = longCond and CondIni[1] == -1 +shortCondition = shortCond and CondIni[1] == 1 + +//Alerts +plotshape(longCondition, title="Buy Signal", text="Buy", textcolor=color.white, style=shape.labelup, size=size.small, location=location.belowbar, color=color.new(#aaaaaa, 20)) +plotshape(shortCondition, title="Sell Signal", text="Sell", textcolor=color.white, style=shape.labeldown, size=size.small, location=location.abovebar, color=color.new(downColor, 20)) + + +alertcondition(longCondition, title="Buy alert on Range Filter", message="Buy alert on Range Filter") +alertcondition(shortCondition, title="Sell alert on Range Filter", message="Sell alert on Range Filter") +alertcondition(longCondition or shortCondition, title="Buy and Sell alert on Range Filter", message="Buy and Sell alert on Range Filter") + + +// For use as a Strategy +// ___________________________________________________________________________________________________________ + +// 1. Replace the word "indicator" on line 2 with the word "strategy" +// 2. Uncomment the code below by highlighting it and pressing Ctl + '/' + +// Settings for 5min BTCUSDT. For other timeframes and assets, adjust the parameters within the settings menu. +// ___________________________________________________________________________________________________________ + +// grp_STRAT = "Strategy settings" +// timeInput = input.time(timestamp("1 Nov 2022 00:00 +0000"), title="Start date", group=grp_STRAT) +// tpInPips = input.int(400, title="TP (in pips)", group=grp_STRAT) +// slInPips = input.int(100, title="SL (in pips)", group=grp_STRAT) + +// timePeriod = time >= timeInput +// notInTrade = strategy.position_size <= 0 + +// if(longCondition and timePeriod and notInTrade) +// strategy.entry("Long", strategy.long) +// strategy.exit("Exit long", "Long", loss=slInPips, profit=tpInPips) +// if(shortCondition and timePeriod and notInTrade) +// strategy.entry("Short", strategy.short) +// strategy.exit("Exit short", "Short", loss=slInPips, profit=tpInPips) diff --git a/xSamples/indicators/ssl.channel.pine b/xSamples/indicators/ssl.channel.pine new file mode 100644 index 0000000..31f4879 --- /dev/null +++ b/xSamples/indicators/ssl.channel.pine @@ -0,0 +1,13 @@ +//@version=3 +study("SSL channel", overlay=true) +period=input(title="Period", defval=10) +len=input(title="Period", defval=10) +smaHigh=sma(high, len) +smaLow=sma(low, len) +Hlv = na +Hlv := close > smaHigh ? 1 : close < smaLow ? -1 : Hlv[1] +sslDown = Hlv < 0 ? smaHigh: smaLow +sslUp = Hlv < 0 ? smaLow : smaHigh + +plot(sslDown, linewidth=2, color=red) +plot(sslUp, linewidth=2, color=lime) \ No newline at end of file diff --git a/xSamples/indicators/stochastic.histogram.pine b/xSamples/indicators/stochastic.histogram.pine new file mode 100644 index 0000000..172920a --- /dev/null +++ b/xSamples/indicators/stochastic.histogram.pine @@ -0,0 +1,19 @@ +///////////////////////////////////////////////////////////////////////////////////// +// Last Edited: 5/19/16 // +// Created By: nboone // +// // +// Description: // +// This is a basic Stochastic histogram that essentially shows when the indicator // +// is either above or below the 50 level. Colors can be customized to your liking. // +// Length and smoothing factor can be adjusted as well. Defaults are 14 (Length) // +// and 3 (Smoothing Factor). // +///////////////////////////////////////////////////////////////////////////////////// +study(title="Stochastic Histogram", shorttitle="NB_StochHist") +length = input(14, minval=1) +smoothK = input(3, minval=1) + +k = (sma(stoch(close, high, low, length), smoothK) - 50) +c = (k > 0) ? green : (k < 0) ? red : black + +plot(k, style=histogram, color=c) +plot(k, color=black) \ No newline at end of file diff --git a/xSamples/indicators/trend-magic.pine b/xSamples/indicators/trend-magic.pine new file mode 100644 index 0000000..90409a6 --- /dev/null +++ b/xSamples/indicators/trend-magic.pine @@ -0,0 +1,19 @@ +// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ +// © KivancOzbilgic + +//@version=4 +study("Trend Magic", shorttitle="TM", overlay=true, format=format.price, precision=2, resolution="") +period=input(20,"CCI period") +coeff=input(1,"ATR Multiplier") +AP=input(5,"ATR Period") +ATR=sma(tr,AP) +src=input(close) +upT=low-ATR*coeff +downT=high+ATR*coeff +MagicTrend=0.0 +MagicTrend := cci(src,period)>=0 ? (upTnz(MagicTrend[1]) ? nz(MagicTrend[1]) : downT) +color1= cci(src,period)>=0 ? #0022FC : #FC0400 +plot(MagicTrend, color=color1, linewidth=3) +alertcondition(cross(close, MagicTrend), title="Cross Alert", message="Price - MagicTrend Crossing!") +alertcondition(crossover(low, MagicTrend), title="CrossOver Alarm", message="BUY SIGNAL!") +alertcondition(crossunder(high, MagicTrend), title="CrossUnder Alarm", message="SELL SIGNAL!") diff --git a/xSamples/indicators/turtle-trade-channels.pine b/xSamples/indicators/turtle-trade-channels.pine new file mode 100644 index 0000000..9fdf5c8 --- /dev/null +++ b/xSamples/indicators/turtle-trade-channels.pine @@ -0,0 +1,59 @@ +//@version=4 +//author: @kivancozbilgic + +study(title="Turtle Trade Channels Indicator", shorttitle="TuTCI", overlay=true, resolution="") +length = input(20,"Entry Length", minval=1) +len2=input(10, "Exit Length", minval=1) +showsignals = input(title="Show Entry/Exit Signals ?", type=input.bool, defval=true) +highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true) + + +lower = lowest(length) +upper = highest(length) +u = plot(upper, "Upper", color=#0094FF) +l = plot(lower, "Lower", color=#0094FF) + +up=highest(high,length) +down=lowest(low,length) +sup=highest(high,len2) +sdown=lowest(low,len2) +K1=barssince(high>=up[1])<=barssince(low<=down[1]) ? down : up +K2=iff(barssince(high>=up[1])<=barssince(low<=down[1]),sdown,sup) +K3=iff(close>K1,down,na) +K4=iff(closeTrendUp[1]? max(Up,TrendUp[1]) : Up +TrendDown=close[1] TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1) +MACD = Trend==1? TrendUp: TrendDown + +linecolor = Trend == 1 ? blue : red + +plot(MACD, color = linecolor , style = line , linewidth = 2,title = "B/S") + +plotshape(cross(close,MACD) and close>MACD , "Up Arrow", shape.triangleup,location.belowbar,blue,0,0) +plotshape(cross(MACD,close) and close=1.0?omed:na, histbase=1.0, style=histogram, color=purple, linewidth=2, title="MediumCycleOB") +plot(omed<=0.0?omed:na, histbase=0.0, style=histogram, color=purple, linewidth=2, title="MediumCycleOS") +plot(oshort>=1.0?oshort:na, histbase=1.0, style=histogram, color=purple, linewidth=2, title="ShortCycleOB") +plot(oshort<=0.0?oshort:na, histbase=0.0, style=histogram, color=purple, linewidth=2, title="ShortCycleOS") +plot(oshort, color=red, linewidth=2, title="FastOsc") +plot(omed, color=green, linewidth=2, title="SlowOsc") +ebc=input(false, title="Enable bar colors") +bc=(oshort>0.5)?(oshort>1.0?purple:(oshort>omed?lime:green)):(oshort<0?purple:(oshort cmean ? -1 + : hso > hso[1] and hso < -cmean ? 1 + : os + +//-----------------------------------------------------------------------------} +//Plot +//-----------------------------------------------------------------------------{ +//Colors +css0 = color.from_gradient(hso, 0, cmean, bull_css_0, bull_css_1) +css1 = color.from_gradient(hso, -cmean, 0, bear_css_1, bear_css_0) +css = hso > 0 ? css0 : css1 + +//Oscillator line/histogram +plot(hso, 'Hull Butterfly', css + , style = plot.style_histogram) + +plot(hso, 'Hull Butterfly', chart.fg_color) + +//Dots +plot(os > os[1] and os == 1 ? hso : na, 'Bullish Dot' + , bull_css_1 + , 2 + , plot.style_circles) + +plot(os < os[1] and os == -1 ? hso : na, 'Bearish Dot' + , bear_css_1 + , 2 + , plot.style_circles) + + +//Levels +plot(cmean, color = color.gray, editable = false) + +plot(cmean / 2, color = color.gray, editable = false) + +plot(-cmean / 2, color = color.gray, editable = false) + +plot(-cmean, color = color.gray, editable = false) + +//-----------------------------------------------------------------------------} diff --git a/xSamples/oscillators/impulse-macd.pine b/xSamples/oscillators/impulse-macd.pine new file mode 100644 index 0000000..8f15c3d --- /dev/null +++ b/xSamples/oscillators/impulse-macd.pine @@ -0,0 +1,36 @@ +// +// @author LazyBear +// +// List of my public indicators: http://bit.ly/1LQaPK8 +// List of my app-store indicators: http://blog.tradingview.com/?p=970 +// +// +study("Impulse MACD [LazyBear]", shorttitle="IMACD_LB", overlay=false) +lengthMA = input(34) +lengthSignal = input(9) +calc_smma(src, len) => + smma=na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len + smma + +calc_zlema(src, length) => + ema1=ema(src, length) + ema2=ema(ema1, length) + d=ema1-ema2 + ema1+d + +src=hlc3 +hi=calc_smma(high, lengthMA) +lo=calc_smma(low, lengthMA) +mi=calc_zlema(src, lengthMA) + +md=(mi>hi)? (mi-hi) : (mimi?src>hi?lime:green:src= 0 +sc2 = sz < 0 +sc3 = sz >= sz[1] +sc4 = sz < sz[1] + + +clr = sc1 and sc3 ? #00FF00 : sc1 and sc4 ? #008000 : + sc2 and sc4 ? #FF0000 : sc2 and sc3 ? #800000 : color.gray + +plot(show_Momen ? sz : na, title="Squeeze Momentum", color=clr, style=plot.style_area) + + + +//SQUEEZE + + + +lengths = input(20, title="BB Length") +mult = input(2.0,title="BB MultFactor") +lengthKC=input(20, title="KC Length") +multKC = input(1.5, title="KC MultFactor") +scale = input(75.0, title = "General scale") +useTrueRange = true + + + +// Calculate BB +source = close +basis = sma(source, lengths) +dev = multKC * stdev(source, lengths) +upperBB = basis + dev +lowerBB = basis - dev + +// Calculate KC +ma = sma(source, lengthKC) +range = useTrueRange ? tr : (high - low) +rangema = sma(range, lengthKC) +upperKC = ma + rangema * multKC +lowerKC = ma - rangema * multKC + +sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC) +sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC) +noSqz = (sqzOn == false) and (sqzOff == false) + +scolor = noSqz ? color.blue : sqzOn ? #000000 : color.gray +//plotshape(show_Momen? true : na, color=scolor, style=shape.xcross) +plot(show_Momen ? 0 : na, title="Squeeze Zero Line", color=scolor, linewidth=2, style=plot.style_cross, transp=0) +//plotshape(show_Momen?0:na,style=shape.xcross,color=scolor,location=location.absolute) + + + +///// ADX + + + +show_ADX = input(true, title = "------------Show ADX------------") +scaleADX = input(2.0, title = "ADX scale") +show_di = input(false, title = " Show +DI -DI") +show_aa = input(false, "Mostrar punto 23 aparte", inline="adx line") +far = input(-7, "Separacion", inline="adx line") +adxlen = input(14, title = "ADX Smoothing") +dilen = input(14, title = "DI Length") +keyLevel = input(23, title = "Key level for ADX") +show_bg = input (false, title = "Show bg color") + + +dirmov(len) => + up = change(high) + down = -change(low) + truerange = rma(tr, len) + plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange) + minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange) + [plus, minus] + +adx(dilen, adxlen) => + [plus, minus] = dirmov(dilen) + sum = plus + minus + adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen) + [adx, plus, minus] + +[adxValue, diplus, diminus] = adx(dilen, adxlen) + +/////////////////////////////////////////////////////////////// + +//[diplus, diminus, adxValue] = dmi(dilen, adxlen) + +biggest(series) => + max = 0.0 + max := nz(max[1], series) + if series > max + max := series + max + +// Calculate ADX Scale +ni = biggest(sz) +far1=far* ni/scale +adx_scale = (adxValue - keyLevel) * ni/scale + +adx_scale2 = (adxValue - keyLevel+far) * ni/scale + + + +dip= (diplus - keyLevel) * ni/scale +dim= (diminus - keyLevel) * ni/scale +plot (show_di ? dip * scaleADX :na, color=color.green, title="DI+") +plot (show_di ? dim * scaleADX :na, color=color.red, title="DI-") + +color_ADX = adxValue > adxValue[1] ? #ffffff : #a09a9a + +bgcolor(adxValue > adxValue[1] and adxValue > 23 and show_Momen and show_bg? clr : na, transp=95) + + + + + + +/////////////////WHALE BY BLACKCAT1404 + +show_whale = input(false,title = "Show Whale detector") + + +//functions +xrf(values, length) => + r_val = float(na) + if length >= 1 + for i = 0 to length by 1 + if na(r_val) or not na(values[i]) + r_val := values[i] + r_val + r_val + +xsa(src,len,wei) => + sumf = 0.0 + ma = 0.0 + out = 0.0 + sumf := nz(sumf[1]) - nz(src[len]) + src + ma := na(src[len]) ? na : sumf/len + out := na(out[1]) ? ma : (src*wei+out[1]*(len-wei))/len + out + +//trend follower algorithm +var2 = xrf(low,1) +var3 = xsa(abs(low-var2),3,1)/xsa(max(low-var2,0),3,1)*100 +var4 = ema(iff(close*1.2,var3*10,var3/10),3) +var5 = lowest(low,30) +var6 = highest(var4,30) +var7 = iff(lowest(low,58),1,0) +var8 = ema(iff(low<=var5,(var4+var6*2)/2,0),3)/618*var7 + + +//whale pump detector +//plotcandle(0,var8 * (ni/scale) ,0,var8* (ni/scale),color= var8 > 0 and show_whale ?color.yellow:na) + +plot(show_whale? var8 * (ni/scale) : na, title = "whale" , style = plot.style_columns,color=color.yellow, transp=80) + + + + + + +/////////////////// + + + + +//RSI +show_rsi = input(true, title="------------Show RSI---------") +show_RSIfondo=input(true, title="Show RSI background") +rsiApart = input(0,title="RSI separation") +len = input(14, minval=1, title="Length RSI ") +upperR = input (70,title="Upper band") +middleR = input (50,title="Middle band") +lowerR = input(30,title="Lower band") +rsi = rsi(src, len) +rsiColor = rsi <= lowerR ? color.green : rsi >= upperR ? color.red : #da00ff +rsi_scale=(rsi+rsiApart)* ni/scale + + +b1s=(rsiApart+upperR) * ni/scale +bm= (rsiApart+middleR) * ni/scale +b0s=(rsiApart+lowerR) * ni/scale + + + +/////otro RSI DIVERGENCE +show_rsi2 = input (true,title = "Show RSI DIVERGENCE") +farRSI = input(70,title = "Adjust RSI DIVERGENCE") +src_fast = close, len_fast = input(5, minval=1, title="Length Fast RSI") +src_slow = close, len_slow = input(14,minval=1, title="Length Slow RSI") +up_fast = rma(max(change(src_fast), 0), len_fast) +down_fast = rma(-min(change(src_fast), 0), len_fast) +rsi_fast = down_fast == 0 ? 100 : up_fast == 0 ? 0 : 100 - (100 / (1 + up_fast / down_fast)) +up_slow = rma(max(change(src_slow), 0), len_slow) +down_slow = rma(-min(change(src_slow), 0), len_slow) +rsi_slow = down_slow == 0 ? 100 : up_slow == 0 ? 0 : 100 - (100 / (1 + up_slow / down_slow)) +//plotfast = plot(rsi_fast, color=blue) +//plotslow = plot(rsi_slow, color=orange) +divergence = rsi_fast - rsi_slow +//plotdiv = plot(divergence, color = divergence > 0 ? color.lime:color.red, linewidth = 2) +divergence_scale = divergence * (ni/scale) +rsiColor2 = divergence > 0 ? color.lime:color.red +plot(show_rsi ? rsi_scale : show_rsi2 ? divergence_scale + (farRSI * ni/scale) : na, "RSI", color=show_rsi ? rsiColor : show_rsi2 ? rsiColor2 :na) +////// + +///////// +/////// estocastico + +show_stoch=input(false,title="-------Show Stochastic------") + + +periodK = input(14, title="%K Length", minval=1) +smoothK = input(1, title="%K Smoothing", minval=1) +periodD = input(3, title="%D Smoothing", minval=1) +k = sma(stoch(close, high, low, periodK), smoothK) +d = sma(k, periodD) + +k1=k* ni/scale +d1=d* ni/scale +plot(show_stoch?k1:na, title="%K", color=#2962FF) +plot(show_stoch?d1:na, title="%D", color=#FF6D00) +upS=input(80,title = "Upper band") +lowS=input(20,title = "Lower band") + +h1s=upS * ni/scale +h0s=lowS * ni/scale +//plot(show_stoch? h1s : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) +//plot(show_stoch? h0s : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) + +//band1 = plot(show_rsi? b1s : show_stoch? h1s: na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) +//bandm = plot(show_rsi? bm : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=70) +//band0 = plot(show_rsi? b0s : show_stoch ? h0s: na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) + + +/////// + + + +/////////////////AWESOME +show_ao = input(false, title="-----------Show AO-------") +show_aoF = input(true, title = "Show ao away 0 point") +farAO = input(-30 , title = "Away from 0 point") + +fastLength = input(5,title="Fast Length") +slowLength = input(34,title="Slow Length") + + +ao = sma(hl2, fastLength) - sma(hl2, slowLength) +//nia = biggest(aoN) +//ao = aoN*nia/scale + + +ao_f = ao + (farAO * ni /scale) + + +aoColor = ao >= 0 ? (ao[1] < ao ? #26A69A : #B2DFDB) : (ao[1] < ao ? #FFCDD2 : #EF5350) + + +aoPlot = plot(show_aoF and show_ao ? ao_f : show_ao ? ao : na, title="AO", style= show_aoF ? plot.style_line : show_ao ? plot.style_area: plot.style_area , color=aoColor, transp=0) // + + +bandA = plot(show_aoF and show_ao ? farAO * ni /scale : na, color=color.white,transp=60) + + +fill(aoPlot,bandA, color= show_aoF and show_ao ? aoColor : na,transp=90,title="AO Fill") + +///////////////////// + + +//////////////////////////////////// +///////MACD +///////////////////////////// +show_macd = input(false, title="-----------Show MACD-------") +show_macdF = input (true, title = "Show MACD area away 0 point") +show_macdLF = input(true, title = "Show MACD lines away 0 point") +macdF = input(-30 , title = "Away 0 point") +show_macdL= input(false, title="Show MACD lines") +fast_length = input(title="Fast Length", type=input.integer, defval=12) +slow_length = input(title="Slow Length", type=input.integer, defval=26) +//src = input(title="Source", type=input.source, defval=close) +signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9) +sma_source = input(title="Oscillator MA Type", type=input.string, defval="EMA", options=["SMA", "EMA"]) +sma_signal = input(title="Signal Line MA Type", type=input.string, defval="EMA", options=["SMA", "EMA"]) +macdScale = input(2,title="MACD scale") + + +//calculating +fast_ma = sma_source == "SMA" ? sma(src, fast_length) : ema(src, fast_length) +slow_ma = sma_source == "SMA" ? sma(src, slow_length) : ema(src, slow_length) +macd1 = fast_ma - slow_ma +signal = sma_signal == "SMA" ? sma(macd1, signal_length) : ema(macd1, signal_length) +hist = (macd1 - signal) +//color +macdColor = hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #EF5350) +histo = hist * macdScale +macd=macd1*macdScale +sign = signal * macdScale + +histo_f = histo + (macdF * ni /scale) + +colorlineMACD = macd > sign ? color.green : color.red + +histoA = plot(show_macdF and show_macd ? histo_f : show_macd ? histo : na, title="Histogram", style=show_macdF and show_macd ? plot.style_line : show_macd ? plot.style_columns : plot.style_columns , color=macdColor) +plot(show_macdLF and show_macdL ? macd + (macdF * ni /scale) : show_macdL ? macd : na, title="MACD", color=colorlineMACD) +plot(show_macdLF and show_macdL ? sign + (macdF * ni /scale) : show_macdL ? sign : na, title="Signal", color=color.orange) + +band_macd = plot(show_macdF and show_macd ? macdF * ni /scale : na, color=color.white,transp=60) + +fill(histoA,band_macd, color= show_macdF and show_macd ? macdColor : na,transp=90,title="MACD Fill") +//////////////////////////////////////// +//////////////////////END MACD +///////////////////////////////// + +//////////////////////////////////////// +////////////////////// KONOCORDE "Koncorde Inversiones en el Mundo by lkdml all the credits for them +///////////////////////////////// +show_K = input(false, title = "---------------Show Koncorde-------------") +scaleK= input(8,title = "Koncorde scale") +showKF = input(true, title = "Show Koncorde away 0 point") +fark= input (-30 , title = "Away from 0 point") +show_KD = input(false, title = "Show Koncorde Diamond") +kon_pos = input (30, title = "Position diamonds Bull") +kon_posn = input (-30, title = "Position diamonds Bear") +srcTprice = input(ohlc4, title="Fuente para Precio Total") +srcMfi = input(hlc3, title="Fuente MFI", group="Money Flow Index") +tprice=srcTprice + +//lengthEMA = input(255, minval=1) + + +m=input(15, title="Media Exponencial") +longitudPVI=input(90, title="Longitud PVI") +longitudNVI=input(90, title="Longitud NVI") +longitudMFI=input(14, title="Longitud MFI") +multK=input(2.0, title="Multiplicador para derivacion estandar" , group="Bollinger Oscillator") +boLength=input(25, title="Calculation length ", group="Bollinger Oscillator" ) + +pvim = ema(pvi, m) +pvimax = highest(pvim, longitudPVI) +pvimin = lowest(pvim, longitudPVI) +oscp = (pvi - pvim) * 100/ (pvimax - pvimin) + +nvim = ema(nvi, m) +nvimax = highest(nvim, longitudNVI) +nvimin = lowest(nvim, longitudNVI) +azul =( (nvi - nvim) * 100/ (nvimax - nvimin) ) + +xmf = mfi(srcMfi, longitudMFI) + +// Bands Calculation +basisK = sma(tprice, boLength) //Find the 20-day moving average average (n1 + n2 ... + n20)/20 +devK = mult * stdev(tprice, boLength) //Find the standard deviation of the 20-days +upper = basisK + devK //Upper Band = 20-day Moving Average + (2 x standard deviation of the 20-days) +lower = basisK - devK //Lower Band = 20-day Moving Average - (2 x standard deviation of the 20-days) +OB1 = (upper + lower) / 2.0 +OB2 = upper - lower + +BollOsc = ((tprice - OB1) / OB2 ) * 100 // percent b +xrsi = rsi(tprice, 14) + +calc_stoch(src, length,smoothFastD ) => + ll = lowest(low, length) + hh = highest(high, length) + k = 100 * (src - ll) / (hh - ll) + sma(k, smoothFastD) + +stoc = calc_stoch(tprice, 21, 3) +marron =( (xrsi + xmf + BollOsc + (stoc / 3))/2 ) +verde = (marron + oscp) +media = ema(marron,m) +bandacero= showKF ? fark*ni/scale : 0 +scaleK1 = (ni/scale)/scaleK + +//vl=plot(show_K ? verde *scaleK1: na, color=#66FF66, style=plot.style_area, title="verde")// COLOURED(102,255,102) as “verde” , GREEN +//ml=plot(show_K ? marron *scaleK1: na, color= #FFCC99, style=plot.style_area, title="marron", transp=0) // COLOURED(255,204,153) as"marron" , BEIGE +//al=plot(show_K ? azul *scaleK1: na, color=#126bd6, style=plot.style_area, title="azul") // COLOURED(0,255,255) as “azul” , + +lk1 = plot(show_K and showKF ? (marron *scaleK1) + (fark * ni /scale) : show_K ? marron *scaleK1: na, color= #330000, style=plot.style_line, linewidth=3, title="lmarron") // COLOURED(51,0,0) as “lmarron” , +lk2 = plot(show_K and showKF ? (verde *scaleK1) + (fark * ni /scale) : show_K ? verde *scaleK1: na, color=#006600, style=plot.style_line, linewidth=3, title="lineav") // COLOURED(0,102,0) as “lineav” , +lk3 = plot(show_K and showKF ? (azul *scaleK1) + (fark * ni /scale): show_K ? azul *scaleK1: na, color=#000066, style=plot.style_line, title="lazul" ) // COLOURED(0,0,102) as “lazul” , +plot(show_K and showKF ? (media *scaleK1) + (fark * ni /scale) : show_K ? media *scaleK1: na, color=color.red, title="media", style=plot.style_line, linewidth=2) // COLOURED(255,0,0) as “media” , +band0k = plot(show_K ? bandacero : na , color=color.black, title="cero") + +fill(lk2,band0k,color = show_K ? #66FF66 : na , title = "verde", transp = 50) +fill(lk1,band0k,color = show_K ? #FFCC99 : na , title = "marron", transp = 50) +fill(lk3,band0k,color = show_K ? #00FFFF : na , title = "azul", transp = 50) + + +konBull = crossover(marron,media) and show_KD +konBear = crossunder(marron,media) and show_KD + +konlBull=kon_pos * ni/scale +konlBear=kon_posn * ni/scale +plotchar(konBull ? konlBull : konBear ? konlBear : na, title = 'Koncorde diamond', char='◆', color = konBull ? color.lime : konBear ? color.maroon : color.white, location = location.absolute, size = size.tiny, transp = 0) + + + +//////////////////////////////////////// +////////////////////// END KONCORDE +///////////////////////////////// + + +//////////////////////////////////////// +////////////////////// CCI +///////////////////////////////// +show_cci = input(false, title="------------Show CCI---------") +cci_len = input(14, "CCI length") +cci_src = input(close, "CCI source") +upperCCI = input(100, "CCI Upper band") +lowerCCI = input(-100, "CCI lower band") + +b1cci = (upperCCI * ni/scale)*30/100 +b0cci = (lowerCCI * ni/scale) *30/100 +cci = cci(cci_src, cci_len) + + +cci_scale = (30) * ((cci) * ni/scale) / 100 +//cci_scale=((cci * ni/scale)/scale) *scale_cci +//(cci / (ni * scale) ) + (50*ni/scale) +//cci_color = c1 ? #F8B856 : c2 ? #F6AD3C : c3 ? #F5A21B : #F39800 +plot(show_cci ? cci_scale : na, color=color.blue, transp=0, linewidth=2, title="CCI") + +//////////////////////////////////////// +////////////////////// END CCI +///////////////////////////////// + +/////////////////// +//////// +//////////////////// +colorcm = show_cci ? color.blue : color.white +band1 = plot(show_rsi? b1s : show_stoch? h1s : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) +band0 = plot(show_rsi? b0s : show_stoch ? h0s: show_cci ? b0cci : na,color=bar_index % 2 == 0 ? color.white : #00000000,transp=60) +bandm = plot(show_cci ? b1cci : show_rsi? bm : show_rsi2 ? (farRSI * ni/scale): na,color=bar_index % 2 == 0 ? colorcm : #00000000,transp=70) +band00 = plot(show_cci? b0cci : na, color=bar_index % 2 == 0 ? color.blue : #00000000,transp=60) +fill(band1,band0, color= show_rsi and show_RSIfondo? color.purple : na,transp=90,title="RSI background") +////////////// +//////// + + + + + + +/////////////////////\/ +/////////////MFI i got the code fo=rom the CIPHER indicator by vumanchu +////////////////////// + + +rsiMFIShow = input(true, title = '----------Show MFI---------', type = input.bool) +rsiMFIperiod = input(60,title = 'MFI Period', type = input.integer) +rsiMFIMultiplier = input(150, title = 'MFI Area multiplier', type = input.float) +rsiMFIPosY = input(2.5, title = 'MFI Area Y Pos', type = input.float) + + +// RSI+MFI +f_rsimfi(_period, _multiplier, _tf) => security(syminfo.tickerid, _tf, sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY) + +rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, timeframe.period) +rsiMFIColor1 = #ffffff +rsiMFIColor2 = #d1d4dc + +rsiMFIColor = rsiMFI >= 0 ? rsiMFIColor1: rsiMFI < 0 ? rsiMFIColor2 : na +rsiMFIplot = plot(rsiMFIShow ? rsiMFI * ni/scale: na, title = 'RSI+MFI Area', color =rsiMFIColor , transp = 80,style=plot.style_area) + + +///////////////////// +///////// +////////////////////// + +//WT the cipher dots use a indicator by lazy bear +show_cphr = input(true,title = "------------Show Cipher dots---------") +n1 = input(9, title = "Channel Length") +n2 = input(12, title = "Average Length") +smooth = input(3, title = "Smooth Factor") + + //wt +CALC(n1, n2, smooth) => + ap = hlc3 + esa = ema(ap, n1) + dw = ema(abs(ap - esa), n1) + ci = (ap - esa) / (0.015 * dw) + tci = ema(ci, n2) + + wt1 = tci + wt2 = sma(wt1,smooth) + wave = wt1 - wt2 + wavecolor = wave >=0? color.lime : color.red + [wave, wavecolor] + + //CIPHERR +[wave, wavecolor] = CALC(n1, n2, smooth) + +middle = 0 +condWt = cross(wave,middle) ? true : na +wtjeje= show_Momen ? sz : show_ao ? ao : show_macd ? macd : na +plot(condWt and show_cphr ? wtjeje : na, title = 'Buy and sell circle', color = wavecolor, style = plot.style_circles, linewidth = 3, transp = 15) + +/////plot ADX + +plot(show_aa ? far1 *scaleADX : na,color=color.white, title="Punto 23") +p1 = plot(show_aa ? adx_scale2 * scaleADX : show_ADX ? adx_scale * scaleADX : na, color = color_ADX, title = "ADX", linewidth = 2) + +/// +/////////////// +// ESTADOOO +show_status = input(true, title = "------Show STATUS----------") +dist= input(10,title="Distancia del monitor") +dashColor = input(color.new(#696969, 90), "label Color", inline="Dash Line") +dashTextColor = input(color.new(#ffffff, 0), "Text Color", inline="Dash Line") + + +if(adxValue > adxValue[1] and adxValue > 23) + iadx='ADX con pendiente positiva por encima punto 23' +if(adxValue > adxValue[1] and adxValue < 23) + iadx='ADX con pendiente positiva por debajo punto 23' +if(adxValue < adxValue[1] and adxValue < 23) + iadx='ADX con pendiente negativa por debajo punto 23' +if(adxValue < adxValue[1] and adxValue > 23) + iadx='ADX con pendiente negativa por encima punto 23' + + + + +a1=adxValue >= 23 +a2=adxValue < 23 +a3=adxValue >= adxValue[1] +a4=adxValue < adxValue[1] + + +iAdx = a1 and a3 ? 'Pendiente positiva ↑ 23' : a1 and a4 ? 'Pendiente negativa ↑ 23' : + a2 and a4 ? 'Pendiente negativa ↓ 23' : a2 and a3 ? 'Pendiente positiva ↓ 23' : '-' + + +iMom = sc1 and sc3 ? 'Direccionalidad alcista' : sc1 and sc4 ? 'Direccionalidad bajista' : + sc2 and sc4 ? 'Direccionalidad bajista' : sc2 and sc3 ? 'Direccinalidad alcista' : '-' + +igral = a1 and a3 and sc1 and sc3 ? 'Fuerte movimiento alcista' : a1 and a3 and sc1 and sc4 ? 'Monitor muestra rango-caida pero\nel movimiento tiene fuerza': + a1 and a3 and sc2 and sc4 ? 'Fuerte movimiento bajista' : a1 and a3 and sc2 and sc3 ? 'Monitor muestra rango-subida pero\nel movimiento tiene fuerza': + a1 and a4 and sc1 and sc3 ? 'Movimiento alcista sin fuerza' : a1 and a4 and sc1 and sc4 ? 'Monitor muestra rango-caida\n pendiente negativa en ADX ': + a1 and a4 and sc2 and sc4 ? 'Movimiento bajista sin fuerza' : a1 and a4 and sc2 and sc3 ? 'Monitor muestra rango-subida con \npendiente negativa en ADX ': + a2 and a4 and sc1 and sc3 ? 'Movimiento alcista sin fuerza' : a2 and a4 and sc1 and sc4 ? 'Monitor muestra rango-caida sin fuerza ': + a2 and a4 and sc2 and sc4 ? 'Movimiento bajista sin fuerza' : a2 and a4 and sc2 and sc3 ? 'Monitor muestra rango-subida sin fuerza ': + a2 and a3 and sc1 and sc3 ? 'Movimiento alcista que \n quiere agarrar fuerza' : a2 and a3 and sc1 and sc4 ? 'Monitor muestra rango-caida,\n el movimiento quiere agarrar fuerza': + a2 and a3 and sc2 and sc4 ? 'Movimiento bajista que \n quiere agarrar fuerza' : a2 and a3 and sc2 and sc3 ? 'Monitor muestra rango-subida,\n el movimiento quiere agarrar fuerza': '-' + + +s='\n' +scr_label='Info ADX: '+iAdx+s+'Info monitor: '+iMom+s+'Info general:'+s+igral +// Plot Label on the chart +// Plot Label on the chart + +if show_status + + lab_l = label.new( + bar_index + dist, 0, '\t Estatus segun estrategia\n\t' + scr_label, + color = dashColor, + textcolor = dashTextColor, + style = label.style_label_left, + yloc = yloc.price) + label.delete(lab_l[1]) + +// Send alert only if screener is not empty +if (scr_label != '') + alert('Estatus segun estrategia\n' + scr_label, freq = alert.freq_once_per_bar_close ) + + + + +////////////////////////////////// + + +//DIVERGENCIAS BUENNNNNNNAS +show_div=input(true,title="------Divergencias--------") +lbR = input(title="Pivot Lookback Right", defval=1) +lbL = input(title="Pivot Lookback Left", defval=1) +rangeUpper = input(title="Max of Lookback Range", defval=60) +rangeLower = input(title="Min of Lookback Range", defval=1) +plotBull = input(title="Plot Bullish", defval=true) +plotHiddenBull = input(title="Plot Hidden Bullish", defval=true) +plotBear = input(title="Plot Bearish", defval=true) +plotHiddenBear = input(title="Plot Hidden Bearish", defval=true) + + +bearColor = #ff0000 +bullColor = #1bff00 +hiddenBullColor = #a4ff99 +hiddenBearColor = #ff9e9e +textColor = color.white +noneColor = color.new(color.white, 100) + +//FUNCTIONS +plFound(osc) => na(pivotlow(osc, lbL, lbR)) ? false : true +phFound(osc) => na(pivothigh(osc, lbL, lbR)) ? false : true + +_inRange(cond) => + bars = barssince(cond == true) + rangeLower <= bars and bars <= rangeUpper + + +_findDivRB(osc)=> + // Osc: Higher Low + oscHL = osc[lbR] > valuewhen(plFound(osc), osc[lbR], 1) and _inRange(plFound(osc)[1]) + + // Price: Lower Low + priceLL = low[lbR] < valuewhen(plFound(osc), low[lbR], 1) + + bullCond = plotBull and priceLL and oscHL and plFound(osc) + + + //------------------------------------------------------------------------------ + // Hidden Bullish + + // Osc: Lower Low + oscLL = osc[lbR] < valuewhen(plFound(osc), osc[lbR], 1) and _inRange(plFound(osc)[1]) + + // Price: Higher Low + priceHL = low[lbR] > valuewhen(plFound(osc), low[lbR], 1) + + hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound(osc) + + + + //------------------------------------------------------------------------------ + // Regular Bearish + + // Osc: Lower High + oscLH = osc[lbR] < valuewhen(phFound(osc), osc[lbR], 1) and _inRange(phFound(osc)[1]) + + // Price: Higher High + priceHH = high[lbR] > valuewhen(phFound(osc), high[lbR], 1) + + bearCond = plotBear and priceHH and oscLH and phFound(osc) + + + + //------------------------------------------------------------------------------ + // Hidden Bearish + + // Osc: Higher High + oscHH = osc[lbR] > valuewhen(phFound(osc), osc[lbR], 1) and _inRange(phFound(osc)[1]) + + // Price: Lower High + priceLH = high[lbR] < valuewhen(phFound(osc), high[lbR], 1) + + hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound(osc) + + [bullCond,hiddenBullCond,bearCond,hiddenBearCond] + + + + +[sz_bullCond,sz_hiddenBullCond,sz_bearCond,sz_hiddenBearCond]=_findDivRB(sz) + + +foundDivBSZ = plFound(sz) and show_Momen and show_div ? true : false +colordivBSZ = sz_bullCond ? bullColor : sz_hiddenBullCond ? hiddenBullColor : noneColor +foundDivBeSZ = phFound(sz) and show_Momen and show_div ? true : false +colordivBeSZ = sz_bearCond ? bearColor : sz_hiddenBearCond ? hiddenBearColor : noneColor + + + +plot( + foundDivBSZ ? sz[lbR] : na, + offset=-lbR, + title="Regular Bullish", + linewidth=1, + color=colordivBSZ, + transp=0 + ) +plot( + foundDivBeSZ ? sz[lbR] : na, + offset=-lbR, + title="Regular Bullish", + linewidth=1, + color=colordivBeSZ, + transp=0 + ) + + + + + + +////////////////////RSI DIV////////////////// + + +[rsi_bullCond,rsi_hiddenBullCond,rsi_bearCond,rsi_hiddenBearCond]=_findDivRB(rsi_scale) + + +foundDivBRSI = plFound(rsi_scale) and show_rsi and show_div ? true : false +colordivBRSI = rsi_bullCond ? bullColor : rsi_hiddenBullCond ? hiddenBullColor : noneColor +foundDivBeRSI = phFound(rsi_scale) and show_rsi and show_div ? true : false +colordivBeRSI = rsi_bearCond ? bearColor : rsi_hiddenBearCond ? hiddenBearColor : noneColor + + + +plot( + foundDivBRSI ? rsi_scale[lbR] : na, + offset=-lbR, + title="Regular Bullish", + linewidth=1, + color=colordivBRSI, + transp=0 + ) +plot( + foundDivBeRSI ? rsi_scale[lbR] : na, + offset=-lbR, + title="Regular Bullish", + linewidth=1, + color=colordivBeRSI, + transp=0 + ) + \ No newline at end of file diff --git a/xSamples/oscillators/trix-histogram.pine b/xSamples/oscillators/trix-histogram.pine new file mode 100644 index 0000000..46ec52a --- /dev/null +++ b/xSamples/oscillators/trix-histogram.pine @@ -0,0 +1,140 @@ +//@version=3 + +study(title="TRIX Histogram R2.1 by JustUncleL", shorttitle="TRIXHIS R2") + +// Author: JustUncleL +// Revision: R2 +// +// Description: +// This study is an implementation of the Standard TRIX indicator, shown +// in coloured histogram format by default, with optional Bar colouring of TRIX zero +// and signal crossovers. Other options include showing TRIX as a linegraph instead +// of histogram and optional TRIX signal line with difference histogram. +// Have a look at Internet references below for some examples of how TRIX can be used. +// +// Candle Colouring: +// - Aqua = TRIX zero crossing from below to above zero. +// - Blue = TRIX zero crossing from above to below zero. +// - Gold = TRIX signal line crossing TRIX line from above to below. +// - Fuchsia= TRIX signal line crossing TRIX line from below to above. +// +// References: +// - http://forex-indicators.net/momentum-indicators/trix +// - http://www.dolphintrader.com/3-ma-exponential-moving-average-trix-forex-strategy/ +// - "TRIX MA" by munkeefonix +// +// Revisions: +// R2 - Added Signal line crossover bar colouring and all TRIX crosses highlighted. +// - Changed Signal line crosses to "+", instead of arrow for better visibility. +// - Added Alerts for crossovers. +// - Added Implied GPL Copyright notice. +// +// R1 - Original version. +// +// +// ----------------------------------------------------------------------------- +// Copyright 2014 munkeefonix +// Copyright 2017,2018 JustUncleL +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// The GNU General Public License can be found here +// . +// +// ----------------------------------------------------------------------------- +// + +// --- INPUTS --- +// +length = input(12, minval=1, title="TRIX length") +signallen = input(8, minval=1, title="Signal Length") +showSignal= input(true, title="Show Signal line") +showLine = input(false, title="Show TRIX as Line instead of Histogram") +showZeroX = input(false, title="Show TRIX Zero cross overs") +showTrixX = input(false, title="Show TRIX Signal cross overs") +showBars = input(false, title="Colour Crossover Candles") +// +// --- /INPUTS --- + +// --- CONSTANTS --- +// +BLUE = #0000FFFF +AQUA = #00FFFFFF +GOLD = #FFD700FF +gold = #FFD700 +BLACK = #000000FF +GRAY = #808080FF +DARKGRAY= #696969FF +PURPLE = #800080FF +FUCHSIA = #FF00FFFF +MAROON = #8B0000FF +GREEN = #008000FF +// +scaleup = 2 +// +// --- /CONSTANTS + +// --- FUNCTIONS --- +// +// Triple EMA function +tema(a, b)=>ema(ema(ema(a, b), b), b) + +// TRIX function +trix(a, b)=> + t = tema(a,b) + 10000* ((t-t[1]) / t[1]) + +// --- /FUNCTIONS --- + +// --- SERIES --- +// +TRIX = trix(close,length) +TRIXsig = ema(TRIX,signallen) +TRIXdiff= (TRIX - TRIXsig) * scaleup +// +signalX = crossover(TRIXsig,TRIX) ? -1 : crossunder(TRIXsig,TRIX) ? 1 : 0 +// +trixZX = crossover(TRIX,0)? 1 : crossunder(TRIX,0)? -1: 0 +// +// --- /SERIES --- + +// --- PLOTTING +// +hline(0, title="Zero") +plot(showLine?na:TRIX, title="TRIX Histogram", color = TRIX>=0 ? rising(TRIX,3)?lime:green : falling(TRIX,3)?maroon:red, style=histogram, linewidth=4, transp=10) +plot(showLine?TRIX:na, title="TRIX Line", color = TRIX>=0 ? rising(TRIX,3)?lime:green : falling(TRIX,3)?maroon:red, style=line, linewidth=2, transp=10) +plot(showSignal?TRIXsig:na, title="TRIX Signal", color = orange, style=circles, join=true, linewidth=2, transp=10) +plot(showSignal?TRIXdiff:na, title="TRIX Diff", color = gray, style=area, linewidth=1, transp=70) + +plot(showSignal and showTrixX and signalX!=0?TRIXsig:na, style=cross, title="Signal X Highlight", color=black, transp=20, linewidth=5) +plot(showSignal and showTrixX and signalX==1?TRIXsig:na, style=cross, title="Signal X up", color=gold, transp=0, linewidth=4) +plot(showSignal and showTrixX and signalX==-1?TRIXsig:na, style=cross, title="Signal X down", color=fuchsia, transp=20, linewidth=4) + +plot(showZeroX and trixZX!=0?TRIX:na, style=circles, title="Zero X Highlight", color=black, transp=20, linewidth=5) +plot(showZeroX and trixZX==1?TRIX:na, style=circles, title="Zero X up", color=aqua, transp=10, linewidth=4) +plot(showZeroX and trixZX==-1?TRIX:na, style=circles, title="Zero X down", color=blue, transp=10, linewidth=4) + +bclr = showZeroX? trixZX==1? AQUA: trixZX==-1? BLUE: na : na +bclr := not na(bclr)? bclr : showSignal and showTrixX ? signalX==-1? FUCHSIA : signalX==1? GOLD : na : na +barcolor(showBars?bclr:na,title="TRIX Zero X Bar") + +// --- /PLOTTING --- + +// --- ALERTING --- + +alertcondition(trixZX==1,title="ZERO X Up Alert",message="ZERO X UP") +alertcondition(trixZX==-1,title="ZERO X Down Alert",message="ZERO X DOWN") +alertcondition(signalX==1,title="Signal X Up Alert",message="SIGNAL X UP") +alertcondition(signalX==-1,title="Signal X Down Alert",message="SIGNAL X DOWN") + +// --- /ALERTING --- + +// eof \ No newline at end of file diff --git a/xSamples/oscillators/ultra-rsi.pine b/xSamples/oscillators/ultra-rsi.pine new file mode 100644 index 0000000..69ad3b8 --- /dev/null +++ b/xSamples/oscillators/ultra-rsi.pine @@ -0,0 +1,165 @@ +//@version=3 +study(title="Ultra RSI [DW]", overlay=false) +//by Donovan Wall + +//This is an RSI Variation with six different averaging methods to choose from. + +//The averaging methods I've included in this script are: +//-Exponential Moving Average +//-Simple Moving Average +//-Smoothed Moving Average +//-Weighted Moving Average +//-Volume Weighted Moving Average +//-Arnaud Legoux Moving Average + +//Each method produces a different, yet significant gauge of relative strength. + +//Custom bar colors are included. + +//----------------------------------------------------------------------------------------------------------------------------------------------------------------- + +//Updates: +// - Added two more averages, Coefficient of Variation Weighted Moving Average and Kaufman's Adaptive Moving Average, to the available averaging methods. +// - Added a Laguerre mode to the script, which calculates the RSI using the Laguerre method instead of the conventional method when enabled. + +//----------------------------------------------------------------------------------------------------------------------------------------------------------------- +//Updates: + +//Updated the filter types for RSI calculation +//The available filters for RSI calculation are: +//-> Exponential Moving Average +//-> Double Exponential Moving Average +//-> Simple Moving Average +//-> Smoothed Moving Average +//-> Weighted Moving Average +//-> Volume Weighted Moving Average +//-> Arnaud Legoux Moving Average +//-> Coefficient of Variation Moving Average +//-> Kaufman's Adaptive Moving Average + +//The filter type and RSI type are selectable via easy to use dropdown menus. + +//----------------------------------------------------------------------------------------------------------------------------------------------------------------- +//Inputs +//----------------------------------------------------------------------------------------------------------------------------------------------------------------- + +//Source +src = input(defval=close, title="Source") + +//Periods +per = input(defval=14, minval=1, title="Sampling Period") + +//Filter Type +ftype = input(defval="EMA", options=["EMA", "DEMA", "SMA", "SMMA", "WMA", "VWMA", "ALMA", "COVWMA", "KAMA"], title="Filter Type") + +//RSI Type +rsitype = input(defval="Standard", options=["Standard", "Laguerre"], title="RSI Type") + +//Volume Type +voltype = input(defval="Default", options=["Default", "Tick"], title="Volume Type") + +//ALMA Offset and Sigma +aoff = input(defval=0.85, step=0.01, minval=0, title="Offset (if ALMA)") +sigma = input(defval=6, minval=0, title="Sigma (if ALMA)") + +//KAMA +fast = input(defval=0.666, step=0.001, title="Smoothing Constant Fast End (if KAMA)") +slow = input(defval=0.0645, step=0.0001, title="Smoothing Constant Slow End (if KAMA)") + +//Thresholds +obt = input(defval=70, title="Overbought Threshold") +ost = input(defval=30, title="Oversold Threshold") + +//Laguerre Mode +gamma = input(defval=0.75, minval=0.1, step=0.01, maxval=0.9, title="Gamma (if Laguerre Mode is Active)") + +//----------------------------------------------------------------------------------------------------------------------------------------------------------------- +//Definitions +//----------------------------------------------------------------------------------------------------------------------------------------------------------------- + +//Gains and Losses +srcu = src > src[1] ? src - src[1] : 0 +srcd = src < src[1] ? abs(src - src[1]) : 0 + +//DEMA +dema(x, t)=> + dema = 2*ema(x, t) - ema(ema(x, t), t) + dema + +//VWMA +VWMA(x, t)=> + tick = syminfo.mintick + rng = close - open + tickrng = tick + tickrng := abs(rng) < tick ? nz(tickrng[1]) : rng + tickvol = abs(tickrng)/tick + vol = voltype=="Default" ? (volume==na ? tickvol : volume) : tickvol + vmp = x*vol + VWMA = sum(vmp, t)/sum(vol, t) + VWMA + +//SMMA +smma(x, t)=> + smma = x + smma := na(smma[1]) ? sma(x, t) : (nz(smma[1])*(t - 1) + x)/t + smma + +//COVWMA +covwma(x, t) => + cov = stdev(x, t)/sma(x, t) + cw = x*cov + covwma = sum(cw, t)/sum(cov, t) + covwma + +//KAMA +kama(x, t)=> + dist = abs(x[0] - x[1]) + signal = abs(x - x[t]) + noise = sum(dist, t) + effr = noise != 0 ? signal/noise : 1 + sc = pow(effr*(fast - slow) + slow, 2) + kama = x + kama := nz(kama[1]) + sc*(x - nz(kama[1])) + kama + +//Filters +mau = ftype=="EMA" ? ema(srcu, per) : ftype=="DEMA" ? dema(srcu, per) : ftype=="SMA" ? sma(srcu, per) : ftype=="SMMA" ? smma(srcu, per) : ftype=="WMA" ? wma(srcu, per) : ftype=="VWMA" ? VWMA(srcu, per) : ftype=="ALMA" ? alma(srcu, per, 0.85, 6) : ftype=="COVWMA" ? covwma(srcu, per) : kama(srcu, per) +mad = ftype=="EMA" ? ema(srcd, per) : ftype=="DEMA" ? dema(srcd, per) : ftype=="SMA" ? sma(srcd, per) : ftype=="SMMA" ? smma(srcd, per) : ftype=="WMA" ? wma(srcd, per) : ftype=="VWMA" ? VWMA(srcd, per) : ftype=="ALMA" ? alma(srcd, per, 0.85, 6) : ftype=="COVWMA" ? covwma(srcd, per) : kama(srcd, per) + +//Laguerre RSI +l0 = src +l0 := (1 - gamma)*src + gamma*nz(l0[1]) +l1 = l0 +l1 := -gamma*l0 + nz(l0[1]) + gamma*nz(l1[1]) +l2 = l1 +l2 := -gamma*l1 + nz(l1[1]) + gamma*nz(l2[1]) +l3 = l2 +l3 := -gamma*l2 + nz(l2[1]) + gamma*nz(l3[1]) +cu = (l0 > l1 ? l0 - l1 : 0) + (l1 > l2 ? l1 - l2 : 0) + (l2 > l3 ? l2 - l3 : 0) +cd = (l0 < l1 ? l1 - l0 : 0) + (l1 < l2 ? l2 - l1 : 0) + (l2 < l3 ? l3 - l2 : 0) +lrsi = 100*((cu + cd)==0 ? -1 : (cu + cd)==-1 ? 0 : cu/((cu + cd)==0 ? -1 : cu + cd)) + +//RSI +rs = mau/mad +rsi = rsitype=="Laguerre" ? lrsi : 100 - (100/(1 + rs)) + +//Color +rsicolor = (rsi > 50) and (src > src[1]) ? lime : (rsi > 50) and (src <= src[1]) ? green : (rsi < 50) and (src < src[1]) ? red : (rsi < 50) and (src >= src[1]) ? maroon : orange + +//----------------------------------------------------------------------------------------------------------------------------------------------------------------- +//Plots +//----------------------------------------------------------------------------------------------------------------------------------------------------------------- + +//Thresholds +obplot = plot(obt, color=lime, title="Overbought Threshold") +mplot = plot(50, color=orange, title="Midline") +osplot = plot(ost, color=red, title="Oversold Threshold") + +//RSI +rsiplot = plot(rsi, color=rsicolor, transp=0, title="RSI") + +//Fill +fill(rsiplot, mplot, color=rsicolor, transp=60, title="RSI Fill") + +//Bar Color +barcolor(rsicolor, title="Bar Colors") diff --git a/xSamples/oscillators/volume.fight.pine b/xSamples/oscillators/volume.fight.pine new file mode 100644 index 0000000..19633c5 --- /dev/null +++ b/xSamples/oscillators/volume.fight.pine @@ -0,0 +1,36 @@ +// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ +// © Shuttle_Club +//@version=4 + +study('Volume fight') +ma = input(24, 'Search_range', minval=1,tooltip='The range of estimation of the predominance of bullish or bearish volume (quantity bars). The smaller the TF, the higher the range value should be used to filter out false signals.\n\nДиапазон оценки преобладания бычьего или медвежьего объема (количество баров). Чем меньше ТФ, тем выше следует использовать значение диапазона, чтобы отфильтровать ложные сигналы.') +delta = input(15, 'Smoothing_for_flat,%', step=0.5, minval=0,tooltip='Smoothing to reduce false signals and highlight the flat zone. If you set the percentage to zero, the flat zones will not be highlighted, but there will be much more false signals, since the indicator becomes very sensitive when the smoothing percentage decreases.\n\nСглаживание для уменьшения ложных сигналов и выделения зоны флета. Если выставить процент равным нулю, то зоны флета выделяться не будут, но будет гораздо больше ложных сигналов, так как индикатор становится очень чувствительным при снижении процента сглаживания') +bgshow = input(false, 'Show background zones',tooltip='Show the color background of the current trading zone.\n\nПоказывать цветовой фон текущей торговой зоны.') +all_signal_show = input(false, 'Show each setup in zone',tooltip='Show and use signals every time in trading zone.\n\nПоказывать и использовать каждый сигнал в торговой зоне.') + +///// CALCULATION +bull_vol = openclose ? volume : volume*(open-low)/(high-low) //determine the share of bearish volume +avg_bull_vol = vwma(bull_vol,ma), avg_bear_vol = vwma(bear_vol,ma) //determine vwma +diff_vol = sma((avg_bull_vol/volume-1)-(avg_bear_vol/volume-1),ma) //normalize and smooth the values +vol_flat = abs(avg_bull_vol+avg_bear_vol)/2 //determine average value for calculation flat-filter + +///// SIGNALS +up = int(na), up := nz(up[1]), dn = int(na), dn := nz(dn[1]) //variables +bull = avg_bull_vol>avg_bear_vol and vol_flat/avg_bull_vol<(1-delta/100) //determine up zones +bear = avg_bull_volavg_bear_vol and vol_flat/avg_bull_vol<(1-delta/100) ? color.new(color.green,85) : bgshow and avg_bull_volavg_bear_vol and vol_flat/avg_bull_vol<(1-delta/100) ? color.new(color.green,0) : avg_bull_vol + high - low + +// +// Retrieve Candle Ranges Thirs Section ... +getCandleThird() => + getCandleRange() / 3 + +// +// Determines a Candle is Bullish or not ... +isBullishCandle() => + close > low + (getCandleThird() * 2) + +// +// Determines a Candle is Bearish or not ... +isNeutralCandle() => + close < low + (getCandleThird() * 2) and close > low + getCandleThird() + +// +// Determines a Candle is Neutral or not ... +isBearishCandle() => + close < low + getCandleThird() +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +/////////////////////////////// +// START Range Filter Buy Sell +/////////////////////////////// +// +// Smooth Average Range +smoothAverageRange(x, t, m) => + wper = t * 2 - 1 + avrng = ta.ema(math.abs(x - x[1]), t) + result = ta.ema(avrng, wper) * m + result + +// +// Range Filter ... +rangeFilter(x, r) => + result = x + result := x > nz(result[1]) ? x - r < nz(result[1]) ? nz(result[1]) : x - r : x + r > nz(result[1]) ? nz(result[1]) : x + r + result +/////////////////////////////// +// END Range Filter Buy Sell +/////////////////////////////// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var shortColor = color.red +var longColor = color.lime +var longStopLossColor = color.fuchsia +var shortStopLossColor = color.aqua + +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +var bullishColor = color.lime +var bullishShape = shape.arrowup +var bullishTitle = "Bullish" +var bullishType = 1 + +// +var bearishColor = color.red +var bearishShape = shape.arrowdown +var bearishTitle = "Bearish" +var bearishType = -1 + +// +var neutralColor = color.gray +var neutralShape = shape.circle +var neutralTitle = "Neutral" +var neutralType = 0 + +// +candleType = isBullishCandle() ? bullishType : isNeutralCandle() ? neutralType : isBearishCandle() ? bearishType : neutralType + +// +prevCandleType = not na(candleType[1]) ? candleType[1] : neutralType + +// +candleNeighborhoodBaseType = prevCandleType + candleType +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +/////////////////////////////// +// START Range Filter Buy Sell +/////////////////////////////// +// +// Source +RFBSSrc = close + +// +// Sampling Period +RFBSPer = 41 + +// +// Range Multiplier ... +RFBSMult = 3.0 + +// +// Color variables ... +RFBSUpColor = color.green +RFBSMidColor = color.blue +RFBSDownColor = color.red + +// +RFBSSmrng = smoothAverageRange(RFBSSrc, RFBSPer, RFBSMult) +RFBSFilt = rangeFilter(RFBSSrc, RFBSSmrng) + +// +// Filter UP Direction ... +RFBSUpward = 0.0 +RFBSUpward := RFBSFilt > RFBSFilt[1] ? nz(RFBSUpward[1]) + 1 : RFBSFilt < RFBSFilt[1] ? 0 : nz(RFBSUpward[1]) + +// +// Filter DOWN Direction ... +RFBSDownward = 0.0 +RFBSDownward := RFBSFilt < RFBSFilt[1] ? nz(RFBSDownward[1]) + 1 : RFBSFilt > RFBSFilt[1] ? 0 : nz(RFBSDownward[1]) + +// +// Target Bands +RFBSHband = RFBSFilt + RFBSSmrng +RFBSLband = RFBSFilt - RFBSSmrng + +// +// Colors +RFBSFiltcolor = RFBSUpward > 0 ? RFBSUpColor : RFBSDownward > 0 ? RFBSDownColor : RFBSMidColor +RFBSBarcolor = RFBSSrc > RFBSFilt and RFBSSrc > RFBSSrc[1] and RFBSUpward > 0 ? RFBSUpColor : RFBSSrc > RFBSFilt and RFBSSrc < RFBSSrc[1] and RFBSUpward > 0 ? RFBSUpColor : RFBSSrc < RFBSFilt and RFBSSrc < RFBSSrc[1] and RFBSDownward > 0 ? RFBSDownColor : RFBSSrc < RFBSFilt and RFBSSrc > RFBSSrc[1] and RFBSDownward > 0 ? RFBSDownColor : RFBSMidColor + +// +// Break Outs +RFBSLongCond = bool(na) +RFBSShortCond = bool(na) +RFBSLongCond := RFBSSrc > RFBSFilt and RFBSSrc > RFBSSrc[1] and RFBSUpward > 0 or RFBSSrc > RFBSFilt and RFBSSrc < RFBSSrc[1] and RFBSUpward > 0 +RFBSShortCond := RFBSSrc < RFBSFilt and RFBSSrc < RFBSSrc[1] and RFBSDownward > 0 or RFBSSrc < RFBSFilt and RFBSSrc > RFBSSrc[1] and RFBSDownward > 0 + +// +RFBSCondIni = 0 +RFBSCondIni := RFBSLongCond ? 1 : RFBSShortCond ? -1 : RFBSCondIni[1] +RFBSLongCondition = RFBSLongCond and RFBSCondIni[1] == -1 +RFBSShortCondition = RFBSShortCond and RFBSCondIni[1] == 1 +/////////////////////////////// +// END Range Filter Buy Sell +/////////////////////////////// + +/////////////////////////////// +// START Stochastic Histogram +/////////////////////////////// +// +STHSLength = 14 +STHSSmoothK = 3 + +// +STHSK = (ta.sma(ta.stoch(close, high, low, STHSLength), STHSSmoothK) - 50) +/////////////////////////////// +// END Stochastic Histogram +/////////////////////////////// + +/////////////////////// +// START Strategy ... +/////////////////////// +// +canShowStopLoss = showSignals and showStopLosses and (showLongSignals or showShortSignals) and (showLongStopLosses or showShortStopLosses) +canShowLongStopLoss = canShowStopLoss and showLongStopLosses and not na(RFBSLongCondition) +canShowShortStopLoss = canShowStopLoss and showShortStopLosses and not na(RFBSShortCondition) + +// +hasSignal = RFBSLongCondition or RFBSShortCondition + +// +// Stochastic Verification ... +isStochasticLongVerified = STHSK > 0 +isStochasticShortVerified = STHSK < 0 + +// +// and open > RFBSFilt ... +// and close > RFBSFilt ... +hasLongSignal = hasSignal and not na(RFBSLongCondition) and open > RFBSFilt and isBullishCandle() and isStochasticLongVerified +longSignal = hasLongSignal ? RFBSLongCondition : na +longStopLoss = RFBSLband + +// +hasShortSignal = hasSignal and not na(RFBSShortCondition) and isBearishCandle() and isStochasticShortVerified +shortSignal = hasShortSignal ? RFBSShortCondition : na +shortStopLoss = RFBSHband + +// +canShowSignal = showSignals and (showLongSignals or showShortSignals) +canShowLongSignal = canShowSignal and showLongSignals and hasLongSignal +canShowShortSignal = canShowSignal and showShortSignals and hasShortSignal +/////////////////////// +// END Strategy ... +/////////////////////// +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Signals ... +plotshape(canShowLongSignal ? longSignal : na, title = "Long Signal", color = longColor, location = location.belowbar, style = shape.triangleup, size = size.normal) +plotshape(canShowShortSignal ? shortSignal : na, title = "Short Signal", color = shortColor, location = location.abovebar, style = shape.triangledown, size = size.normal) + +// +plot(series = showRangeFilter ? RFBSFilt : na, color = RFBSFiltcolor, linewidth = 2, title = "RFBS > Range Filter", style = plot.style_line) + +// +// Stop Losses ... +plot(series = canShowLongStopLoss ? longStopLoss : na, color = longStopLossColor, linewidth = 1, style = plot.style_line, title = "Long Stop Loss") +plot(series = canShowShortStopLoss ? shortStopLoss : na, color = shortStopLossColor, linewidth = 1, style = plot.style_line, title = "Short Stop Loss") +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(hasSignal, "XST_RF15M > Signal") +alertcondition(hasLongSignal, "XST_RF15M > Long Signal") +alertcondition(hasShortSignal, "XST_RF15M > Short Signal") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xStrategies/XST_SCCH15M/Docs/report.ADAUSDT.P.Binance.15min.md b/xStrategies/XST_SCCH15M/Docs/report.ADAUSDT.P.Binance.15min.md new file mode 100644 index 0000000..8584794 --- /dev/null +++ b/xStrategies/XST_SCCH15M/Docs/report.ADAUSDT.P.Binance.15min.md @@ -0,0 +1,118 @@ +# XST_CC_OSC + +## Report + +### Makret + +ADAUSDT.P + +### Exchange + +Binance + +### Time Frame + +15min + +### Start Date + +Longs: + +19 may 2023 | 12:00 UTC + +Shorts: + +18 may 2023 | 00:00 UTC + +### End Date + +Longs: + +23 may 2023 | 01:15 UTC + +Shorts: + +23 may 2023 | 12:45 UTC + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | | x | | +| 4 | Long | | x | | +| 5 | Long | | x | | +| 6 | Long | x | | | +| 7 | Long | x | | | +| 8 | Long | x | | | +| 9 | Long | x | | | +| 10 | Long | x | | | +| 11 | Long | | x | | +| 12 | Long | x | | | +| 13 | Long | x | | | +| 14 | Long | x | | | +| 15 | Long | | x | | +| 16 | Long | | x | | +| 17 | Long | x | | | +| 18 | Long | x | | | +| 19 | Long | x | | | +| 20 | Long | x | | | +| 21 | Long | x | | | +| 22 | Long | x | | | +| 23 | Long | x | | | +| 24 | Long | x | | | +| 25 | Long | x | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | x | | | +| 3 | Short | x | | | +| 4 | Short | x | | | +| 5 | Short | x | | | +| 6 | Short | x | | | +| 7 | Short | x | | | +| 8 | Short | | x | | +| 9 | Short | x | | | +| 10 | Short | x | | | +| 11 | Short | | x | | +| 12 | Short | x | | | +| 13 | Short | x | | | +| 14 | Short | x | | | +| 15 | Short | | x | | +| 16 | Short | x | | | +| 17 | Short | x | | | +| 18 | Short | x | | | +| 19 | Short | | x | | +| 20 | Short | x | | | +| 21 | Short | | x | | +| 22 | Short | x | | | +| 23 | Short | | x | Open | +| 24 | Short | x | | | +| 25 | Short | x | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 25 | 19 | 06 | +| Shorts | 25 | 19 | 06 | +| Total | 50 | 38 | 12 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 500$ +total lose: 120$ +total reward: 570$ +total cash: 380$ + 570$ = 950$ +win rate: 90% diff --git a/xStrategies/XST_SCCH15M/Docs/report.BNBUSDT.P.Binance.15min.md b/xStrategies/XST_SCCH15M/Docs/report.BNBUSDT.P.Binance.15min.md new file mode 100644 index 0000000..6b343a7 --- /dev/null +++ b/xStrategies/XST_SCCH15M/Docs/report.BNBUSDT.P.Binance.15min.md @@ -0,0 +1,118 @@ +# XST_CC_OSC + +## Report + +### Makret + +BNBUSDT.P + +### Exchange + +Binance + +### Time Frame + +15min + +### Start Date + +Longs: + +17 may 2023 | 22:45 UTC + +Shorts: + +17 may 2023 | 10:00 UTC + +### End Date + +Longs: + +23 may 2023 | 01:15 UTC + +Shorts: + +23 may 2023 | 11:00 UTC + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | x | | | +| 4 | Long | x | | | +| 5 | Long | x | | | +| 6 | Long | x | | | +| 7 | Long | x | | | +| 8 | Long | | x | | +| 9 | Long | x | | | +| 10 | Long | x | | | +| 11 | Long | | x | | +| 12 | Long | | x | | +| 13 | Long | x | | | +| 14 | Long | x | | | +| 15 | Long | x | | | +| 16 | Long | x | | | +| 17 | Long | x | | | +| 18 | Long | | x | | +| 19 | Long | | x | | +| 20 | Long | x | | | +| 21 | Long | x | | | +| 22 | Long | x | | | +| 23 | Long | x | | | +| 24 | Long | x | | | +| 25 | Long | x | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | x | | | +| 3 | Short | | x | | +| 4 | Short | x | | | +| 5 | Short | x | | | +| 6 | Short | x | | | +| 7 | Short | | x | | +| 8 | Short | x | | | +| 9 | Short | x | | | +| 10 | Short | | x | | +| 11 | Short | | x | | +| 12 | Short | | x | | +| 13 | Short | x | | | +| 14 | Short | | x | | +| 15 | Short | x | | | +| 16 | Short | x | | | +| 17 | Short | x | | | +| 18 | Short | x | | | +| 19 | Short | x | | | +| 20 | Short | x | | | +| 21 | Short | x | | | +| 22 | Short | x | | | +| 23 | Short | x | | | +| 24 | Short | | x | | +| 25 | Short | x | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 25 | 20 | 05 | +| Shorts | 25 | 18 | 07 | +| Total | 50 | 38 | 12 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 500$ +total lose: 120$ +total reward: 570$ +total cash: 380$ + 570$ = 950$ +win rate: 90% diff --git a/xStrategies/XST_SCCH15M/Docs/report.DOGEUSDT.P.Binance.15min.md b/xStrategies/XST_SCCH15M/Docs/report.DOGEUSDT.P.Binance.15min.md new file mode 100644 index 0000000..b25842a --- /dev/null +++ b/xStrategies/XST_SCCH15M/Docs/report.DOGEUSDT.P.Binance.15min.md @@ -0,0 +1,106 @@ +# XST_CC_OSC + +## Report + +### Makret + +DOGEUSDT.P + +### Exchange + +Binance + +### Time Frame + +15min + +### Start Date + +19 may 2023 | 12:00 UTC + +### End Date + +23 may 2023 | 01:15 UTC + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | | x | | +| 4 | Long | x | | | +| 5 | Long | | x | | +| 6 | Long | x | | | +| 7 | Long | | x | | +| 8 | Long | x | | | +| 9 | Long | | x | | +| 10 | Long | x | | | +| 11 | Long | x | | | +| 12 | Long | x | | | +| 13 | Long | x | | | +| 14 | Long | | x | | +| 15 | Long | | x | | +| 16 | Long | x | | | +| 17 | Long | x | | | +| 18 | Long | x | | | +| 19 | Long | x | | | +| 20 | Long | x | | | +| 21 | Long | x | | | +| 22 | Long | x | | | +| 23 | Long | x | | | +| 24 | Long | | x | | +| 25 | Long | x | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | | | +| 2 | Short | | | | +| 3 | Short | | | | +| 4 | Short | | | | +| 5 | Short | | | | +| 6 | Short | | | | +| 7 | Short | | | | +| 8 | Short | | | | +| 9 | Short | | | | +| 10 | Short | | | | +| 11 | Short | | | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | +| 21 | Short | | | | +| 22 | Short | | | | +| 23 | Short | | | | +| 24 | Short | | | | +| 25 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 25 | 18 | 07 | +| Shorts | 00 | 00 | 00 | +| Total | 00 | 00 | 00 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 250$ +total lose: 70$ +total reward: 270$ +total cash: 180$ + 270$ = 450$ +win rate: 80% diff --git a/xStrategies/XST_SCCH15M/Docs/report.ETCUSDT.P.Binance.15m.md b/xStrategies/XST_SCCH15M/Docs/report.ETCUSDT.P.Binance.15m.md new file mode 100644 index 0000000..89caefc --- /dev/null +++ b/xStrategies/XST_SCCH15M/Docs/report.ETCUSDT.P.Binance.15m.md @@ -0,0 +1,131 @@ +# XST_CC_OSC + +## Report + +### Makret + +ETCUSDT.P + +### Exchange + +BINANCE + +### Time Frame + +15min + +### Start Date + +13 may 2023 | 08:45 UTC + +### End Date + +23 may 2023 | 06:00 UTC + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | x | | | +| 4 | Long | x | | | +| 5 | Long | x | | | +| 6 | Long | x | | | +| 7 | Long | x | | | +| 8 | Long | x | | | +| 9 | Long | x | | | +| 10 | Long | | x | | +| 11 | Long | | x | | +| 12 | Long | x | | | +| 13 | Long | x | | | +| 14 | Long | x | | | +| 15 | Long | x | | | +| 16 | Long | | x | | +| 17 | Long | x | | | +| 18 | Long | x | | | +| 19 | Long | x | | | +| 20 | Long | | x | | +| 21 | Long | | x | | +| 22 | Long | x | | | +| 23 | Long | | x | | +| 24 | Long | x | | | +| 25 | Long | x | | | +| 26 | Long | x | | | +| 27 | Long | x | | | +| 28 | Long | x | | | +| 29 | Long | x | | | +| 30 | Long | x | | | +| 31 | Long | x | | | +| 32 | Long | | x | | +| 33 | Long | x | | | +| 34 | Long | x | | | +| 35 | Long | | x | | +| 36 | Long | x | | | +| 37 | Long | x | | | +| 38 | Long | x | | | +| 39 | Long | | x | | +| 40 | Long | | x | | +| 41 | Long | | x | | +| 42 | Long | | x | | +| 43 | Long | x | | | +| 44 | Long | x | | | +| 45 | Long | x | | | +| 46 | Long | | x | | +| 47 | Long | x | | | +| 48 | Long | x | | | +| 49 | Long | x | | | +| 50 | Long | x | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | | | +| 2 | Short | | | | +| 3 | Short | | | | +| 4 | Short | | | | +| 5 | Short | | | | +| 6 | Short | | | | +| 7 | Short | | | | +| 8 | Short | | | | +| 9 | Short | | | | +| 10 | Short | | | | +| 11 | Short | | | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | +| 21 | Short | | | | +| 22 | Short | | | | +| 23 | Short | | | | +| 24 | Short | | | | +| 25 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 50 | 37 | 13 | +| Shorts | 00 | 00 | 00 | +| Total | 50 | 37 | 13 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 500$ +total lose: 130$ +total reward: 555$ +total cash: 555$ + 370$ = 925$ +win rate: 85% diff --git a/xStrategies/XST_SCCH15M/Docs/report.ETHUSDT.Kucoin.15min.md b/xStrategies/XST_SCCH15M/Docs/report.ETHUSDT.Kucoin.15min.md new file mode 100644 index 0000000..8591b2c --- /dev/null +++ b/xStrategies/XST_SCCH15M/Docs/report.ETHUSDT.Kucoin.15min.md @@ -0,0 +1,106 @@ +# XST_CC_OSC + +## Report + +### Makret + +ETHUSDT + +### Exchange + +Kucoin + +### Time Frame + +15min + +### Start Date + +18 may 2023 | 01:00 UTC + +### End Date + +23 may 2023 | 01:15 UTC + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | x | | | +| 4 | Long | x | | | +| 5 | Long | x | | | +| 6 | Long | x | | | +| 7 | Long | x | | | +| 8 | Long | x | | | +| 9 | Long | x | | | +| 10 | Long | x | | | +| 11 | Long | x | | | +| 12 | Long | x | | | +| 13 | Long | x | | | +| 14 | Long | x | | | +| 15 | Long | | x | | +| 16 | Long | | x | | +| 17 | Long | x | | | +| 18 | Long | | x | | +| 19 | Long | | x | | +| 20 | Long | | x | | +| 21 | Long | x | | | +| 22 | Long | x | | | +| 23 | Long | x | | | +| 24 | Long | x | | | +| 25 | Long | x | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | | | +| 2 | Short | | | | +| 3 | Short | | | | +| 4 | Short | | | | +| 5 | Short | | | | +| 6 | Short | | | | +| 7 | Short | | | | +| 8 | Short | | | | +| 9 | Short | | | | +| 10 | Short | | | | +| 11 | Short | | | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | +| 21 | Short | | | | +| 22 | Short | | | | +| 23 | Short | | | | +| 24 | Short | | | | +| 25 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 25 | 20 | 05 | +| Shorts | 00 | 00 | 00 | +| Total | 00 | 00 | 00 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 250$ +total lose: 60$ +total reward: 285$ +total cash: 190$ + 285$ = 475$ +win rate: 90% diff --git a/xStrategies/XST_SCCH15M/Docs/report.LTCUSDT.KUCOIN.15min.md b/xStrategies/XST_SCCH15M/Docs/report.LTCUSDT.KUCOIN.15min.md new file mode 100644 index 0000000..9447870 --- /dev/null +++ b/xStrategies/XST_SCCH15M/Docs/report.LTCUSDT.KUCOIN.15min.md @@ -0,0 +1,107 @@ +# XST_??? + +## Report + +### Makret + +LTCUSDT + +### Exchange + +KUCOIN + +### Time Frame + +15min + +### Start Date + +24 may 2023 | 17:30 UTC + +### End Date + +29 may 2023 | 20:00 UTC + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | x | | | +| 4 | Long | x | | | +| 5 | Long | x | | | +| 6 | Long | x | | | +| 7 | Long | | x | | +| 8 | Long | x | | | +| 9 | Long | x | | | +| 10 | Long | | x | | +| 11 | Long | x | | | +| 12 | Long | x | | | +| 13 | Long | x | | | +| 14 | Long | x | | | +| 15 | Long | x | | | +| 16 | Long | x | | | +| 17 | Long | x | | | +| 18 | Long | x | | | +| 19 | Long | x | | | +| 20 | Long | x | | | +| 21 | Long | x | | | +| 22 | Long | x | | | +| 23 | Long | x | | | +| 24 | Long | | x | | +| 25 | Long | x | | | +| 26 | Long | x | | | +| 27 | Long | x | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | x | | | +| 3 | Short | x | | | +| 4 | Short | | x | | +| 5 | Short | x | | | +| 6 | Short | x | | | +| 7 | Short | x | | | +| 8 | Short | x | | | +| 9 | Short | x | | | +| 10 | Short | x | | | +| 11 | Short | x | | | +| 12 | Short | | x | | +| 13 | Short | x | | | +| 14 | Short | x | | | +| 15 | Short | x | | | +| 16 | Short | | x | | +| 17 | Short | x | | | +| 18 | Short | x | | | +| 19 | Short | x | | | +| 20 | Short | x | | | +| 21 | Short | x | | | +| 22 | Short | x | | | +| 23 | Short | x | | | +| 24 | Short | | x | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 27 | 24 | 03 | +| Shorts | 24 | 20 | 04 | +| Total | 51 | 44 | 07 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 510$ +total lose: 70$ +total reward: 660$ +total cash: 440$ + 660$ = 1100$ +win rate: 129.4% diff --git a/xStrategies/XST_SCCH15M/Docs/report.XRPUSDT.P.Binance.15min.md b/xStrategies/XST_SCCH15M/Docs/report.XRPUSDT.P.Binance.15min.md new file mode 100644 index 0000000..bb322a4 --- /dev/null +++ b/xStrategies/XST_SCCH15M/Docs/report.XRPUSDT.P.Binance.15min.md @@ -0,0 +1,106 @@ +# XST_CC_OSC + +## Report + +### Makret + +XRPUSDT.P + +### Exchange + +Binance + +### Time Frame + +15min + +### Start Date + +19 may 2023 | 00:30 UTC + +### End Date + +23 may 2023 | 02:00 UTC + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | x | | | +| 4 | Long | | x | | +| 5 | Long | x | | | +| 6 | Long | | x | | +| 7 | Long | x | | | +| 8 | Long | x | | | +| 9 | Long | x | | | +| 10 | Long | x | | | +| 11 | Long | x | | | +| 12 | Long | x | | | +| 13 | Long | x | | | +| 14 | Long | x | | | +| 15 | Long | | x | | +| 16 | Long | x | | | +| 17 | Long | x | | | +| 18 | Long | x | | | +| 19 | Long | | x | | +| 20 | Long | x | | | +| 21 | Long | x | | | +| 22 | Long | x | | | +| 23 | Long | x | | | +| 24 | Long | x | | | +| 25 | Long | x | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | | | +| 2 | Short | | | | +| 3 | Short | | | | +| 4 | Short | | | | +| 5 | Short | | | | +| 6 | Short | | | | +| 7 | Short | | | | +| 8 | Short | | | | +| 9 | Short | | | | +| 10 | Short | | | | +| 11 | Short | | | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | +| 21 | Short | | | | +| 22 | Short | | | | +| 23 | Short | | | | +| 24 | Short | | | | +| 25 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 25 | 21 | 04 | +| Shorts | 00 | 00 | 00 | +| Total | 00 | 00 | 00 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 250$ +total lose: 40$ +total reward: 315$ +total cash: 210$ + 315$ = 525$ +win rate: 137.5% diff --git a/xStrategies/XST_SCCH15M/xst_scch15m.pine b/xStrategies/XST_SCCH15M/xst_scch15m.pine new file mode 100644 index 0000000..39b72fc --- /dev/null +++ b/xStrategies/XST_SCCH15M/xst_scch15m.pine @@ -0,0 +1,299 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center XTrade SCCH15M Strategy +// --------------------------------------------- +// SaherElm Custom Private Strategy ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm XTrade SCCH15M Strategy", shorttitle = "XST_SCCH15M", overlay = true) + +// +// START Inputs .... +// +// +// Determines Show Signals or not ... +showSignals = input.bool(defval = true, title = "Show Signals", group = "Strategy") +showStopLosses = input.bool(defval = true, title = "Show Stop Losses", group = "Strategy") +showTakeProfits = input.bool(defval = true, title = "Show Take Profits", group = "Strategy") + +// +// Show Signals based on their types ... +showLongSignals = input.bool(defval = true, title = "Show Long Signals", group = "Signals") +showShortSignals = input.bool(defval = true, title = "Show Short Signals", group = "Signals") + +// +// Show Stop Losses based on their types ... +swingLoopback = input.int(defval = 7, title = "Swing Loopback Period", group = "Stop Loss") +showLongStopLosses = input.bool(defval = true, title = "Show Long Stop Losses", group = "Stop Loss") +showShortStopLosses = input.bool(defval = true, title = "Show Short Stop Losses", group = "Stop Loss") + +// +// Take Profits ... +riskRewardRatio = input.float(defval = 1.5, title = "Risk To Reward Ratio", group = "Take Profit") + +// +longTakeProfitColor = input.color(defval = color.yellow, title = "Long TPs Color", group = "Take Profit") +shortTakeProfitColor = input.color(defval = color.lime, title = "Short TPs Color", group = "Take Profit") + +// +showLongTakeProfits = input.bool(defval = true, title = "Show Long Take Profits", group = "Take Profit") +showShortTakeProfits = input.bool(defval = true, title = "Show Short Take Profits", group = "Take Profit") +// +// END Inputs .... +// + +// +// START Functions .... +// +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +// Retrieve Specific Candle Height (based on low and high) ... +getCandleRange() => + high - low + +// +// Retrieve Candle Ranges Thirs Section ... +getCandleThird() => + getCandleRange() / 3 + +// +// Determines a Candle is Bullish or not ... +isBullishCandle() => + close > low + (getCandleThird() * 2) + +// +// Determines a Candle is Bearish or not ... +isNeutralCandle() => + close < low + (getCandleThird() * 2) and close > low + getCandleThird() + +// +// Determines a Candle is Neutral or not ... +isBearishCandle() => + close < low + getCandleThird() +///////////////////////////// +// END Price Action Candles +///////////////////////////// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var longColor = color.aqua +var shortColor = color.fuchsia +var longStopLossColor = color.fuchsia +var shortStopLossColor = color.aqua + +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +var bullishColor = color.lime +var bullishShape = shape.arrowup +var bullishTitle = "Bullish" +var bullishType = 1 + +// +var bearishColor = color.red +var bearishShape = shape.arrowdown +var bearishTitle = "Bearish" +var bearishType = -1 + +// +var neutralColor = color.gray +var neutralShape = shape.circle +var neutralTitle = "Neutral" +var neutralType = 0 + +// +candleType = isBullishCandle() ? bullishType : isNeutralCandle() ? neutralType : isBearishCandle() ? bearishType : neutralType + +// +prevCandleType = not na(candleType[1]) ? candleType[1] : neutralType + +// +candleNeighborhoodBaseType = prevCandleType + candleType +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +//////////////////////////// +// START Last Market Price +//////////////////////////// +// +lastMarketLowest = ta.lowest(low, swingLoopback) +lastMarketLowest2 = ta.lowest(low, swingLoopback * 2) +lastMarketLowest3 = ta.lowest(low, swingLoopback * 3) + +// +lastMarketHighest = ta.highest(high, swingLoopback) +lastMarketHighest2 = ta.highest(high, swingLoopback * 2) +lastMarketHighest3 = ta.highest(high, swingLoopback * 3) +//////////////////////////// +// END Last Market Price +//////////////////////////// + +/////////////////////// +// START Cycle Channel +/////////////////////// +// +CCHSclT = 10 +CCHMclT = 30 +CCHScm = 1.0 +CCHMcm = 3.0 +CCHSrc = close +CCHEbc = false + +// +CCHScl = CCHSclT / 2 +CCHMcl = CCHMclT / 2 + +// +CCHMaScl = ta.rma(CCHSrc, CCHScl) +CCHMaMcl = ta.rma(CCHSrc, CCHMcl) + +// +CCHScmOff = CCHScm * ta.atr(CCHScl) +CCHMcmOff = CCHMcm * ta.atr(CCHMcl) + +// +CCHScl2 = CCHScl / 2 +CCHMcl2 = CCHMcl / 2 + +// +CCHSct = nz(CCHMaScl[CCHScl2], CCHSrc) + CCHScmOff +CCHScb = nz(CCHMaScl[CCHScl2], CCHSrc) - CCHScmOff + +// +CCHMct = nz(CCHMaMcl[CCHMcl2], CCHSrc) + CCHMcmOff +CCHMcb = nz(CCHMaMcl[CCHMcl2], CCHSrc) - CCHMcmOff + +// +CCHScmm = math.avg(CCHSct, CCHScb) + +// +CCHOmed = (CCHScmm - CCHMcb) / (CCHMct - CCHMcb) +CCHOshort = (CCHSrc - CCHMcb) / (CCHMct - CCHMcb) + +// +CCHBc = (CCHOshort > 0.5) ? (CCHOshort > 1.0 ? color.purple : (CCHOshort > CCHOmed ? color.lime : color.green)) : (CCHOshort < 0 ? color.purple : ( CCHOshort < CCHOmed ? color.red : color.orange)) + +// +// RED ... +CCHFastOSC = CCHOshort + +// +// Green ... +CCHSlowOSC = CCHOmed + +// +CCHMidOSC = CCHFastOSC >= CCHSlowOSC ? (CCHFastOSC - CCHSlowOSC) / 2 : (CCHSlowOSC - CCHFastOSC) / 2 + +// +isCCHFastOSCCrossOverCCHSlowOSC = ta.crossover(CCHFastOSC, CCHSlowOSC) +isCCHFastOSCCrossUnderCCHSlowOSC = ta.crossunder(CCHFastOSC, CCHSlowOSC) + +// +hasCCHBullishSignal = isCCHFastOSCCrossOverCCHSlowOSC and CCHMidOSC >= 0.02 +hasCCHBearishSignal = isCCHFastOSCCrossUnderCCHSlowOSC and CCHMidOSC >= 0.02 + +// +hasCCHSignal = hasCCHBullishSignal or hasCCHBearishSignal +/////////////////////// +// END Cycle Channel +/////////////////////// + +/////////////////////// +// START Strategy ... +/////////////////////// +// +canShowStopLoss = showSignals and showStopLosses and (showLongSignals or showShortSignals) and (showLongStopLosses or showShortStopLosses) +canShowLongStopLoss = canShowStopLoss and showLongStopLosses +canShowShortStopLoss = canShowStopLoss and showShortStopLosses + +// +canShowTakeProfit = showSignals and showTakeProfits and (showLongSignals or showShortSignals) and (showLongTakeProfits or showShortTakeProfits) +canShowLongTakeProfit = canShowTakeProfit and showLongTakeProfits +canShowShortTakeProfit = canShowTakeProfit and showShortTakeProfits + +// +hasSignal = hasCCHSignal + +// +stopLossThreshold = 0.0 + +// +hasLongSignal = hasSignal and hasCCHBullishSignal +longSignal = hasLongSignal ? bar_index : na +longStopLoss = lastMarketLowest +longTakeProfit = open + (open - longStopLoss - stopLossThreshold) * riskRewardRatio + +// +hasShortSignal = hasSignal and hasCCHBearishSignal +shortSignal = hasShortSignal ? bar_index : na +shortStopLoss = lastMarketHighest +shortTakeProfit = open + (open - shortStopLoss - stopLossThreshold) * riskRewardRatio + +// +canShowSignal = showSignals and (showLongSignals or showShortSignals) +canShowLongSignal = canShowSignal and showLongSignals and hasLongSignal +canShowShortSignal = canShowSignal and showShortSignals and hasShortSignal +/////////////////////// +// END Strategy ... +/////////////////////// +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Signals ... +plotshape(canShowLongSignal ? longSignal : na, title = "Long Signal", color = longColor, location = location.belowbar, style = shape.triangleup, size = size.small) +plotshape(canShowShortSignal ? shortSignal : na, title = "Short Signal", color = shortColor, location = location.abovebar, style = shape.triangledown, size = size.small) + +// +// Stop Losses ... +plot(series = canShowLongStopLoss ? longStopLoss : na, color = longStopLossColor, linewidth = 1, style = plot.style_line, title = "Long Stop Loss") +plot(series = canShowShortStopLoss ? shortStopLoss : na, color = shortStopLossColor, linewidth = 1, style = plot.style_line, title = "Short Stop Loss") + +// +// Long Take Profits ... +if hasLongSignal and canShowLongSignal and canShowLongTakeProfit + lTp = line.new(x1 = bar_index, y1 = longTakeProfit, x2 = bar_index + swingLoopback, y2 = longTakeProfit, color = longTakeProfitColor, width = 2, style = line.style_arrow_right) + +// +// Short Take Profits ... +if hasShortSignal and canShowShortSignal and canShowShortTakeProfit + sTp = line.new(x1 = bar_index, y1 = shortTakeProfit, x2 = bar_index + swingLoopback, y2 = shortTakeProfit, color = shortTakeProfitColor, width = 2, style = line.style_arrow_right) +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(hasSignal, "XST_SCCH15M > Signal") +alertcondition(hasLongSignal, "XST_SCCH15M > Long Signal") +alertcondition(hasShortSignal, "XST_SCCH15M > Short Signal") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xStrategies/XST_SR15M/Docs/XST_SR15M.md b/xStrategies/XST_SR15M/Docs/XST_SR15M.md new file mode 100644 index 0000000..e2703c7 --- /dev/null +++ b/xStrategies/XST_SR15M/Docs/XST_SR15M.md @@ -0,0 +1,64 @@ +# Support and Resistance Scalping (XTS_SR15M) + +## Setup + +- **TF**: 15m +- **Asset**: AAPL +- **R2R**: 1:1.5 +- **Indicators**: + - Leledc Levels (IS) InSillico: + - Change Exhaustion bar count to 42; + - Change Line Tickness to 7; + - Hide Support Level line; + - Hide Resistance Level linel; + - ATR Stop Loss garethyeo: + - Change Source to low; +- **Oscillators**: + - Kurutoga Histogram (D7R): + - Hide Kurutuga Lead 4x; + +## Descriptions + +since Kurutoga Histogram doesn't provides it's source code, i try to implement +Cycle Channel Oscillator, instead of it. + +after i try to do back testing usage of CCH and KUH, i found this rules: + +- kurutuga histogram green color, means both red and green line in Cycle Channel must be above than 0.5 (Middle) line and green line above than red line. +- kurutuga histogram red color, means both red and green line in Cycle Channel must be below than 0.5 (Middle) line and red line below than green line. + +so we have to implement cycle channel oscillator and it's verifications on signals ... + +## Using the Strategy + +### Long/Buy Conditions + +- Leledc Level gives **Support Signal** (green to up side triangle); +- kurutuga histogram is **red** color; +- market forms a **bullish** candle; + +#### Long SL + +place sl at low of ATR Stop Loss Purple(red) Line. + +#### Long TP + +calculate based on R2R; + +### Short/Sell Conditions + +- Leledc Level gives **Resistance Signal** (red to down side triangle); +- kurutuga histogram is **green** color; +- market forms a **bearish** candle; + +#### Short SL + +place sl at high of ATR Stop Loss Green Line. + +#### Short TP + +calculate based on R2R; + +### Signals Overlap + +how to handle signals overlaps. diff --git a/xStrategies/XST_SR15M/Docs/report.md b/xStrategies/XST_SR15M/Docs/report.md new file mode 100644 index 0000000..984f5fa --- /dev/null +++ b/xStrategies/XST_SR15M/Docs/report.md @@ -0,0 +1,67 @@ +# XST_SR15M + +## Report 1 + +### Makret + +ETHUSDT + +### Exchange + +Kucoin + +### Time Frame + +15min + +### Start Date + +24 april 2023 | 01:15 + +### End Date + +18 may 2023 | 14:45 + +### Risk to Reward + +1:1.5 + +### Reports + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | | x | | +| 3 | Short | x | | | +| 4 | Short | | x | | +| 5 | Short | | x | | +| 6 | Short | x | | | +| 7 | Short | | x | | +| 8 | Short | x | | | +| 9 | Short | | x | | +| 10 | Long | x | | | +| 11 | Long | x | | | +| 12 | Long | | x | | +| 13 | Long | | x | | +| 14 | Long | x | | | +| 15 | Long | x | | | +| 16 | Long | | x | | +| 17 | Long | x | | | +| 18 | Long | | x | | +| 19 | Long | x | | | +| 20 | Long | x | | | +| 21 | Long | | x | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :-: | :-: | :-: | :-: | +| Shorts | 9 | 4 | 5 | +| Longs | 12 | 7 | 5 | +| Total | 21 | 11 | 10 | + +#### Analysis + +per trade volume: 10$ +total spending: 210$ +total comeback: 165$ diff --git a/xStrategies/XST_SR15M/xst_sr15m.pine b/xStrategies/XST_SR15M/xst_sr15m.pine new file mode 100644 index 0000000..7c5d425 --- /dev/null +++ b/xStrategies/XST_SR15M/xst_sr15m.pine @@ -0,0 +1,353 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center XTrade SR15M Strategy +// --------------------------------------------- +// in this strategy i must use: +// - Price Action Candle Recognition; +// - Leledc Levels (IS) InSillico; +// - ATR Stop Loss garethyeo; +// - Cycle Channel Oscillator; +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm XTrade SR15M Strategy", shorttitle = "XST_SR15M", overlay = true) + +// +// START Inputs .... +// +// +// Determines Show Signals or not ... +showSignals = input.bool(defval = true, title = "Show Signals", group = "Strategy") +showStopLosses = input.bool(defval = true, title = "Show Stop Losses", group = "Strategy") +showSupportResistance = input.bool(defval = false, title = "Show Support and Resistance", group = "Strategy") + +// +// Show Signals based on their types ... +showLongSignals = input.bool(defval = true, title = "Show Long Signals", group = "Signals") +showShortSignals = input.bool(defval = true, title = "Show Short Signals", group = "Signals") + +// +// Show Stop Losses based on their types ... +showLongStopLosses = input.bool(defval = true, title = "Show Long Stop Losses", group = "Stop Loss") +showShortStopLosses = input.bool(defval = true, title = "Show Short Stop Losses", group = "Stop Loss") +// +// END Inputs .... +// + +// +// START Functions .... +// +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +// Retrieve Specific Candle Height (based on low and high) ... +getCandleRange() => + high - low + +// +// Retrieve Candle Ranges Thirs Section ... +getCandleThird() => + getCandleRange() / 3 + +// +// Determines a Candle is Bullish or not ... +isBullishCandle() => + close > low + (getCandleThird() * 2) + +// +// Determines a Candle is Bearish or not ... +isNeutralCandle() => + close < low + (getCandleThird() * 2) and close > low + getCandleThird() + +// +// Determines a Candle is Neutral or not ... +isBearishCandle() => + close < low + getCandleThird() +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +/////////////////////// +// START Leledc Levels +/////////////////////// +// +Lelec(bars, len) => + // + result = 0 + bindex = int(na) + bindex := nz(bindex[1], 0) + sindex = int(na) + sindex := nz(sindex[1], 0) + + // + bindex := close > close[4] ? bindex + 1 : bindex + sindex := close < close[4] ? sindex + 1 : sindex + + // + lowest = ta.lowest(low, len) + highest = ta.highest(high, len) + + // + if bindex > bars and close < open and high >= highest + bindex := 0 + result := -1 + result + else + if sindex > bars and close > open and low <= lowest + sindex := 0 + result := 1 + result +/////////////////////// +// END Leledc Levels +/////////////////////// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var shortColor = color.red +var longColor = color.lime + +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +var bullishColor = color.lime +var bullishShape = shape.arrowup +var bullishTitle = "Bullish" +var bullishType = 1 + +// +var bearishColor = color.red +var bearishShape = shape.arrowdown +var bearishTitle = "Bearish" +var bearishType = -1 + +// +var neutralColor = color.gray +var neutralShape = shape.circle +var neutralTitle = "Neutral" +var neutralType = 0 + +// +candleType = isBullishCandle() ? bullishType : isNeutralCandle() ? neutralType : isBearishCandle() ? bearishType : neutralType + +// +prevCandleType = not na(candleType[1]) ? candleType[1] : neutralType + +// +candleNeighborhoodBaseType = prevCandleType + candleType +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +/////////////////////// +// START Leledc Levels +/////////////////////// +// +LLBars = 42 +LLLength = 40 +LLLevelSwitch = true +LLThicknesSwitch = 7 +LLExhaustionSwitch = true + +// +// Out C ... +Lelex = Lelec(LLBars, LLLength) + +// +// Out Bar ... +LLHighLel = Lelex == -1 ? high : na +LLLowLel = Lelex == 1 ? low : na + +// +// Out level ... +LLResistance = float(na) +LLSupport = float(na) +LLResistance := close < open and Lelex ? high : LLResistance[1] +LLSupport := close > open and Lelex ? low : LLSupport[1] + +// +// Resistance Color ... +LLResistanceColor = shortColor +LLHighColor = ta.change(LLResistance) == 0 ? LLResistanceColor : na + +// +// Support Color ... +LLSupportColor = longColor +LLLowColor = ta.change(LLSupport) == 0 ? LLSupportColor : na + +// +// Has Signal ... +LLHasSignal = LLExhaustionSwitch + +// +// Up Signals ... +LLUpSignal = LLHasSignal ? LLLowLel : na + +// +// Down Signals ... +LLDownSignal = LLHasSignal ? LLHighLel : na +/////////////////////// +// END Leledc Levels +/////////////////////// + +/////////////////////// +// START ATR Stop Loss +/////////////////////// +// +ATRSLSource = low +ATRSLLength = 14 +ATRSLMultiplier = 1.6 + +// +ATRSLLongStopLoss = ATRSLSource - ta.atr(ATRSLLength) * ATRSLMultiplier +ATRSLShortStopLoss = ATRSLSource + ta.atr(ATRSLLength) * ATRSLMultiplier +/////////////////////// +// END ATR Stop Loss +/////////////////////// + +/////////////////////// +// START Cycle Channel +/////////////////////// +// +CCHSclT = 10 +CCHMclT = 30 +CCHScm = 1.0 +CCHMcm = 3.0 +CCHSrc = close +CCHEbc = false + +// +CCHScl = CCHSclT / 2 +CCHMcl = CCHMclT / 2 + +// +CCHMaScl = ta.rma(CCHSrc, CCHScl) +CCHMaMcl = ta.rma(CCHSrc, CCHMcl) + +// +CCHScmOff = CCHScm * ta.atr(CCHScl) +CCHMcmOff = CCHMcm * ta.atr(CCHMcl) + +// +CCHScl2 = CCHScl / 2 +CCHMcl2 = CCHMcl / 2 + +// +CCHSct = nz(CCHMaScl[CCHScl2], CCHSrc) + CCHScmOff +CCHScb = nz(CCHMaScl[CCHScl2], CCHSrc) - CCHScmOff + +// +CCHMct = nz(CCHMaMcl[CCHMcl2], CCHSrc) + CCHMcmOff +CCHMcb = nz(CCHMaMcl[CCHMcl2], CCHSrc) - CCHMcmOff + +// +CCHScmm = math.avg(CCHSct, CCHScb) + +// +CCHOmed = (CCHScmm - CCHMcb) / (CCHMct - CCHMcb) +CCHOshort = (CCHSrc - CCHMcb) / (CCHMct - CCHMcb) + +// +CCHBc = (CCHOshort > 0.5) ? (CCHOshort > 1.0 ? color.purple : (CCHOshort > CCHOmed ? color.lime : color.green)) : (CCHOshort < 0 ? color.purple : ( CCHOshort < CCHOmed ? color.red : color.orange)) +/////////////////////// +// END Cycle Channel +/////////////////////// + +/////////////////////// +// START Strategy ... +/////////////////////// +// +canShowStopLoss = showSignals and showStopLosses and (showLongSignals or showShortSignals) and (showLongStopLosses or showShortStopLosses) +canShowLongStopLoss = canShowStopLoss and showLongStopLosses and not na(ATRSLLongStopLoss) +canShowShortStopLoss = canShowStopLoss and showShortStopLosses and not na(ATRSLShortStopLoss) + +// +// retrieve verification from CCH ... +// +// Red Line ... +fastLine = CCHOshort +// plot(fastLine, color = color.red) + +// +// Green Line ... +slowLine = CCHOmed +// plot(slowLine, color = color.green) + +// +// CCH Long Verification ... +isLongPositionVerifiedByCCH = fastLine < 0.5 and slowLine < 0.5 and fastLine < slowLine + +// +// CCH Short Verification ... +isShortPositionVerifiedByCCH = fastLine > 0.5 and slowLine > 0.5 and fastLine > slowLine + +// +hasSignal = LLHasSignal + +// +hasLongSignal = hasSignal and not na(LLUpSignal) and isLongPositionVerifiedByCCH and isBullishCandle() +longSignal = hasLongSignal ? LLUpSignal : na + +// +hasShortSignal = hasSignal and not na(LLDownSignal) and isShortPositionVerifiedByCCH and isBearishCandle() +shortSignal = hasShortSignal ? LLDownSignal : na + +// +canShowSignal = showSignals and (showLongSignals or showShortSignals) +canShowLongSignal = canShowSignal and showLongSignals and hasLongSignal +canShowShortSignal = canShowSignal and showShortSignals and hasShortSignal +/////////////////////// +// END Strategy ... +/////////////////////// +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Signals ... +plotshape(canShowLongSignal ? longSignal : na, title = "Long Signal", color = longColor, location = location.belowbar, style = shape.triangleup, size = size.normal) +plotshape(canShowShortSignal ? shortSignal : na, title = "Short Signal", color = shortColor, location = location.abovebar, style = shape.triangledown, size = size.normal) + +// +// Stop Losses ... +plot(series = canShowLongStopLoss ? ATRSLLongStopLoss : na, color = color.fuchsia, linewidth = 1, style = plot.style_stepline, title = "Long Stop Loss") +plot(series = canShowShortStopLoss ? ATRSLShortStopLoss : na, color = color.aqua, linewidth = 1, style = plot.style_stepline, title = "Short Stop Loss") + +// +// Support and Resistance level ... +plot(showSupportResistance and LLLevelSwitch ? LLSupport : na, title = "Support Level", style = plot.style_line, color = LLLowColor, linewidth = LLThicknesSwitch) +plot(showSupportResistance and LLLevelSwitch ? LLResistance : na, title = "Reistance Level", style = plot.style_line, color = LLHighColor, linewidth = LLThicknesSwitch) +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(hasSignal, "XST_SR15M > Signal") +alertcondition(hasLongSignal, "XST_SR15M > Long Signal") +alertcondition(hasShortSignal, "XST_SR15M > Short Signal") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xStrategies/XST_TM15M/Docs/XST_TM15M.md b/xStrategies/XST_TM15M/Docs/XST_TM15M.md new file mode 100644 index 0000000..7e6641c --- /dev/null +++ b/xStrategies/XST_TM15M/Docs/XST_TM15M.md @@ -0,0 +1,43 @@ +# Trend Magic Scalping (TM15M) + +## Setup + +- **TF**: 15m +- **Asset**: AAPL +- **R2R**: 1:1.1 +- **Indicators**: + - : + - ; +- **Oscillators**: + - : + - ; + +## Using the Strategy + +### Long/Buy Conditions + +- ; + +#### Long SL + +place sl at prev MArket lowest + +#### Long TP + +calculate based on R2R; + +### Short/Sell Conditions + +- ; + +#### Short SL + +place sl at prev market highest; + +#### Short TP + +calculate based on R2R; + +### Signals Overlap + +how to handle signals overlaps. diff --git a/xStrategies/XST_TM15M/Docs/microsoft-report.md b/xStrategies/XST_TM15M/Docs/microsoft-report.md new file mode 100644 index 0000000..e06e850 --- /dev/null +++ b/xStrategies/XST_TM15M/Docs/microsoft-report.md @@ -0,0 +1,93 @@ +# XST_SR15M + +## Report + +### Makret + +ETHUSDT + +### Exchange + +Kucoin + +### Time Frame + +15min + +### Start Date + +13 march 2023 | 14:00 + +### End Date + +21 may 2023 | 15:00 + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | | X | | +| 4 | Long | | x | | +| 5 | Long | x | | | +| 6 | Long | | x | | +| 7 | Long | | x | | +| 8 | Long | x | | | +| 9 | Long | | x | | +| 10 | Long | x | | | +| 11 | Long | | x | | +| 12 | Long | | x | | +| 13 | Long | | x | | +| 14 | Long | | x | | +| 15 | Long | x | | | +| 16 | Long | | | | +| 17 | Long | | | | +| 18 | Long | | | | +| 19 | Long | | | | +| 20 | Long | | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | x | | +| 2 | Short | | x | | +| 3 | Short | | x | | +| 4 | Short | | | | +| 5 | Short | | | | +| 6 | Short | | | | +| 7 | Short | | | | +| 8 | Short | | | | +| 9 | Short | | | | +| 10 | Short | | | | +| 11 | Short | | | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :-: | :-: | :-: | :-: | +| Shorts | | 4 | 5 | +| Longs | 12 | 7 | 5 | +| Total | 21 | 11 | 10 | + +#### Analysis + +per trade volume: 10$ +total spending: 210$ +total comeback: 165$ diff --git a/xStrategies/XST_TM15M/Docs/report.md b/xStrategies/XST_TM15M/Docs/report.md new file mode 100644 index 0000000..1f5498c --- /dev/null +++ b/xStrategies/XST_TM15M/Docs/report.md @@ -0,0 +1,93 @@ +# XST_SR15M + +## Report 1 + +### Makret + +ETHUSDT + +### Exchange + +Kucoin + +### Time Frame + +15min + +### Start Date + +15 may 2023 | 01:30 + +### End Date + +21 may 2023 | 15:00 + +### Risk to Reward + +1:1.5 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | x | | | +| 4 | Long | | x | | +| 5 | Long | x | | | +| 6 | Long | x | | | +| 7 | Long | x | | | +| 8 | Long | x | | | +| 9 | Long | x | | | +| 10 | Long | | x | | +| 11 | Long | | x | | +| 12 | Long | x | | | +| 13 | Long | x | | | +| 14 | Long | x | | | +| 15 | Long | | x | | +| 16 | Long | x | | | +| 17 | Long | | x | | +| 18 | Long | x | | | +| 19 | Long | | x | | +| 20 | Long | | x | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | x | Open | +| 2 | Short | x | | | +| 3 | Short | x | | | +| 4 | Short | x | | | +| 5 | Short | | x | | +| 6 | Short | x | | | +| 7 | Short | x | | | +| 8 | Short | | x | | +| 9 | Short | x | | | +| 10 | Short | x | | | +| 11 | Short | | | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :-: | :-: | :-: | :-: | +| Shorts | | 4 | 5 | +| Longs | 12 | 7 | 5 | +| Total | 21 | 11 | 10 | + +#### Analysis + +per trade volume: 10$ +total spending: 210$ +total comeback: 165$ diff --git a/xStrategies/XST_TM15M/xst_tm15m.pine b/xStrategies/XST_TM15M/xst_tm15m.pine new file mode 100644 index 0000000..0e52e7c --- /dev/null +++ b/xStrategies/XST_TM15M/xst_tm15m.pine @@ -0,0 +1,340 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center XTrade TM15M Strategy +// --------------------------------------------- +// in this strategy i must use: +// - ; +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm XTrade TM15M Strategy", shorttitle = "XST_TM15M", overlay = true) + +// +// START Inputs .... +// +// +showTrendMagic = input.bool(defval = false, title = "Show Trend Magic") + +// +// Determines Show Signals or not ... +showSignals = input.bool(defval = true, title = "Show Signals", group = "Strategy") +showStopLosses = input.bool(defval = true, title = "Show Stop Losses", group = "Strategy") + +// +// Show Signals based on their types ... +showLongSignals = input.bool(defval = true, title = "Show Long Signals", group = "Signals") +showShortSignals = input.bool(defval = true, title = "Show Short Signals", group = "Signals") + +// +// Show Stop Losses based on their types ... +swingLoopback = input.int(defval = 7, title = "Swing Loopback Period", group = "Stop Loss") +showLongStopLosses = input.bool(defval = true, title = "Show Long Stop Losses", group = "Stop Loss") +showShortStopLosses = input.bool(defval = true, title = "Show Short Stop Losses", group = "Stop Loss") +// +// END Inputs .... +// + +// +// START Functions .... +// +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +// Retrieve Specific Candle Height (based on low and high) ... +getCandleRange() => + high - low + +// +// Retrieve Candle Ranges Thirs Section ... +getCandleThird() => + getCandleRange() / 3 + +// +// Determines a Candle is Bullish or not ... +isBullishCandle() => + close > low + (getCandleThird() * 2) + +// +// Determines a Candle is Bearish or not ... +isNeutralCandle() => + close < low + (getCandleThird() * 2) and close > low + getCandleThird() + +// +// Determines a Candle is Neutral or not ... +isBearishCandle() => + close < low + getCandleThird() +///////////////////////////// +// END Price Action Candles +///////////////////////////// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var shortColor = color.red +var longColor = color.lime + +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +var bullishColor = color.lime +var bullishShape = shape.arrowup +var bullishTitle = "Bullish" +var bullishType = 1 + +// +var bearishColor = color.red +var bearishShape = shape.arrowdown +var bearishTitle = "Bearish" +var bearishType = -1 + +// +var neutralColor = color.gray +var neutralShape = shape.circle +var neutralTitle = "Neutral" +var neutralType = 0 + +// +candleType = isBullishCandle() ? bullishType : isNeutralCandle() ? neutralType : isBearishCandle() ? bearishType : neutralType + +// +prevCandleType = not na(candleType[1]) ? candleType[1] : neutralType + +// +candleNeighborhoodBaseType = prevCandleType + candleType +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +//////////////////////////// +// START Last Market Price +//////////////////////////// +// +lastMarketLowest = ta.lowest(low, swingLoopback) +lastMarketLowest2 = ta.lowest(low, swingLoopback * 2) +lastMarketLowest3 = ta.lowest(low, swingLoopback * 3) + +// +lastMarketHighest = ta.highest(high, swingLoopback) +lastMarketHighest2 = ta.highest(high, swingLoopback * 2) +lastMarketHighest3 = ta.highest(high, swingLoopback * 3) +//////////////////////////// +// END Last Market Price +//////////////////////////// + +//////////////////////////// +// START Trend Magic ... +//////////////////////////// +TMAP = 5 +TMCoeff = 1 +TMPeriod = 20 +TMSrc = close + +// +TMATR = ta.sma(ta.tr,TMAP) + +// +TMUpT = low - TMATR * TMCoeff +TMDownT = high + TMATR * TMCoeff + +// +TMMagicTrend = 0.0 +TMMagicTrend := ta.cci(TMSrc, TMPeriod) >= 0 ? (TMUpT < nz(TMMagicTrend[1]) ? nz(TMMagicTrend[1]) : TMUpT) : (TMDownT > nz(TMMagicTrend[1]) ? nz(TMMagicTrend[1]) : TMDownT) + +// +// Check Candle State based on TMMagic Trend ... +TMCandleState = ta.cci(TMSrc, TMPeriod) + +// +TMTrendUp = TMCandleState > 0 +TMTrendDown = TMCandleState < 0 +TMTrendNeutral = TMCandleState == 0 + +// +TMTrendDiff = TMMagicTrend - TMMagicTrend[1] +// plot(series = TMTrendDiff, color = color.yellow) + +// // +// TMTrendNeutral = TMTrendDiff == 0 +// TMTrendIncreased = TMTrendDiff > 0 +// TMTrendDecreased = TMTrendDiff < 0 + +// +TMTrendChanged = TMTrendUp and not TMTrendUp[1] or not TMTrendUp and TMTrendUp[1] + +// +TMColor = TMTrendUp ? color.blue : TMTrendDown ? color.red : TMTrendNeutral ? color.gray : na +//////////////////////////// +// END Trend Magic ... +//////////////////////////// + +/////////////////////// +// START Cycle Channel +/////////////////////// +// +CCHSclT = 10 +CCHMclT = 30 +CCHScm = 1.0 +CCHMcm = 3.0 +CCHSrc = close +CCHEbc = false + +// +CCHScl = CCHSclT / 2 +CCHMcl = CCHMclT / 2 + +// +CCHMaScl = ta.rma(CCHSrc, CCHScl) +CCHMaMcl = ta.rma(CCHSrc, CCHMcl) + +// +CCHScmOff = CCHScm * ta.atr(CCHScl) +CCHMcmOff = CCHMcm * ta.atr(CCHMcl) + +// +CCHScl2 = CCHScl / 2 +CCHMcl2 = CCHMcl / 2 + +// +CCHSct = nz(CCHMaScl[CCHScl2], CCHSrc) + CCHScmOff +CCHScb = nz(CCHMaScl[CCHScl2], CCHSrc) - CCHScmOff + +// +CCHMct = nz(CCHMaMcl[CCHMcl2], CCHSrc) + CCHMcmOff +CCHMcb = nz(CCHMaMcl[CCHMcl2], CCHSrc) - CCHMcmOff + +// +CCHScmm = math.avg(CCHSct, CCHScb) + +// +CCHOmed = (CCHScmm - CCHMcb) / (CCHMct - CCHMcb) +CCHOshort = (CCHSrc - CCHMcb) / (CCHMct - CCHMcb) + +// +CCHSlowOSC = CCHOmed +CCHFastOSC = CCHOshort + +// +CCHMidPoint = 0.5 +isCCHUpTrend = CCHFastOSC > CCHMidPoint +isCCHDownTrend = CCHFastOSC < CCHMidPoint +CCHTrendUp = ta.crossover(CCHFastOSC, CCHMidPoint) +CCHTrendDown = ta.crossunder(CCHFastOSC, CCHMidPoint) +CCHTrendBullish = ta.crossover(CCHFastOSC, CCHSlowOSC) and isBullishCandle() + +// +CCHFastOSCDiff = CCHFastOSC - CCHFastOSC[1] +CCHSlowOSCDiff = CCHSlowOSC - CCHSlowOSC[1] +// plot(CCHFastOSCDiff, color = color.fuchsia) +// plot(CCHSlowOSCDiff, color =color.yellow) +// isFastOSCDiffPassed = true // CCHFastOSCDiff < 0 and CCHFastOSCDiff < -0.07 +// isSlowOSCDiffPassed = true // CCHSlowOSCDiff > 0 and CCHSlowOSCDiff <= 0.03 + +// +// lastMarketRange = lastMarketHighest - TMMagicTrend +// candleRangeInLastMarket = math.abs(lastMarketRange - getCandleRange()) +// isCandleVerifiedInTrendClopud = lastMarketRange > getCandleRange() and candleRangeInLastMarket >= lastMarketRange / 2 + +// isCandleRageVerified = +// plot(lastMarketRange, color = color.maroon) +// plot(candleRangeInLastMarket, color = color.rgb(11, 108, 199)) + +CCHTrendBearish = ta.crossunder(CCHFastOSC, CCHSlowOSC) and isBearishCandle() and low < TMMagicTrend and high < TMMagicTrend // and isCandleVerifiedInTrendClopud // and isFastOSCDiffPassed and isSlowOSCDiffPassed + +// +CCHBc = (CCHOshort > 0.5) ? (CCHOshort > 1.0 ? color.purple : (CCHOshort > CCHOmed ? color.lime : color.green)) : (CCHOshort < 0 ? color.purple : ( CCHOshort < CCHOmed ? color.red : color.orange)) +/////////////////////// +// END Cycle Channel +/////////////////////// + +/////////////////////// +// START Strategy ... +/////////////////////// +// +canShowStopLoss = showSignals and showStopLosses and (showLongSignals or showShortSignals) and (showLongStopLosses or showShortStopLosses) +canShowLongStopLoss = canShowStopLoss and showLongStopLosses // and not na(ATRSLLongStopLoss) +canShowShortStopLoss = canShowStopLoss and showShortStopLosses // and not na(ATRSLShortStopLoss) + +// +hasSignal = TMTrendUp and CCHTrendUp or CCHTrendBearish // (TMTrendDown and CCHTrendDown) + +// +hasLongSignal = hasSignal and TMTrendUp and CCHTrendUp and TMTrendDiff[1] >= 0// and open < TMMagicTrend //and (close < TMMagicTrend) and isBullishCandle() +longSignal = hasLongSignal ? bar_index : na +float longStopLoss = lastMarketLowest + +// +hasShortSignal = hasSignal and CCHTrendBearish // and TMTrendDown and open > TMMagicTrend // and close > TMMagicTrend) and isBearishCandle() +shortSignal = hasShortSignal ? bar_index : na +float shortStopLoss = lastMarketHighest + +// +canShowSignal = showSignals and (showLongSignals or showShortSignals) +canShowLongSignal = canShowSignal and showLongSignals and hasLongSignal +canShowShortSignal = canShowSignal and showShortSignals and hasShortSignal +/////////////////////// +// END Strategy ... +/////////////////////// +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Trend Magic ... +plot(series = showTrendMagic ? TMMagicTrend : na, color = TMColor, linewidth = 3, title = "TM > Trend Magic") + +// +// CCH Trend Signals ... +// plotshape(CCHTrendUp ? bar_index : na, title = "CCH > Trend Up", location = location.belowbar ,style = shape.arrowup, size = size.normal, color = color.green) +// plotshape(CCHTrendBullish ? bar_index : na, title = "CCH > Trend Bullish", location = location.belowbar ,style = shape.arrowup, size = size.normal, color = color.aqua) +// plotshape(CCHTrendDown ? bar_index : na, title = "CCH > Trend Down", location = location.abovebar, style = shape.arrowdown, size = size.normal, color = color.red) +// plotshape(CCHTrendBearish ? bar_index : na, title = "CCH > Trend Bearish", location = location.abovebar, style = shape.arrowdown, size = size.normal, color = color.purple) + +// +// TM Trend Signals ... +// plotshape(TMTrendUp ? bar_index : na, title = "TM > Trend Up", location = location.belowbar ,style = shape.labelup, size = size.normal, color = color.green) +// plotshape(TMTrendDown ? bar_index : na, title = "TM > Trend Down", location = location.abovebar, style = shape.labeldown, size = size.normal, color = color.red) + + +// +// Signals ... +plotshape(canShowLongSignal ? longSignal : na, title = "Long Signal", color = longColor, location = location.belowbar, style = shape.triangleup, size = size.normal) +plotshape(canShowShortSignal ? shortSignal : na, title = "Short Signal", color = shortColor, location = location.abovebar, style = shape.triangledown, size = size.normal) + +// +// Stop Losses ... +plot(series = canShowLongStopLoss ? longStopLoss : na, color = color.fuchsia, linewidth = 1, style = plot.style_stepline, title = "Long Stop Loss") +plot(series = canShowShortStopLoss ? shortStopLoss : na, color = color.aqua, linewidth = 1, style = plot.style_stepline, title = "Short Stop Loss") +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(hasSignal, "XST_SHULL5M > Signal") +alertcondition(hasLongSignal, "XST_SHULL5M > Long Signal") +alertcondition(hasShortSignal, "XST_SHULL5M > Short Signal") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xStrategies/XST_TMPLMCD5M/Docs/XST_TMPLMCD5M.md b/xStrategies/XST_TMPLMCD5M/Docs/XST_TMPLMCD5M.md new file mode 100644 index 0000000..ead1dc0 --- /dev/null +++ b/xStrategies/XST_TMPLMCD5M/Docs/XST_TMPLMCD5M.md @@ -0,0 +1,54 @@ +# Trend Magic Scalping (TMPLMCD5M) + +## Setup + +- **TF**: 5m +- **Asset**: TSLA +- **R2R**: 1:2 +- **Indicators**: + - Trend Magic (KivancQzbilgic): + - Change Plot Blue color to Green; + - Change CCI Period to 18; +- **Oscillators**: + - Impulse MACD by LazyBear: + - Change ImpulseMACD shows as Columns; + - Change ImpulseMACD Color 3 to Red; + - Change Color of ImpulsHisto to Yellow; + +## Using the Strategy + +### Long/Buy Conditions + +- ImpulseMACD gives Green DownSide (Reversal); +- ImpulseMACD Green Column is above of ImpulseMACD signal line; +- ImpulseHisto Yellow is above MACD green Bar (above zero line); +- TrendMagic is Green; +- Market froms a Bullish Candle; + +#### Long SL + +place sl at prev MArket lowest + +#### Long TP + +calculate based on R2R; + +### Short/Sell Conditions + +- ImpulseMACD gives Red UpSide (Reversal); +- ImpulseMACD Red Column is below of ImpulseMACD signal line; +- ImpulseHisto Yellow is below MACD Red Bar (below zero line); +- TrendMagic is Red; +- Market froms a Berish Candle; + +#### Short SL + +place sl at prev market highest; + +#### Short TP + +calculate based on R2R; + +### Signals Overlap + +how to handle signals overlaps. diff --git a/xStrategies/XST_TMPLMCD5M/Docs/report.BTCUSDT.p.OKX.5m.md b/xStrategies/XST_TMPLMCD5M/Docs/report.BTCUSDT.p.OKX.5m.md new file mode 100644 index 0000000..4c4aca3 --- /dev/null +++ b/xStrategies/XST_TMPLMCD5M/Docs/report.BTCUSDT.p.OKX.5m.md @@ -0,0 +1,96 @@ +# XST_TMPLMCD5M + +## Report + +### Makret + +BTCUSDT.P + +### Exchange + +OKX + +### Time Frame + +5min + +### Start Date + +19 may 2023 | 03:20 UTC + +### End Date + +22 may 2023 | 15:10 UTC + +### Risk to Reward + +1:2 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | | x | | +| 2 | Long | | x | | +| 3 | Long | | x | | +| 4 | Long | x | | | +| 5 | Long | x | | | +| 6 | Long | x | | | +| 7 | Long | | x | | +| 8 | Long | x | | | +| 9 | Long | | | | +| 10 | Long | | | | +| 11 | Long | | | | +| 12 | Long | | | | +| 13 | Long | | | | +| 14 | Long | | | | +| 15 | Long | | | | +| 16 | Long | | | | +| 17 | Long | | | | +| 18 | Long | | | | +| 19 | Long | | | | +| 20 | Long | | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | | Open | +| 2 | Short | x | | | +| 3 | Short | x | | | +| 4 | Short | | x | | +| 5 | Short | | x | | +| 6 | Short | | x | | +| 7 | Short | | x | | +| 8 | Short | x | | | +| 9 | Short | x | | | +| 10 | Short | | x | | +| 11 | Short | x | | | +| 12 | Short | | x | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 08 | 04 | 04 | +| Shorts | 12 | 05 | 06 | 1 OPEN +| Total | 00 | 00 | 00 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 200$ +total lose: 100$ +total reward: 180$ +total cash: 100$ + 180$ = 280$ +win rate: 40% diff --git a/xStrategies/XST_TMPLMCD5M/Docs/report.ETHUSDT.Kucoin.5m.md b/xStrategies/XST_TMPLMCD5M/Docs/report.ETHUSDT.Kucoin.5m.md new file mode 100644 index 0000000..1870a83 --- /dev/null +++ b/xStrategies/XST_TMPLMCD5M/Docs/report.ETHUSDT.Kucoin.5m.md @@ -0,0 +1,96 @@ +# XST_TMPLMCD5M + +## Report + +### Makret + +ETHUSDT + +### Exchange + +Kucoin + +### Time Frame + +5min + +### Start Date + +14 may 2023 | 07:25 UTC + +### End Date + +22 may 2023 | 08:55 UTC + +### Risk to Reward + +1:2 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | | x | | +| 3 | Long | x | | | +| 4 | Long | | x | | +| 5 | Long | | x | | +| 6 | Long | | x | | +| 7 | Long | | x | | +| 8 | Long | x | | | +| 9 | Long | | | | +| 10 | Long | | | | +| 11 | Long | | | | +| 12 | Long | | | | +| 13 | Long | | | | +| 14 | Long | | | | +| 15 | Long | | | | +| 16 | Long | | | | +| 17 | Long | | | | +| 18 | Long | | | | +| 19 | Long | | | | +| 20 | Long | | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | x | | +| 2 | Short | x | | | +| 3 | Short | x | | | +| 4 | Short | | x | | +| 5 | Short | x | | | +| 6 | Short | | x | | +| 7 | Short | x | | | +| 8 | Short | x | | | +| 9 | Short | x | | | +| 10 | Short | x | | | +| 11 | Short | | x | | +| 12 | Short | x | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 08 | 03 | 05 | +| Shorts | 12 | 08 | 04 | +| Total | 20 | 11 | 09 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 200$ +total lose: 90$ +total reward: 220$ +total cash: 110$ + 220$ = 330$ +win rate: 65% diff --git a/xStrategies/XST_TMPLMCD5M/Docs/report.MicroStrategy.NASDAQ.5min.md b/xStrategies/XST_TMPLMCD5M/Docs/report.MicroStrategy.NASDAQ.5min.md new file mode 100644 index 0000000..564eea2 --- /dev/null +++ b/xStrategies/XST_TMPLMCD5M/Docs/report.MicroStrategy.NASDAQ.5min.md @@ -0,0 +1,100 @@ +# XST_TMPLMCD5M + +## Report + +### Makret + +Micro Strategy + +### Exchange + +NASDAQ + +### Time Frame + +5min + +### Start Date + +14 Feb 2023 | 14:30 UTC + +### End Date + +18 may 2023 | 18:45 UTC + +### Risk to Reward + +1:2 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | x | | | +| 4 | Long | x | | | +| 5 | Long | | x | | +| 6 | Long | x | | | +| 7 | Long | | x | | +| 8 | Long | | x | | +| 9 | Long | | x | | +| 10 | Long | | x | | +| 11 | Long | x | | | +| 12 | Long | x | | | +| 13 | Long | | x | | +| 14 | Long | | x | | +| 15 | Long | x | | | +| 16 | Long | x | | | +| 17 | Long | | x | | +| 18 | Long | | x | | +| 19 | Long | | x | | +| 20 | Long | | x | | +| 21 | Long | | x | | +| 22 | Long | | x | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | | x | | +| 3 | Short | | x | | +| 4 | Short | | x | | +| 5 | Short | | x | | +| 6 | Short | x | | | +| 7 | Short | | x | | +| 8 | Short | | x | | +| 9 | Short | | x | | +| 10 | Short | x | | | +| 11 | Short | | x | | +| 12 | Short | | x | | +| 13 | Short | | x | | +| 14 | Short | | x | | +| 15 | Short | | x | | +| 16 | Short | | x | | +| 17 | Short | x | | | +| 18 | Short | x | | | +| 19 | Short | x | | | +| 20 | Short | | x | | +| 21 | Short | | x | | +| 22 | Short | x | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 22 | 09 | 13 | +| Shorts | 22 | 07 | 15 | +| Total | 44 | 16 | 28 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 440$ +total lose: 280$ +total reward: 320$ +total cash: 480$ +win rate: 9.09% diff --git a/xStrategies/XST_TMPLMCD5M/Docs/report.TSLA.NASDAQ.5m.md b/xStrategies/XST_TMPLMCD5M/Docs/report.TSLA.NASDAQ.5m.md new file mode 100644 index 0000000..c4a9d4d --- /dev/null +++ b/xStrategies/XST_TMPLMCD5M/Docs/report.TSLA.NASDAQ.5m.md @@ -0,0 +1,96 @@ +# XST_TMPLMCD5M + +## Report + +### Makret + +TSLA + +### Exchange + +NASDAQ + +### Time Frame + +5min + +### Start Date + +10 mar 2023 | 15:05 UTC + +### End Date + +16 may 2023 | 14:25 UTC + +### Risk to Reward + +1:2 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | x | | | +| 2 | Long | x | | | +| 3 | Long | | x | | +| 4 | Long | | x | | +| 5 | Long | | | | +| 6 | Long | | | | +| 7 | Long | | | | +| 8 | Long | | | | +| 9 | Long | | | | +| 10 | Long | | | | +| 11 | Long | | | | +| 12 | Long | | | | +| 13 | Long | | | | +| 14 | Long | | | | +| 15 | Long | | | | +| 16 | Long | | | | +| 17 | Long | | | | +| 18 | Long | | | | +| 19 | Long | | | | +| 20 | Long | | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | | x | | +| 3 | Short | x | | | +| 4 | Short | x | | | +| 5 | Short | | x | | +| 6 | Short | | x | | +| 7 | Short | | | | +| 8 | Short | | | | +| 9 | Short | | | | +| 10 | Short | | | | +| 11 | Short | | | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 04 | 02 | 02 | +| Shorts | 06 | 03 | 03 | +| Total | 10 | 05 | 05 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 100$ +total lose: 50$ +total reward: 100$ +total cash: 150$ +win rate: 50% diff --git a/xStrategies/XST_TMPLMCD5M/Docs/report.XAUUSD.Forex.com.5m.md b/xStrategies/XST_TMPLMCD5M/Docs/report.XAUUSD.Forex.com.5m.md new file mode 100644 index 0000000..700b7bc --- /dev/null +++ b/xStrategies/XST_TMPLMCD5M/Docs/report.XAUUSD.Forex.com.5m.md @@ -0,0 +1,96 @@ +# XST_TMPLMCD5M + +## Report + +### Makret + +XAUUSD + +### Exchange + +Forex.com + +### Time Frame + +5min + +### Start Date + +1 may 2023 | 13:45 UTC + +### End Date + +22 may 2023 | 06:30 UTC + +### Risk to Reward + +1:2 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | | x | | +| 2 | Long | x | | | +| 3 | Long | | x | | +| 4 | Long | | x | | +| 5 | Long | | x | | +| 6 | Long | x | | | +| 7 | Long | | x | | +| 8 | Long | x | | | +| 9 | Long | | x | | +| 10 | Long | x | | | +| 11 | Long | | x | | +| 12 | Long | | | | +| 13 | Long | | | | +| 14 | Long | | | | +| 15 | Long | | | | +| 16 | Long | | | | +| 17 | Long | | | | +| 18 | Long | | | | +| 19 | Long | | | | +| 20 | Long | | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | | x | | +| 3 | Short | x | | | +| 4 | Short | x | | | +| 5 | Short | | x | | +| 6 | Short | x | | | +| 7 | Short | x | | | +| 8 | Short | | x | | +| 9 | Short | x | | | +| 10 | Short | | | | +| 11 | Short | | | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 11 | 04 | 07 | +| Shorts | 09 | 06 | 03 | +| Total | 20 | 10 | 10 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 200$ +total lose: 100$ +total reward: 200$ +total cash: 300$ +win rate: 50% diff --git a/xStrategies/XST_TMPLMCD5M/Docs/report.XMRUSDT.P.BINANCE.1h.md b/xStrategies/XST_TMPLMCD5M/Docs/report.XMRUSDT.P.BINANCE.1h.md new file mode 100644 index 0000000..ed8f40f --- /dev/null +++ b/xStrategies/XST_TMPLMCD5M/Docs/report.XMRUSDT.P.BINANCE.1h.md @@ -0,0 +1,96 @@ +# XST_TMPLMCD5M + +## Report + +### Makret + +XMRUSDT.P + +### Exchange + +Binance + +### Time Frame + +1h + +### Start Date + +8 jan 2023 | 14:00 UTC + +### End Date + +9 may 2023 | 03:00 UTC + +### Risk to Reward + +1:2 + +### Reports + +#### Longs + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Long | | x | | +| 2 | Long | x | | | +| 3 | Long | x | | | +| 4 | Long | | x | | +| 5 | Long | | x | | +| 6 | Long | x | | | +| 7 | Long | | x | | +| 8 | Long | | x | | +| 9 | Long | | x | | +| 10 | Long | | | | +| 11 | Long | | | | +| 12 | Long | | | | +| 13 | Long | | | | +| 14 | Long | | | | +| 15 | Long | | | | +| 16 | Long | | | | +| 17 | Long | | | | +| 18 | Long | | | | +| 19 | Long | | | | +| 20 | Long | | | | + +#### Shorts + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | | x | | +| 3 | Short | | x | | +| 4 | Short | x | | | +| 5 | Short | | x | | +| 6 | Short | x | | | +| 7 | Short | | x | | +| 8 | Short | x | | | +| 9 | Short | | x | | +| 10 | Short | | x | | +| 11 | Short | | x | | +| 12 | Short | | | | +| 13 | Short | | | | +| 14 | Short | | | | +| 15 | Short | | | | +| 16 | Short | | | | +| 17 | Short | | | | +| 18 | Short | | | | +| 19 | Short | | | | +| 20 | Short | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :----: | :-: | :-: | :-: | +| Longs | 09 | 03 | 06 | +| Shorts | 11 | 04 | 07 | +| Total | 20 | 07 | 13 | + +#### Analysis + +per trade volume: 10$ +total drawdown: 200$ +total lose: $ +total reward: $ +total cash: $ +win rate: % diff --git a/xStrategies/XST_TMPLMCD5M/xst_tmplmcd5m.pine b/xStrategies/XST_TMPLMCD5M/xst_tmplmcd5m.pine new file mode 100644 index 0000000..ea7157d --- /dev/null +++ b/xStrategies/XST_TMPLMCD5M/xst_tmplmcd5m.pine @@ -0,0 +1,344 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center XTrade TMPLMCD5M Strategy +// --------------------------------------------- +// in this strategy i must use: +// - Price Action Candle Recognition Indicator; +// - Swing Stop Loss Indicator; +// - TrenMagic Indicator; +// - Impulse MACD Oscillator; +// - Cycle Channel Oscillator; +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm XTrade TMPLMCD5M Strategy", shorttitle = "XST_TMPLMCD5M", overlay = true) + +// +// START Inputs .... +// +// +// Determines Show Signals or not ... +showSignals = input.bool(defval = true, title = "Show Signals", group = "Strategy") +showStopLosses = input.bool(defval = true, title = "Show Stop Losses", group = "Strategy") + +// +// Show Signals based on their types ... +showLongSignals = input.bool(defval = true, title = "Show Long Signals", group = "Signals") +showShortSignals = input.bool(defval = true, title = "Show Short Signals", group = "Signals") + +// +// Show Stop Losses based on their types ... +swingLoopback = input.int(defval = 7, title = "Swing Loopback Period", group = "Stop Loss") +showLongStopLosses = input.bool(defval = true, title = "Show Long Stop Losses", group = "Stop Loss") +showShortStopLosses = input.bool(defval = true, title = "Show Short Stop Losses", group = "Stop Loss") +// +// END Inputs .... +// + +// +// START Functions .... +// +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +// Retrieve Specific Candle Height (based on low and high) ... +getCandleRange() => + high - low + +// +// Retrieve Candle Ranges Thirs Section ... +getCandleThird() => + getCandleRange() / 3 + +// +// Determines a Candle is Bullish or not ... +isBullishCandle() => + close > low + (getCandleThird() * 2) + +// +// Determines a Candle is Bearish or not ... +isNeutralCandle() => + close < low + (getCandleThird() * 2) and close > low + getCandleThird() + +// +// Determines a Candle is Neutral or not ... +isBearishCandle() => + close < low + getCandleThird() +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +////////////////////// +// START Impuls MACD +////////////////////// +// +calc_smma(src, len) => + float result = na + rSma = ta.sma(src, len) + result := na(result[1]) ? rSma : (result[1] * (len - 1) + src) / len + result + +// +calc_zlema(src, length) => + ema1 = ta.ema(src, length) + ema2 = ta.ema(ema1, length) + d = ema1 - ema2 + result = ema1+d + result +////////////////////// +// END Impuls MACD +////////////////////// + +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var shortColor = color.fuchsia +var longColor = color.aqua + +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +var bullishTitle = "Bullish" +var bullishType = 1 + +// +var bearishTitle = "Bearish" +var bearishType = -1 + +// +var neutralTitle = "Neutral" +var neutralType = 0 + +// +candleType = isBullishCandle() ? bullishType : isNeutralCandle() ? neutralType : isBearishCandle() ? bearishType : neutralType + +// +prevCandleType = not na(candleType[1]) ? candleType[1] : neutralType + +// +candleNeighborhoodBaseType = prevCandleType + candleType +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +//////////////////////////// +// START Last Market Price +//////////////////////////// +// +lastMarketLowest = ta.lowest(low, swingLoopback) +lastMarketLowest2 = ta.lowest(low, swingLoopback * 2) +lastMarketLowest3 = ta.lowest(low, swingLoopback * 3) + +// +lastMarketHighest = ta.highest(high, swingLoopback) +lastMarketHighest2 = ta.highest(high, swingLoopback * 2) +lastMarketHighest3 = ta.highest(high, swingLoopback * 3) +//////////////////////////// +// END Last Market Price +//////////////////////////// + +//////////////////////////// +// START Trend Magic ... +//////////////////////////// +TMAP = 5 +TMCoeff = 1 +TMPeriod = 18 +TMSrc = close + +// +TMATR = ta.sma(ta.tr,TMAP) + +// +TMUpT = low - TMATR * TMCoeff +TMDownT = high + TMATR * TMCoeff + +// +TMMagicTrend = 0.0 +TMMagicTrend := ta.cci(TMSrc, TMPeriod) >= 0 ? (TMUpT < nz(TMMagicTrend[1]) ? nz(TMMagicTrend[1]) : TMUpT) : (TMDownT > nz(TMMagicTrend[1]) ? nz(TMMagicTrend[1]) : TMDownT) + +// +// Check Candle State based on TMMagic Trend ... +TMCandleState = ta.cci(TMSrc, TMPeriod) + +// +TMTrendUp = TMCandleState > 0 +TMTrendDown = TMCandleState < 0 +TMTrendNeutral = TMCandleState == 0 + +// +TMTrendDiff = TMMagicTrend - TMMagicTrend[1] + +// +TMTrendChanged = (TMTrendUp and not TMTrendUp[1]) or (TMTrendDown and not TMTrendDown[1]) + +// +TMColor = TMTrendUp ? color.green : TMTrendDown ? color.red : TMTrendNeutral ? color.gray : na +//////////////////////////// +// END Trend Magic ... +//////////////////////////// + +/////////////////////// +// START Cycle Channel +/////////////////////// +// +CCHSclT = 10 +CCHMclT = 30 +CCHScm = 1.0 +CCHMcm = 3.0 +CCHSrc = close +CCHEbc = false + +// +CCHScl = CCHSclT / 2 +CCHMcl = CCHMclT / 2 + +// +CCHMaScl = ta.rma(CCHSrc, CCHScl) +CCHMaMcl = ta.rma(CCHSrc, CCHMcl) + +// +CCHScmOff = CCHScm * ta.atr(CCHScl) +CCHMcmOff = CCHMcm * ta.atr(CCHMcl) + +// +CCHScl2 = CCHScl / 2 +CCHMcl2 = CCHMcl / 2 + +// +CCHSct = nz(CCHMaScl[CCHScl2], CCHSrc) + CCHScmOff +CCHScb = nz(CCHMaScl[CCHScl2], CCHSrc) - CCHScmOff + +// +CCHMct = nz(CCHMaMcl[CCHMcl2], CCHSrc) + CCHMcmOff +CCHMcb = nz(CCHMaMcl[CCHMcl2], CCHSrc) - CCHMcmOff + +// +CCHScmm = math.avg(CCHSct, CCHScb) + +// +CCHOmed = (CCHScmm - CCHMcb) / (CCHMct - CCHMcb) +CCHOshort = (CCHSrc - CCHMcb) / (CCHMct - CCHMcb) + +// +CCHSlowOSC = CCHOmed +CCHFastOSC = CCHOshort + +// +CCHMidPoint = 0.5 +isCCHUpTrend = CCHFastOSC > CCHMidPoint +isCCHDownTrend = CCHFastOSC < CCHMidPoint +CCHTrendUp = ta.crossover(CCHFastOSC, CCHMidPoint) +CCHTrendDown = ta.crossunder(CCHFastOSC, CCHMidPoint) +CCHTrendBullish = ta.crossover(CCHFastOSC, CCHSlowOSC) and isBullishCandle() + +// +CCHFastOSCDiff = CCHFastOSC - CCHFastOSC[1] +CCHSlowOSCDiff = CCHSlowOSC - CCHSlowOSC[1] + +// +CCHBc = (CCHOshort > 0.5) ? (CCHOshort > 1.0 ? color.purple : (CCHOshort > CCHOmed ? color.lime : color.green)) : (CCHOshort < 0 ? color.purple : ( CCHOshort < CCHOmed ? color.red : color.orange)) +/////////////////////// +// END Cycle Channel +/////////////////////// + +////////////////////// +// START Impuls MACD +////////////////////// +// +IMPMACDLengthMA = 34 +IMPMACDLengthSignal = 9 + +// +IMPMACDSrc = hlc3 +IMPMACDHi = calc_smma(high, IMPMACDLengthMA) +IMPMACDLo = calc_smma(low, IMPMACDLengthMA) +IMPMACDNi = calc_zlema(IMPMACDSrc, IMPMACDLengthMA) + +// +IMPMACDMd = (IMPMACDNi > IMPMACDHi) ? (IMPMACDNi - IMPMACDHi) : (IMPMACDNi < IMPMACDLo) ? (IMPMACDNi - IMPMACDLo) : 0.0 +IMPMACDSb = ta.sma(IMPMACDMd, IMPMACDLengthSignal) +IMPMACDSh = IMPMACDMd - IMPMACDSb + +// +IMPMACDIsBullish = (ta.crossunder(IMPMACDSb, IMPMACDMd) or ta.crossunder(IMPMACDSb[1], IMPMACDMd) or ta.crossunder(IMPMACDSb[2], IMPMACDMd)) and IMPMACDMd < 0 and IMPMACDSh > 0.1 and IMPMACDSb < IMPMACDMd and IMPMACDMd < -0.6 +IMPMACDIsBearish = (ta.crossover(IMPMACDSb, IMPMACDMd) or ta.crossover(IMPMACDSb[1], IMPMACDMd) or ta.crossover(IMPMACDSb[2], IMPMACDMd)) and IMPMACDMd > 0 and IMPMACDSh < -0.1 and IMPMACDSb > IMPMACDMd and IMPMACDMd > 0.6 +////////////////////// +// END Impuls MACD +////////////////////// + +/////////////////////// +// START Strategy ... +/////////////////////// +// +canShowStopLoss = showSignals and showStopLosses and (showLongSignals or showShortSignals) and (showLongStopLosses or showShortStopLosses) +canShowLongStopLoss = canShowStopLoss and showLongStopLosses +canShowShortStopLoss = canShowStopLoss and showShortStopLosses + +// +hasLongSignal = IMPMACDIsBullish and TMTrendUp and isBullishCandle() // and open < TMMagicTrend +longSignal = hasLongSignal ? bar_index : na +float longStopLoss = lastMarketLowest + +// +hasShortSignal = IMPMACDIsBearish and TMTrendDown and isBearishCandle() // and open > TMMagicTrend +shortSignal = hasShortSignal ? bar_index : na +float shortStopLoss = lastMarketHighest + +// +hasSignal = hasLongSignal or hasShortSignal + +// +canShowSignal = showSignals and (showLongSignals or showShortSignals) +canShowLongSignal = canShowSignal and showLongSignals and hasLongSignal +canShowShortSignal = canShowSignal and showShortSignals and hasShortSignal +/////////////////////// +// END Strategy ... +/////////////////////// +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Signals ... +plotshape(canShowLongSignal ? longSignal : na, title = "Long Signal", color = longColor, location = location.belowbar, style = shape.triangleup, size = size.normal) +plotshape(canShowShortSignal ? shortSignal : na, title = "Short Signal", color = shortColor, location = location.abovebar, style = shape.triangledown, size = size.normal) + +// +// Stop Losses ... +plot(series = canShowLongStopLoss ? longStopLoss : na, color = color.fuchsia, linewidth = 1, style = plot.style_stepline, title = "Long Stop Loss") +plot(series = canShowShortStopLoss ? shortStopLoss : na, color = color.aqua, linewidth = 1, style = plot.style_stepline, title = "Short Stop Loss") +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(hasSignal, "XST_SHULL5M > Signal") +alertcondition(hasLongSignal, "XST_SHULL5M > Long Signal") +alertcondition(hasShortSignal, "XST_SHULL5M > Short Signal") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xStrategies/XST_VBM15M/Docs/XST_VBM15M.md b/xStrategies/XST_VBM15M/Docs/XST_VBM15M.md new file mode 100644 index 0000000..97ab17b --- /dev/null +++ b/xStrategies/XST_VBM15M/Docs/XST_VBM15M.md @@ -0,0 +1,52 @@ +# VB Momentum Scalping (XTS_VBM15M) + +## Setup + +- **TF**: 15m +- **Asset**: AAPL +- **R2R**: 1:1.5 +- **Indicators**: + - vbm_Buy or Sell Signal (vbmohale): + - Change Factor to 4; +- **Oscillators**: + - Multpile Strategies (LupOwn): + - Change MOM Length to 17; + - Change SQZ Length to 17; + - Uncheck Show ADX; + - Uncheck Show Status; + +## Using the Strategy + +### Long/Buy Conditions + +- VBM gives us BUY signal (label up); +- RSI => OSC Top Part shoud be above 0.5 level; +- Histogram of OSC shoud be green Color; +- Market forms a Bullish Candle; + +#### Long SL + +place sl at prev MArket lowest + +#### Long TP + +calculate based on R2R; + +### Short/Sell Conditions + +- VBM gives us SELL signal (label down); +- RSI => OSC Top Part shoud be below 0.5 level; +- Histogram of OSC shoud be red Color; +- Market forms a Bearish Candle; + +#### Short SL + +place sl at prev market highest; + +#### Short TP + +calculate based on R2R; + +### Signals Overlap + +how to handle signals overlaps. diff --git a/xStrategies/XST_VBM15M/Docs/report.md b/xStrategies/XST_VBM15M/Docs/report.md new file mode 100644 index 0000000..b668213 --- /dev/null +++ b/xStrategies/XST_VBM15M/Docs/report.md @@ -0,0 +1,66 @@ +# XST_SR15M + +## Report 1 + +### Makret + +ETHUSDT + +### Exchange + +Kucoin + +### Time Frame + +15min + +### Start Date + +23 april 2023 | 17:30 + +### End Date + +18 may 2023 | 14:45 + +### Risk to Reward + +1:1.5 + +### Reports + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | x | | | +| 2 | Short | | x | | +| 3 | Short | | x | Close in Loss Before Next Trader | +| 4 | Short | x | | | +| 5 | Short | x | | Close in Profit Before Next Trade | +| 6 | Short | | x | | +| 7 | Short | | x | | +| 8 | Short | x | | | +| 9 | Long | X | | | +| 10 | Long | | x | Close in Loss Before next Trade | +| 11 | Long | | x | | +| 12 | Long | x | | Close in Profit Before Next Trade | +| 13 | Long | x | | Close in Profit Before Next Trade | +| 14 | Long | x | | | +| 15 | Long | | x | | +| 16 | Long | x | | | +| 17 | Long | | x | | +| 18 | Long | | x | | +| 19 | Long | | x | | +| 20 | Long | | | Open | + +#### Signals lts + +| Type | Count | TPs | SLs | +| :-: | :-: | :-: | :-: | +| Shorts | 8 | 4 | 4 | +| Longs | 12 | 5 | 6 | 1 open +| Total | 20 | 9 | 11 | + +#### Analysis + +per trade volume: 10$ +total lose: 110$ +total reward: 135$ diff --git a/xStrategies/XST_VBM15M/xst_vbm15m.pine b/xStrategies/XST_VBM15M/xst_vbm15m.pine new file mode 100644 index 0000000..9d18e7d --- /dev/null +++ b/xStrategies/XST_VBM15M/xst_vbm15m.pine @@ -0,0 +1,295 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center XTrade VBM15M Strategy +// --------------------------------------------- +// in this strategy i must use: +// - Price Action Candle Recognition; +// - VBM Buy and Sell; +// - Multpile Strategies Oscillator; +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm XTrade VBM15M Strategy", shorttitle = "XTS_VBM15M", overlay = true) + +// +// START Inputs .... +// +// +// Determines Show Signals or not ... +showSignals = input.bool(defval = true, title = "Show Signals", group = "Strategy") +showStopLosses = input.bool(defval = true, title = "Show Stop Losses", group = "Strategy") + +// +// Show Signals based on their types ... +showLongSignals = input.bool(defval = true, title = "Show Long Signals", group = "Signals") +showShortSignals = input.bool(defval = true, title = "Show Short Signals", group = "Signals") + +// +// Show Stop Losses based on their types ... +swingLoopback = input.int(defval = 7, title = "Swing Loopback Period", group = "Stop Loss") +showLongStopLosses = input.bool(defval = true, title = "Show Long Stop Losses", group = "Stop Loss") +showShortStopLosses = input.bool(defval = true, title = "Show Short Stop Losses", group = "Stop Loss") +// +// END Inputs .... +// + +// +// START Functions .... +// +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +// Retrieve Specific Candle Height (based on low and high) ... +getCandleRange() => + high - low + +// +// Retrieve Candle Ranges Thirs Section ... +getCandleThird() => + getCandleRange() / 3 + +// +// Determines a Candle is Bullish or not ... +isBullishCandle() => + close > low + (getCandleThird() * 2) + +// +// Determines a Candle is Bearish or not ... +isNeutralCandle() => + close < low + (getCandleThird() * 2) and close > low + getCandleThird() + +// +// Determines a Candle is Neutral or not ... +isBearishCandle() => + close < low + getCandleThird() +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +////////////////////// +// START MPS HIS +////////////////////// +// +biggest(series) => + max = 0.0 + max := nz(max[1], series) + if series > max + max := series + max +////////////////////// +// END MPS HIS +////////////////////// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var shortColor = color.red +var longColor = color.lime + +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +var bullishColor = color.lime +var bullishShape = shape.arrowup +var bullishTitle = "Bullish" +var bullishType = 1 + +// +var bearishColor = color.red +var bearishShape = shape.arrowdown +var bearishTitle = "Bearish" +var bearishType = -1 + +// +var neutralColor = color.gray +var neutralShape = shape.circle +var neutralTitle = "Neutral" +var neutralType = 0 + +// +candleType = isBullishCandle() ? bullishType : isNeutralCandle() ? neutralType : isBearishCandle() ? bearishType : neutralType + +// +prevCandleType = not na(candleType[1]) ? candleType[1] : neutralType + +// +candleNeighborhoodBaseType = prevCandleType + candleType +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +////////////////////// +// START VBM Buy Sell +////////////////////// +// +VBMBSFactor = 4 +VBMBSPd = 7 + +// +VBMBSUp = hl2 - (VBMBSFactor * ta.atr(VBMBSPd)) +VBMBSDown = hl2 + (VBMBSFactor * ta.atr(VBMBSPd)) + +// +// Trend Up ... +float VBMBSTrendUp = na +VBMBSTrendUp := close[1] > VBMBSTrendUp[1] ? math.max(VBMBSUp, VBMBSTrendUp[1]) : VBMBSUp + +// +// Trend Down ... +float VBMBSTrendDown = na +VBMBSTrendDown := close[1] < VBMBSTrendDown[1] ? math.min(VBMBSDown, VBMBSTrendDown[1]) : VBMBSDown + +// +float VBMBSTrend = na +VBMBSTrend := close > VBMBSTrendDown[1] ? 1 : close < VBMBSTrendUp[1] ? -1 : nz(VBMBSTrend[1], 1) + +// +VBMBSMACD = VBMBSTrend == 1 ? VBMBSTrendUp : VBMBSTrendDown + +// +VBMBSLinecolor = VBMBSTrend == 1 ? bullishColor : bearishColor + +// +VBMBSUpArrow = ta.cross(close, VBMBSMACD) and close > VBMBSMACD +VBMBSDownArrow = ta.cross(VBMBSMACD, close) and close < VBMBSMACD + +// +VBMBSLongSignal = VBMBSTrend == 1 and VBMBSTrend[1] == -1 ? VBMBSTrend : na +VBMBSHasLongSignal = not na (VBMBSLongSignal) + +// +VBMBSShortSignal = VBMBSTrend == -1 and VBMBSTrend[1] == 1 ? VBMBSTrend : na +VBMBSHasShortSignal = not na (VBMBSShortSignal) + +// +VBMBSHasSignal = VBMBSHasLongSignal or VBMBSHasShortSignal +////////////////////// +// END VBM Buy Sell +////////////////////// + +////////////////////// +// START MPS HIS +////////////////////// +// +MPSScale = 75.0 + +// +// Momentum ... +MPSLengthM = 17 +MPSSrcM = close + +// +MPSLength = 17 +MPSSrc = close + +// +// Momentum ... +MPSSz = ta.linreg(MPSSrcM - math.avg(math.avg(ta.highest(high, MPSLengthM), ta.lowest(low, MPSLengthM)), ta.sma(close, MPSLengthM)), MPSLengthM, 0) +MPSNi = biggest(MPSSz) + +// +// Momentum Conditions ... +MPSSc1 = MPSSz >= 0 +MPSSc2 = MPSSz < 0 +MPSSc3 = MPSSz >= MPSSz[1] +MPSSc4 = MPSSz < MPSSz[1] + +// +// Momentum Identifiers ... +isMPSMomentumBullish = (MPSSc1 and MPSSc3) or (MPSSc1 and MPSSc4) +isMPSMomentumBearish = (MPSSc2 and MPSSc4) or (MPSSc2 and MPSSc3) +////////////////////// +// END MPS HIS +////////////////////// + +//////////////////////////// +// START Last Market Price +//////////////////////////// +// +lastMarketLowest = ta.lowest(low, swingLoopback) +lastMarketLowest2 = ta.lowest(low, swingLoopback * 2) +lastMarketLowest3 = ta.lowest(low, swingLoopback * 3) + +// +lastMarketHighest = ta.highest(high, swingLoopback) +lastMarketHighest2 = ta.highest(high, swingLoopback * 2) +lastMarketHighest3 = ta.highest(high, swingLoopback * 3) +//////////////////////////// +// END Last Market Price +//////////////////////////// + +/////////////////////// +// START Strategy ... +/////////////////////// +// +canShowStopLoss = showSignals and showStopLosses and (showLongSignals or showShortSignals) and (showLongStopLosses or showShortStopLosses) +canShowLongStopLoss = canShowStopLoss and showLongStopLosses // and not na(ATRSLLongStopLoss) +canShowShortStopLoss = canShowStopLoss and showShortStopLosses // and not na(ATRSLShortStopLoss) + +// +hasSignal = VBMBSHasSignal + +// +hasLongSignal = hasSignal and isBullishCandle() and VBMBSHasLongSignal and isMPSMomentumBullish +longSignal = hasLongSignal ? VBMBSLongSignal : na +float longStopLoss = lastMarketLowest + +// +hasShortSignal = hasSignal and isBearishCandle() and VBMBSHasShortSignal and isMPSMomentumBearish +shortSignal = hasShortSignal ? VBMBSShortSignal : na +float shortStopLoss = lastMarketHighest + +// +canShowSignal = showSignals and (showLongSignals or showShortSignals) +canShowLongSignal = canShowSignal and showLongSignals and hasLongSignal +canShowShortSignal = canShowSignal and showShortSignals and hasShortSignal +/////////////////////// +// END Strategy ... +/////////////////////// +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Signals ... +plotshape(canShowLongSignal ? longSignal : na, title = "Long Signal", color = longColor, location = location.belowbar, style = shape.triangleup, size = size.normal) +plotshape(canShowShortSignal ? shortSignal : na, title = "Short Signal", color = shortColor, location = location.abovebar, style = shape.triangledown, size = size.normal) + +// +// Stop Losses ... +plot(series = canShowLongStopLoss ? longStopLoss : na, color = color.fuchsia, linewidth = 1, style = plot.style_stepline, title = "Long Stop Loss") +plot(series = canShowShortStopLoss ? shortStopLoss : na, color = color.aqua, linewidth = 1, style = plot.style_stepline, title = "Short Stop Loss") +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(hasSignal, "XST_SHULL5M > Signal") +alertcondition(hasLongSignal, "XST_SHULL5M > Long Signal") +alertcondition(hasShortSignal, "XST_SHULL5M > Short Signal") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +////////////////////////////////////////////////////// diff --git a/xStrategies/XTS_SHULL5M/Docs/XTS_SHULL5M.md b/xStrategies/XTS_SHULL5M/Docs/XTS_SHULL5M.md new file mode 100644 index 0000000..a7422eb --- /dev/null +++ b/xStrategies/XTS_SHULL5M/Docs/XTS_SHULL5M.md @@ -0,0 +1,51 @@ +# Hull Scalping (XTS_SHULL5M) + +## Setup + +- **TF**: 5m +- **Asset**: AAPL +- **R2R**: 1:1.5 +- **Indicators**: + - Hull Trend (jaggedsoft): + - Change Length to 23; +- **Oscillators**: + - Hull Butterfly Oscillator (LuxAlgo): + - Change Bullish Dot to Columns; + - Change Bearish Dot to Columns; + - Change Length to 11; + +## Using the Strategy + +### Long/Buy Conditions + +- OSC gives Bullish Reversal Signal; +- OSC Wait's 1 bar to confirmation; +- HT Ind gives Buy Signal; +- Market forms a Bullish Candle; + +#### Long SL + +place sl at prev MArket lowest + +#### Long TP + +calculate based on R2R; + +### Short/Sell Conditions + +- OSC gives Bearish Reversal Signal; +- OSC Wait's 1 bar to confirmation; +- HT Ind gives Sell Signal; +- Market forms a Bearish Candle; + +#### Short SL + +place sl at prev market highest; + +#### Short TP + +calculate based on R2R; + +### Signals Overlap + +how to handle signals overlaps. diff --git a/xStrategies/XTS_SHULL5M/Docs/report.md b/xStrategies/XTS_SHULL5M/Docs/report.md new file mode 100644 index 0000000..dc83ca2 --- /dev/null +++ b/xStrategies/XTS_SHULL5M/Docs/report.md @@ -0,0 +1,67 @@ +# XST_SR15M + +## Report 1 + +### Makret + +ETHUSDT + +### Exchange + +Kucoin + +### Time Frame + +15min + +### Start Date + +24 april 2023 | 01:15 + +### End Date + +18 may 2023 | 14:45 + +### Risk to Reward + +1:1.5 + +### Reports + +| ID | Position Type | TP | SL | Description | +| :--: | :-----------: | :--: | :--: | :---------- | +| 1 | Short | | | | +| 2 | Short | | | | +| 3 | Short | | | | +| 4 | Short | | | | +| 5 | Short | | | | +| 6 | Short | | | | +| 7 | Short | | | | +| 8 | Short | | | | +| 9 | Short | | | | +| 10 | Long | | | | +| 11 | Long | | | | +| 12 | Long | | | | +| 13 | Long | | | | +| 14 | Long | | | | +| 15 | Long | | | | +| 16 | Long | | | | +| 17 | Long | | | | +| 18 | Long | | | | +| 19 | Long | | | | +| 20 | Long | | | | +| 21 | Long | | | | + +#### Signals Results + +| Type | Count | TPs | SLs | +| :-: | :-: | :-: | :-: | +| Shorts | 9 | 4 | 5 | +| Longs | 12 | 7 | 5 | +| Total | 21 | 11 | 10 | + +#### Analysis + +per trade volume: 10$ +total spending: 210$ +total comeback: 165$ diff --git a/xStrategies/XTS_SHULL5M/xst_shull5m.pine b/xStrategies/XTS_SHULL5M/xst_shull5m.pine new file mode 100644 index 0000000..559ff36 --- /dev/null +++ b/xStrategies/XTS_SHULL5M/xst_shull5m.pine @@ -0,0 +1,234 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center XTrade SHULL5M Strategy +// --------------------------------------------- +// in this strategy i must use: +// - Price Action Candle Recognition; +// - Hull Trend; +// - Hull Butterfly Oscillator; +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// + +// +//@version=5 +indicator(title="SaherElm XTrade SHULL5M Strategy", shorttitle = "XST_SHULL5M", overlay = true) + +// +// START Inputs .... +// +// +// Determines Show Signals or not ... +showSignals = input.bool(defval = true, title = "Show Signals", group = "Strategy") +showStopLosses = input.bool(defval = true, title = "Show Stop Losses", group = "Strategy") + +// +// Show Signals based on their types ... +showLongSignals = input.bool(defval = true, title = "Show Long Signals", group = "Signals") +showShortSignals = input.bool(defval = true, title = "Show Short Signals", group = "Signals") + +// +// Show Stop Losses based on their types ... +showLongStopLosses = input.bool(defval = true, title = "Show Long Stop Losses", group = "Stop Loss") +showShortStopLosses = input.bool(defval = true, title = "Show Short Stop Losses", group = "Stop Loss") +// +// END Inputs .... +// + +// +// START Functions .... +// +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +// Retrieve Specific Candle Height (based on low and high) ... +getCandleRange() => + high - low + +// +// Retrieve Candle Ranges Thirs Section ... +getCandleThird() => + getCandleRange() / 3 + +// +// Determines a Candle is Bullish or not ... +isBullishCandle() => + close > low + (getCandleThird() * 2) + +// +// Determines a Candle is Bearish or not ... +isNeutralCandle() => + close < low + (getCandleThird() * 2) and close > low + getCandleThird() + +// +// Determines a Candle is Neutral or not ... +isBearishCandle() => + close < low + getCandleThird() +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +/////////////////////// +// START Hull Trend ... +/////////////////////// +// +HUTRHma(src, length)=> + ta.wma((2 * ta.wma(src, length / 2)) - ta.wma(src, length), math.round(math.sqrt(length))) + +// +HUTRHma3(src, length)=> + p = length / 2 + ta.wma(ta.wma(close, p / 3) * 3 - ta.wma(close, p / 2) - ta.wma(close, p) ,p) +/////////////////////// +// END Hull Trend ... +/////////////////////// +// +// END Functions .... +// + +// +// START Calculations .... +// +// +var shortColor = color.red +var longColor = color.lime + +////////////////////////////// +// START Price Action Candles +////////////////////////////// +// +var bullishColor = color.lime +var bullishShape = shape.arrowup +var bullishTitle = "Bullish" +var bullishType = 1 + +// +var bearishColor = color.red +var bearishShape = shape.arrowdown +var bearishTitle = "Bearish" +var bearishType = -1 + +// +var neutralColor = color.gray +var neutralShape = shape.circle +var neutralTitle = "Neutral" +var neutralType = 0 + +// +candleType = isBullishCandle() ? bullishType : isNeutralCandle() ? neutralType : isBearishCandle() ? bearishType : neutralType + +// +prevCandleType = not na(candleType[1]) ? candleType[1] : neutralType + +// +candleNeighborhoodBaseType = prevCandleType + candleType +///////////////////////////// +// END Price Action Candles +///////////////////////////// + +/////////////////////// +// START Hull Trend ... +/////////////////////// +// +HUTRSrc = hl2 +HUTRLength = 23 + +// +HUTRA = HUTRHma(HUTRSrc, HUTRLength) +HUTRB = HUTRHma3(HUTRSrc, HUTRLength) +HUTRColor = HUTRB > HUTRA ? color.lime : color.red + +// +HUTRCrossDown = HUTRA > HUTRB and HUTRA[1] < HUTRB[1] +HUTRCrossUp = HUTRB > HUTRA and HUTRB[1] < HUTRA[1] + +// +HUTRLongSignal = HUTRCrossUp ? HUTRA : na +HUTRShortSignal = HUTRCrossDown ? HUTRA : na + +// +HUTRHasSignal = not na(HUTRLongSignal) or not na(HUTRShortSignal) +HUTRHasLongSignal = HUTRHasSignal and not na(HUTRLongSignal) +HUTRHasShortSignal = HUTRHasSignal and not na(HUTRShortSignal) + +// +// plotshape(HUTRLongSignal, location = location.belowbar, style = shape.labelup, color = color.green, size = size.tiny, text = "Buy", textcolor = color.white) +// plotshape(HUTRShortSignal, location = location.abovebar, style = shape.labeldown, color = color.red, size = size.tiny, text = "Sell", textcolor = color.white) +/////////////////////// +// END Hull Trend ... +/////////////////////// + +//////////////////////////// +// START Hull Butterfly ... +//////////////////////////// +//////////////////////////// +// END Hull Butterfly ... +//////////////////////////// + +/////////////////////// +// START Strategy ... +/////////////////////// +// +canShowStopLoss = showSignals and showStopLosses and (showLongSignals or showShortSignals) and (showLongStopLosses or showShortStopLosses) +canShowLongStopLoss = canShowStopLoss and showLongStopLosses // and not na(ATRSLLongStopLoss) +canShowShortStopLoss = canShowStopLoss and showShortStopLosses // and not na(ATRSLShortStopLoss) + +// +hasSignal = HUTRHasSignal + +// +hasLongSignal = hasSignal and isBullishCandle() and HUTRHasLongSignal +longSignal = hasLongSignal ? HUTRLongSignal : na +float longStopLoss = na + +// +hasShortSignal = hasSignal and isBearishCandle() and HUTRHasShortSignal +shortSignal = hasShortSignal ? HUTRShortSignal : na +float shortStopLoss = na + +// +canShowSignal = showSignals and (showLongSignals or showShortSignals) +canShowLongSignal = canShowSignal and showLongSignals and hasLongSignal +canShowShortSignal = canShowSignal and showShortSignals and hasShortSignal +/////////////////////// +// END Strategy ... +/////////////////////// +// +// END Calculations .... +// + +// +// START Plots .... +// +// +// Signals ... +plotshape(canShowLongSignal ? longSignal : na, title = "Long Signal", color = longColor, location = location.belowbar, style = shape.triangleup, size = size.normal) +plotshape(canShowShortSignal ? shortSignal : na, title = "Short Signal", color = shortColor, location = location.abovebar, style = shape.triangledown, size = size.normal) + +// +// Stop Losses ... +plot(series = canShowLongStopLoss ? longStopLoss : na, color = color.fuchsia, linewidth = 1, style = plot.style_stepline, title = "Long Stop Loss") +plot(series = canShowShortStopLoss ? shortStopLoss : na, color = color.aqua, linewidth = 1, style = plot.style_stepline, title = "Short Stop Loss") +// +// END Plots .... +// + +// +// START Alerts ... +// +alertcondition(hasSignal, "XST_SHULL5M > Signal") +alertcondition(hasLongSignal, "XST_SHULL5M > Long Signal") +alertcondition(hasShortSignal, "XST_SHULL5M > Short Signal") +// +// END Alerts ... +// + +////////////////////////////////////////////////////// +// TODOS: +// ------- +// - [] +//////////////////////////////////////////////////////