Candle Patterns 10 [BUY/SELL Auto] β Strategy by jolieeden123
By version
Performance Metrics
- Author: version
- Symbol: OANDA:EURUSD
- Timeframe: 15 minutes
- Net P&L: +6.83 USD (+0.07%)
- Win Rate: 36.2%
- Profit Factor: 1.056
- Max Drawdown: 15.59 USD (0.16%)
- Total Trades: 229
Description
π’ Hammerπ’ Bull Engulfingπ’ Morning Starπ’ Bull Marubozuπ’ 3 White Soldiersπ΄ Shooting Starπ΄ Bear Engulfingπ΄ Evening Starπ΄ Bear Marubozuπ΄ 3 Black CrowsCΓ‘ch paste an toΓ n (trΓ‘nh mαΊ₯t kΓ½ tα»±):Click link tαΊ£i fileMα» file bαΊ±ng Notepad β Ctrl+A β Ctrl+CTradingView β Pine Editor β Open β New blank strategyCtrl+A trong editor β Delete β Ctrl+VSave β Add to chartNαΊΏu vαΊ«n bΓ‘o lα»i, gα»i mΓ¬nh:TΓͺn file Δang dΓΉng (clean / multi_timeframe / 15min?)Sα» dΓ²ng + nα»i dung lα»i (vΓ dα»₯: line 67: Could not find function ...)HoαΊ·c screenshot console phΓa dΖ°α»i Pine EditorMΓ¬nh cαΊ§n thΓ΄ng tin lα»i cα»₯ thα» mα»i fix chΓnh xΓ‘c Δược.//version=6strategy("Candle Patterns Auto-Detect [10 Patterns + BUY/SELL]", shorttitle = "Candles Auto", overlay = true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, pyramiding = 0, max_labels_count = 500, max_lines_count = 200)// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// β Tα»° Δα»NG NHαΊ¬N DIα»N 10 MαΊͺU NαΊΎN + TRIGGER BUY/SELL β// β Rule: SL = ΔΓ‘y/Δα»nh nαΊΏn tΓn hiα»u Β± 0.2ΓATR | TP = R:R 1:2 β// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// INPUTS// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββg_p = "β Pattern Toggles"useHam = input.bool(true, "Hammer (BUY)", group=g_p, inline="r1")useStar = input.bool(true, "Shooting Star (SELL)", group=g_p, inline="r1")useBE = input.bool(true, "Bullish Engulfing (BUY)", group=g_p, inline="r2")useSE = input.bool(true, "Bearish Engulfing(SELL)", group=g_p, inline="r2")useMS = input.bool(true, "Morning Star (BUY)", group=g_p, inline="r3")useES = input.bool(true, "Evening Star (SELL)", group=g_p, inline="r3")useBM = input.bool(true, "Bull Marubozu (BUY)", group=g_p, inline="r4")useSM = input.bool(true, "Bear Marubozu(SELL)", group=g_p, inline="r4")use3WS = input.bool(true, "3 White Soldiers (BUY)", group=g_p, inline="r5")use3BC = input.bool(true, "3 Black Crows (SELL)", group=g_p, inline="r5")useIB = input.bool(false,"Inside Bar (Break BUY/SELL)", group=g_p)useDoji = input.bool(false,"Doji (Wait β no entry)", group=g_p)g_thr = "β Pattern Thresholds (sα» xαΊ₯p xα»)"hamWickRatio = input.float(2.0, "Hammer/Star: Wick Γ· Body β₯", group=g_thr, step=0.1)hamBodyMaxPct = input.float(30, "Hammer/Star: Body% Max", group=g_thr)maruBodyPct = input.float(80, "Marubozu: Body% Min", group=g_thr)soldierBody = input.float(60, "3 Soldiers/Crows: Body% Min", group=g_thr)dojiMaxPct = input.float(5, "Doji: Body% Max", group=g_thr)starCloseRet = input.float(50, "Morning/Evening Star Retrace %", group=g_thr, tooltip="NαΊΏn 3 phαΊ£i ΔΓ³ng cα»a β₯ X% thΓ’n nαΊΏn 1 (ngược chiα»u)")g_filt = "Filters"useVol = input.bool(true, "Volume Filter β₯ NΓMA", group=g_filt)volX = input.float(1.5, "Volume Γ MA", group=g_filt, step=0.1)volLen = input.int(20, "Volume MA Length", group=g_filt)useTrend= input.bool(true, "Trade with EMA200 trend only", group=g_filt, tooltip="BUY chα» khi giΓ‘ > EMA200, SELL chα» khi giΓ‘ 0 ? body1 / range1 * 100 : 0isBull = close > openisBear = close open[1]isBear2 = close[1] 0 and volume >= volMA * volX)trendBullOK = not useTrend or close > emaValtrendBearOK = not useTrend or close 0 and dnWick >= hamWickRatio * body1 and upWick 0 and upWick >= hamWickRatio * body1 and dnWick = open[1] and open = body2// 4) BEARISH ENGULFINGisBearEng = useSE and isBear and isBull2 and close = close[1] and body1 >= body2// 5) MORNING STAR (3 nαΊΏn) β Δα» lα»n β small body β xanh lα»n close β₯ 50% nαΊΏn 1isSmall2 = body2 = midpoint1 + body3 * (starCloseRet - 50) / 100// 6) EVENING STARmidpoint1b = (open[2] + close[2]) / 2isEveningStar = useES and isBull[2] and isSmall2 and isBear and close = maruBodyPct and upWick = maruBodyPct and upWick nαΊΏn trΖ°α»c, body β₯ 60%body1Pct = range1 > 0 ? body1 / range1 * 100 : 0body2Pct = range2 > 0 ? body2 / range2 * 100 : 0body3Pct = range3 > 0 ? body3 / range3 * 100 : 0is3Soldiers = use3WS and isBull and isBull[1] and isBull[2] and close > close[1] and close[1] > close[2] and body1Pct >= soldierBody and body2Pct >= soldierBody and body3Pct >= soldierBody// 10) 3 BLACK CROWSis3Crows = use3BC and isBear and isBear[1] and isBear[2] and close = soldierBody and body2Pct >= soldierBody and body3Pct >= soldierBody// BONUS: DOJI (cαΊ£nh bΓ‘o, khΓ΄ng vΓ o lα»nh)isDoji = useDoji and bodyPct low[1]ibBuy = useIB and isInside[1] and high > high[1] // break high mαΊΉibSell = useIB and isInside[1] and low = cooldownbuySignal = canFire and buyPattern and trendBullOK and volOKsellSignal = canFire and sellPattern and trendBearOK and volOKif buySignal or sellSignal lastSig := bar_index// Pattern name (for display)patternName = isHammer ? "Hammer" : isBullEng ? "Bull Engulf" : isMorningStar ? "Morning Star" : isBullMaru ? "Bull Marubozu" : is3Soldiers ? "3 White Soldiers" : ibBuy ? "Inside Bar Breakβ" : isShoot ? "Shooting Star" : isBearEng ? "Bear Engulf" : isEveningStar ? "Evening Star" : isBearMaru ? "Bear Marubozu" : is3Crows ? "3 Black Crows" : ibSell ? "Inside Bar Breakβ" : isDoji ? "Doji (wait)" : ""// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// ENTRY / TP / SL// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Entry = close (vΓ o tαΊ‘i close nαΊΏn tΓn hiα»u hoαΊ·c vượt high/low theo rule)longEntry = closeshortEntry = close// SL = ΔΓ‘y/Δα»nh nαΊΏn tΓn hiα»u Β± bufferlongSL = low - atr * slBufshortSL = high + atr * slBuf// TP = R:RlongRisk = longEntry - longSLshortRisk = shortSL - shortEntrylongTP = longEntry + longRisk * rrTarshortTP = shortEntry - shortRisk * rrTarlongTPpct = longEntry > 0 ? (longTP - longEntry) / longEntry * 100 : 0longSLpct = longEntry > 0 ? (longSL - longEntry) / longEntry * 100 : 0shortTPpct = shortEntry > 0 ? (shortEntry - shortTP) / shortEntry * 100 : 0shortSLpct = shortEntry > 0 ? (shortSL - shortEntry) / shortEntry * 100 : 0// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// PLOTS// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββplot(useTrend ? emaVal : na, "EMA200", color=color.new(color.orange, 40), linewidth=2)// Pattern labelsif showLbl and patternName != "" bool isBuy = buyPattern label.new(bar_index, isBuy ? low : high, text=patternName, style=isBuy ? label.style_label_up : label.style_label_down, color=isBuy ? color.new(color.green, 20) : color.new(color.red, 20), textcolor=color.white, size=size.small)// BUY/SELL big arrowsplotshape(buySignal, "BUY", shape.labelup, location.belowbar, color=color.green, text="BUY", textcolor=color.white, size=size.normal)plotshape(sellSignal, "SELL", shape.labeldown, location.abovebar, color=color.red, text="SELL", textcolor=color.white, size=size.normal)// Entry/TP/SL linesvar line ln_e = navar line ln_t = navar line ln_s = navar label lb_e = navar label lb_t = navar label lb_s = naif showLevels and (buySignal or sellSignal) line.delete(ln_e) line.delete(ln_t) line.delete(ln_s) label.delete(lb_e) label.delete(lb_t) label.delete(lb_s) float ePr = buySignal ? longEntry : shortEntry float tPr = buySignal ? longTP : shortTP float sPr = buySignal ? longSL : shortSL float pT = buySignal ? longTPpct : shortTPpct float pS = buySignal ? longSLpct : shortSLpct string dir = buySignal ? "BUY" : "SELL" int x2 = bar_index + 30 ln_e := line.new(bar_index, ePr, x2, ePr, color=color.yellow, width=2, extend=extend.right) ln_t := line.new(bar_index, tPr, x2, tPr, color=color.green, width=2, extend=extend.right, style=line.style_dashed) ln_s := line.new(bar_index, sPr, x2, sPr, color=color.red, width=2, extend=extend.right, style=line.style_dashed) lb_e := label.new(x2, ePr, dir + " " + str.tostring(ePr, format.mintick), style=label.style_label_left, color=color.yellow, textcolor=color.black, size=size.small) lb_t := label.new(x2, tPr, "TP " + str.tostring(tPr, format.mintick) + " (" + str.tostring(pT, "#.##") + "%)", style=label.style_label_left, color=color.green, textcolor=color.white, size=size.small) lb_s := label.new(x2, sPr, "SL " + str.tostring(sPr, format.mintick) + " (" + str.tostring(pS, "#.##") + "%)", style=label.style_label_left, color=color.red, textcolor=color.white, size=size.small)// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// PATTERN PANEL// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββvar table panel = table.new(position.top_right, 2, 14, bgcolor=color.new(color.black, 70), border_color=color.gray, border_width=1)if showPanel and barstate.islast table.cell(panel, 0, 0, "β PATTERN STATUS", text_color=color.yellow, bgcolor=color.new(color.purple, 50)) table.cell(panel, 1, 0, "β/β", text_color=color.yellow, bgcolor=color.new(color.purple, 50)) table.cell(panel, 0, 1, "Hammer", text_color=color.white) table.cell(panel, 1, 1, isHammer ? "π’ BUY" : "β", text_color=isHammer ? color.green : color.gray) table.cell(panel, 0, 2, "Shooting Star", text_color=color.white) table.cell(panel, 1, 2, isShoot ? "π΄ SELL": "β", text_color=isShoot ? color.red : color.gray) table.cell(panel, 0, 3, "Bull Engulfing", text_color=color.white) table.cell(panel, 1, 3, isBullEng ? "π’ BUY": "β", text_color=isBullEng ? color.green : color.gray) table.cell(panel, 0, 4, "Bear Engulfing", text_color=color.white) table.cell(panel, 1, 4, isBearEng ? "π΄ SELL":"β", text_color=isBearEng ? color.red : color.gray) table.cell(panel, 0, 5, "Morning Star", text_color=color.white) table.cell(panel, 1, 5, isMorningStar ? "π’ BUY":"β", text_color=isMorningStar ? color.green : color.gray) table.cell(panel, 0, 6, "Evening Star", text_color=color.white) table.cell(panel, 1, 6, isEveningStar ? "π΄ SELL":"β",text_color=isEveningStar ? color.red : color.gray) table.cell(panel, 0, 7, "Bull Marubozu", text_color=color.white) table.cell(panel, 1, 7, isBullMaru ? "π’ BUY":"β",text_color=isBullMaru ? color.green : color.gray) table.cell(panel, 0, 8, "Bear Marubozu", text_color=color.white) table.cell(panel, 1, 8, isBearMaru ? "π΄ SELL":"β",text_color=isBearMaru ? color.red : color.gray) table.cell(panel, 0, 9, "3 White Soldiers", text_color=color.white) table.cell(panel, 1, 9, is3Soldiers ? "π’ BUY":"β",text_color=is3Soldiers ? color.green : color.gray) table.cell(panel, 0, 10, "3 Black Crows", text_color=color.white) table.cell(panel, 1, 10, is3Crows ? "π΄ SELL":"β",text_color=is3Crows ? color.red : color.gray) table.cell(panel, 0, 11, "Doji", text_color=color.white) table.cell(panel, 1, 11, isDoji ? "βΈ WAIT":"β",text_color=isDoji ? color.yellow : color.gray) table.cell(panel, 0, 12, "Body%", text_color=color.white) table.cell(panel, 1, 12, str.tostring(bodyPct,"#.#") + "%", text_color=color.aqua) table.cell(panel, 0, 13, "VolumeΓMA", text_color=color.white) table.cell(panel, 1, 13, str.tostring(volMA > 0 ? volume/volMA : 0,"#.##") + "Γ", text_color=volOK ? color.green : color.red)// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// TRADE PANEL// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββvar table tp = table.new(position.bottom_right, 3, 8, bgcolor=color.new(color.black, 70), border_color=color.gray, border_width=1)if barstate.islast string dir = buySignal ? "π’ BUY" : sellSignal ? "π΄ SELL" : "βΈ WAIT" color dCol = buySignal ? color.green : sellSignal ? color.red : color.gray float ePr = buySignal ? longEntry : sellSignal ? shortEntry : close float tPr = buySignal ? longTP : sellSignal ? shortTP : na float sPr = buySignal ? longSL : sellSignal ? shortSL : na float pT = buySignal ? longTPpct : sellSignal ? shortTPpct : na float pS = buySignal ? longSLpct : sellSignal ? shortSLpct : na table.cell(tp, 0, 0, "TRADE PANEL", text_color=color.yellow, bgcolor=color.new(color.purple,50)) table.cell(tp, 1, 0, "VALUE", text_color=color.yellow, bgcolor=color.new(color.purple,50)) table.cell(tp, 2, 0, "%", text_color=color.yellow, bgcolor=color.new(color.purple,50)) table.cell(tp, 0, 1, "Pattern", text_color=color.white) table.cell(tp, 1, 1, patternName == "" ? "β" : patternName, text_color=color.aqua) table.cell(tp, 2, 1, "Detected", text_color=color.gray) table.cell(tp, 0, 2, "Direction", text_color=color.white) table.cell(tp, 1, 2, dir, text_color=dCol) table.cell(tp, 2, 2, "R:R " + str.tostring(rrTar,"#.#"),text_color=color.white) table.cell(tp, 0, 3, "Entry", text_color=color.white) table.cell(tp, 1, 3, str.tostring(ePr, format.mintick),text_color=color.yellow) table.cell(tp, 2, 3, "Market", text_color=color.gray) table.cell(tp, 0, 4, "π― TP", text_color=color.white) table.cell(tp, 1, 4, na(tPr) ? "β" : str.tostring(tPr, format.mintick), text_color=color.green) table.cell(tp, 2, 4, na(pT) ? "β" : str.tostring(pT,"#.##") + "% β", text_color=color.green) table.cell(tp, 0, 5, "π SL", text_color=color.white) table.cell(tp, 1, 5, na(sPr) ? "β" : str.tostring(sPr, format.mintick), text_color=color.red) table.cell(tp, 2, 5, na(pS) ? "β" : str.tostring(pS,"#.##") + "% β", text_color=color.red) table.cell(tp, 0, 6, "ATR", text_color=color.white) table.cell(tp, 1, 6, str.tostring(atr, "#.####"), text_color=color.aqua) table.cell(tp, 2, 6, "Γ " + str.tostring(slBuf,"#.#") + " buf",text_color=color.gray) table.cell(tp, 0, 7, "Current", text_color=color.white) table.cell(tp, 1, 7, str.tostring(close, format.mintick), text_color=color.aqua) table.cell(tp, 2, 7, "Live", text_color=color.gray)// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// STRATEGY ENTRIES// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββif buySignal strategy.entry("Long", strategy.long) strategy.exit("Long Exit", "Long", stop=longSL, limit=longTP)if sellSignal strategy.entry("Short", strategy.short) strategy.exit("Short Exit", "Short", stop=shortSL, limit=shortTP)// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// ALERTS// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββalertcondition(buySignal, "BUY Pattern", 'BUY {{ticker}} {{interval}} @ {{close}} β pattern detected')alertcondition(sellSignal, "SELL Pattern", 'SELL {{ticker}} {{interval}} @ {{close}} β pattern detected')Show moreYou said: bao loi sua laibao loi sua laiClaude responded: BαΊ‘n Δang paste lαΊ‘i file cΕ© (candlepatternsauto.BαΊ‘n Δang paste lαΊ‘i file cΕ© (candle_patterns_auto.pine) β file nΓ y cΓ³ vαΊ₯n Δα» α» vΓ i chα». MΓ¬nh ΔΓ£ tαΊ‘o bαΊ£n sα»a rα»i (candle_patterns_clean.pine), bαΊ‘n dΓΉng bαΊ£n ΔΓ³ nhΓ©:π₯ candle_patterns_clean.pine β BαΊ£n ΔΓ£ FIX, dΓΉng cΓ‘i nΓ y3 lα»i cα»₯ thα» trong file cΕ© bαΊ‘n vα»«a paste:Lα»i 1 (dΓ²ng ~155): Khai bΓ‘o local bool trong if-block khΓ΄ng an toΓ npine// CΕ¨ (lα»i):if showLbl and patternName != "" bool isBuy = buyPattern β Pine v6 khΓ΄ng cho redefine biαΊΏn trong scope nΓ y label.new(bar_index, isBuy ? low : high, ...)β BαΊ£n clean: tΓ‘ch labelBuy = buyPat and patName != "" ra global scope, khΓ΄ng khai bΓ‘o trong if.Lα»i 2 (dΓ²ng ~110-115): isBull[2] vΓ isBear[2] β truy cαΊp historical value cα»§a biαΊΏn bool dαΊ«n xuαΊ₯tpine// CΕ¨ (Pine v6 khΓ΄ng Ζ°a):isMorningStar = useMS and isBear[2] and ...is3Soldiers = use3WS and isBull and isBull[1] and isBull[2] and ...β BαΊ£n clean: Δα»nh nghΔ©a rΓ΅ rΓ ng bull2 = close[2] > open[2] vΓ bear2 = close[2] = midpoint1 + body3 * (starCloseRet - 50) / 100β BαΊ£n clean: ΔΖ‘n giαΊ£n hΓ³a thΓ nh close >= mid2 (chuαΊ©n theo Δα»nh nghΔ©a Morning Star).TΓ³m lαΊ‘i: Δα»«ng dΓΉng file cΕ© (candle_patterns_auto.pine) nα»―a. TαΊ£i vΓ dΓΉng candle_patterns_clean.pine α» link bΓͺn trΓͺn β ΔΓ£ loαΊ‘i cΓ‘c phαΊ§n lα»i.NαΊΏu file clean vαΊ«n bΓ‘o lα»i khi compile, bαΊ‘n copy nguyΓͺn dΓ²ng bΓ‘o lα»i (cΓ³ chα»― "line XX" hoαΊ·c "Error at...") gα»i mΓ¬nh, mΓ¬nh fix chΓnh xΓ‘c trong 1 phΓΊt.Opus uses your limit faster. Try another model for longer conversations.AskOpus 4.7