// ----------------------------- // Inputs // ----------------------------- bull = input.color(color.new(color.green, 0), title = "Bull Color") bear = input.color(color.new(color.red, 0), title = "Bear Color") neutral = input.color(color.new(color.yellow, 0), title = "Neutral Color") show_ma = input.bool(true, title = "Show MA") ma_type = input.string("WMA", title = "MA Type", options=["SMA", "EMA", "RMA", "WMA", "VWMA", "HMA", "TMA"]) ma_source = input.source(close, title = "MA Source") ma_length = input.int(55, title = "MA Length", minval=1) UseGradient = input.bool(true, title = "Use Gradient Colors") stepn = input.int(5, title = "Max Gradient Steps", minval=1)
// Calculate MA and Gradient Color ma = mat(ma_source, ma_length, ma_type) col = f_c_gradientAdvDecPro(ma, ta.ema(ma, 3), stepn, neutral, bear, neutral, bull)
// Custom Alert: Yellow Candle Followed by Higher/Lower Open with Additional Conditions yellowCandle = (UseGradient ? col == color.new(color.yellow, 0) : BodyColor == color.yellow) yellowCandleDetected = yellowCandle[1] // Previous candle was yellow
// New Conditions based on user requirements // For Buy: Previous yellow candle's close < close of candle before yellow candle, and current open > open of yellow candle previousYellowClose = CandleClose[1] // Close of yellow candle previousCloseBeforeYellow = close[2] // Close of the candle before yellow candle currentOpen = open openOfYellowCandle = CandleOpen[1] // Open of yellow candle
buyCondition = yellowCandleDetected and (previousYellowClose < previousCloseBeforeYellow) and (currentOpen > openOfYellowCandle) alertcondition(buyCondition, title="Buy Signal", message="Buy signal: A yellow candle was followed by a candle with a higher open and the yellow candle's close was lower than the previous candle's close.")
// For Sell: Previous yellow candle's close > close of candle before yellow candle, and current open < open of yellow candle sellCondition = yellowCandleDetected and (previousYellowClose > previousCloseBeforeYellow) and (currentOpen < openOfYellowCandle) alertcondition(sellCondition, title="Sell Signal", message="Sell signal: A yellow candle was followed by a candle with a lower open and the yellow candle's close was higher than the previous candle's close.")
// Additional Alerts When a Yellow Candle Appears alertcondition(yellowCandle, title="Yellow Candle Appeared", message="A yellow candle has appeared on the chart.")
// ----------------------------- // Strategy Entry and Exit // -----------------------------
// Strategy Entry based on Buy and Sell Conditions if (buyCondition) strategy.entry("Buy", strategy.long)
if (sellCondition) strategy.entry("Sell", strategy.short)
// Example Exit Conditions (Bạn có thể tùy chỉnh thêm) exitLongCondition = ta.crossunder(ma, ta.ema(ma, 3)) // Exit long when MA crosses under its EMA if (exitLongCondition) strategy.close("Buy")
exitShortCondition = ta.crossover(ma, ta.ema(ma, 3)) // Exit short when MA crosses over its EMA if (exitShortCondition) strategy.close("Sell")
// ----------------------------- // Watermark // ----------------------------- var table Watermark = table.new(position.bottom_left, 1, 1, border_width = 0) if barstate.islast table.cell(Watermark, 0, 0, text="North Star Day Trading - NSDT HAMA Candles Strategy", text_color=color.new(color.white, 95), text_size=size.small, bgcolor=color.new(color.black, 100))
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.