// ----------------------------- // 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 אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.