Binance Square

pinescript

7 次瀏覽
4 討論中
chamod wenushka
--
查看原文
//@version=5 indicator("買入下跌策略 (任意幣種)", overlay=true) // === 輸入 === stochKLen = input.int(14, "隨機指標 %K 長度") stochDLen = input.int(3, "隨機指標 %D 長度") stochSmooth = input.int(3, "隨機指標平滑") buyZone = input.float(0.98, "買入區域 % (例如 0.98 = 低於 2%)", step=0.01) tpMultiplier = input.float(1.05, "獲利了結 % (例如 1.05 = 高於 5%)", step=0.01) slMultiplier = input.float(0.97, "止損 % (例如 0.97 = 低於 3%)", step=0.01) // === 隨機振盪器 === k = ta.sma(ta.stoch(close, high, low, stochKLen), stochSmooth) d = ta.sma(k, stochDLen) // === 動態水平 === var float entryPrice = na var bool inTrade = false // === 買入條件 === buyCondition = ta.crossover(k, d) and k < 80 if (buyCondition and not inTrade) entryPrice := close inTrade := true // === 獲利和止損水平 === takeProfitPrice = entryPrice * tpMultiplier stopLossPrice = entryPrice * slMultiplier // === 退出條件 === exitConditionTP = inTrade and close >= takeProfitPrice exitConditionSL = inTrade and close <= stopLossPrice if (exitConditionTP or exitConditionSL) inTrade := false entryPrice := na // === 繪圖 === plotshape(buyCondition and not inTrade, title="買入信號", location=location.belowbar, color=color.green, style=shape.labelup, text="買入") plotshape(exitConditionTP, title="獲利了結", location=location.abovebar, color=color.red, style=shape.labeldown, text="TP") plotshape(exitConditionSL, title="止損", location=location.abovebar, color=color.orange, style=shape.labeldown, text="SL") plot(entryPrice, title="進場價格", color=color.new(color.green, 60)) plot(inTrade ? takeProfitPrice : na, title="獲利了結水平", color=color.new(color.red, 60), style=plot.style_line) plot(inTrade ? stopLossPrice : na, title="止損水平", color=color.new(color.orange, 60), style=plot.style_line) #pinescript #Write2Earn
//@version=5
indicator("買入下跌策略 (任意幣種)", overlay=true)

// === 輸入 ===
stochKLen = input.int(14, "隨機指標 %K 長度")
stochDLen = input.int(3, "隨機指標 %D 長度")
stochSmooth = input.int(3, "隨機指標平滑")

buyZone = input.float(0.98, "買入區域 % (例如 0.98 = 低於 2%)", step=0.01)
tpMultiplier = input.float(1.05, "獲利了結 % (例如 1.05 = 高於 5%)", step=0.01)
slMultiplier = input.float(0.97, "止損 % (例如 0.97 = 低於 3%)", step=0.01)

// === 隨機振盪器 ===
k = ta.sma(ta.stoch(close, high, low, stochKLen), stochSmooth)
d = ta.sma(k, stochDLen)

// === 動態水平 ===
var float entryPrice = na
var bool inTrade = false

// === 買入條件 ===
buyCondition = ta.crossover(k, d) and k < 80

if (buyCondition and not inTrade)
entryPrice := close
inTrade := true

// === 獲利和止損水平 ===
takeProfitPrice = entryPrice * tpMultiplier
stopLossPrice = entryPrice * slMultiplier

// === 退出條件 ===
exitConditionTP = inTrade and close >= takeProfitPrice
exitConditionSL = inTrade and close <= stopLossPrice

if (exitConditionTP or exitConditionSL)
inTrade := false
entryPrice := na

// === 繪圖 ===
plotshape(buyCondition and not inTrade, title="買入信號", location=location.belowbar, color=color.green, style=shape.labelup, text="買入")
plotshape(exitConditionTP, title="獲利了結", location=location.abovebar, color=color.red, style=shape.labeldown, text="TP")
plotshape(exitConditionSL, title="止損", location=location.abovebar, color=color.orange, style=shape.labeldown, text="SL")

plot(entryPrice, title="進場價格", color=color.new(color.green, 60))
plot(inTrade ? takeProfitPrice : na, title="獲利了結水平", color=color.new(color.red, 60), style=plot.style_line)
plot(inTrade ? stopLossPrice : na, title="止損水平", color=color.new(color.orange, 60), style=plot.style_line)
#pinescript #Write2Earn
登入探索更多內容
探索最新的加密貨幣新聞
⚡️ 參與加密貨幣領域的最新討論
💬 與您喜愛的創作者互動
👍 享受您感興趣的內容
電子郵件 / 電話號碼