Based on the provided code, I’ll help create an SEO-friendly article analyzing this trading strategy in both Chinese and English.
یہ حکمت عملی قیمت کے عمل کے تجزیہ پر مبنی ہے (قیمت ایکشن) اور بل ولیمز کی K لائن کی تیسری تقسیم کی تھیوری ، موجودہ اور پچھلے K لائن کی قیمتوں کے کھلنے اور قیمتوں کے اختتامی قیمتوں کے درمیان محل وقوع کے تعلقات کا تجزیہ کرکے ، مارکیٹ کے رجحانات کے موڑ اور تسلسل کی نشاندہی کرنے کے لئے ، تاکہ تجارتی سگنل پیدا کریں۔ یہ حکمت عملی مکمل طور پر قیمت کے عمل پر مبنی ہے ، کسی بھی تکنیکی اشارے پر انحصار نہیں کرتی ہے ، اور تجارتی عمل میں جذباتی انحراف کو ختم کرنے کے لئے ایک منظم طریقہ کے ذریعہ۔
اس حکمت عملی کا بنیادی منطق یہ ہے کہ ہر K لائن کے اتار چڑھاؤ کے علاقوں کو تین حصوں میں تقسیم کیا جائے ، اور ان علاقوں میں کھلنے والی قیمتوں اور اختتامی قیمتوں کے مقام کا تجزیہ کرکے مارکیٹ کے رجحانات کا فیصلہ کیا جائے۔ اس میں شامل ہیں:
اس حکمت عملی نے قیمتوں کے رویے کا تجزیہ کرنے کے لئے K لائن کے تیسرے درجے کے جدید طریقوں کا استعمال کرتے ہوئے ، ایک سادہ اور موثر رجحانات کا سراغ لگانے کا نظام تشکیل دیا ہے۔ اگرچہ اس میں کچھ حدود موجود ہیں ، لیکن معقول اصلاح اور خطرے سے متعلق اقدامات کے ذریعہ ، مارکیٹ کے ماحول میں مستحکم منافع حاصل کیا جاسکتا ہے جہاں رجحانات واضح ہیں۔ حکمت عملی کا بنیادی فائدہ اس کے منظم طریقہ کار اور قیمتوں کے رویے کے بارے میں گہرائی سے تجزیہ میں ہے ، جس سے مقدار کی تجارت کے لئے ایک قابل تحسین تحقیقی سمت فراہم کی جاتی ہے۔
/*backtest
start: 2025-01-17 00:00:00
end: 2025-02-15 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("TrinityBar", overlay=true, initial_capital=100000,
default_qty_type=strategy.percent_of_equity, default_qty_value=200)
//─────────────────────────────────────────────────────────────
// Current Bar Thirds Calculations
//─────────────────────────────────────────────────────────────
cur_range = high - low
cur_lowerThird = low + cur_range / 3
cur_upperThird = high - cur_range / 3
//─────────────────────────────────────────────────────────────
// Previous Bar Thirds Calculations
//─────────────────────────────────────────────────────────────
prev_range = high[1] - low[1]
prev_lowerThird = low[1] + prev_range / 3
prev_upperThird = high[1] - prev_range / 3
//─────────────────────────────────────────────────────────────
// Define Bullish Bar Types for Current Bar
//─────────────────────────────────────────────────────────────
is_1_3 = (open <= cur_lowerThird) and (close >= cur_upperThird)
is_3_3 = (open >= cur_upperThird) and (close >= cur_upperThird)
is_2_3 = (open > cur_lowerThird) and (open < cur_upperThird) and (close >= cur_upperThird)
//─────────────────────────────────────────────────────────────
// Define Bearish Bar Types for Current Bar
//─────────────────────────────────────────────────────────────
is_3_1 = (open >= cur_upperThird) and (close <= cur_lowerThird)
is_1_1 = (open <= cur_lowerThird) and (close <= cur_lowerThird)
is_2_1 = (open > cur_lowerThird) and (open < cur_upperThird) and (close <= cur_lowerThird)
//─────────────────────────────────────────────────────────────
// Define Bullish Bar Types for Previous Bar
//─────────────────────────────────────────────────────────────
prev_is_1_3 = (open[1] <= prev_lowerThird) and (close[1] >= prev_upperThird)
prev_is_3_3 = (open[1] >= prev_upperThird) and (close[1] >= prev_upperThird)
prev_is_2_3 = (open[1] > prev_lowerThird) and (open[1] < prev_upperThird) and (close[1] >= prev_upperThird)
//─────────────────────────────────────────────────────────────
// Define Bearish Bar Types for Previous Bar
//─────────────────────────────────────────────────────────────
prev_is_3_1 = (open[1] >= prev_upperThird) and (close[1] <= prev_lowerThird)
prev_is_1_1 = (open[1] <= prev_lowerThird) and (close[1] <= prev_lowerThird)
prev_is_2_1 = (open[1] > prev_lowerThird) and (open[1] < prev_upperThird) and (close[1] <= prev_lowerThird)
//─────────────────────────────────────────────────────────────
// Valid Signal Conditions
//─────────────────────────────────────────────────────────────
// Bullish Signal: If the previous bar is any bullish type (2‑3, 3‑3, or 1‑3)
// and the current bar is either a 1‑3 or a 3‑3 bar.
validBuy = (prev_is_2_3 or prev_is_3_3 or prev_is_1_3) and (is_1_3 or is_3_3)
// Bearish Signal: If the previous bar is any bearish type (2‑1, 1‑1, or 3‑1)
// and the current bar is either a 1‑1 or a 3‑1 bar.
validSell = (prev_is_2_1 or prev_is_1_1 or prev_is_3_1) and (is_1_1 or is_3_1)
//─────────────────────────────────────────────────────────────
// Plot Only the Signal Triangles
//─────────────────────────────────────────────────────────────
plotshape(validBuy, title="Valid Buy", style=shape.triangleup, location=location.belowbar,
color=color.green, size=size.small, text="B")
plotshape(validSell, title="Valid Sell", style=shape.triangledown, location=location.abovebar,
color=color.red, size=size.small, text="S")
//─────────────────────────────────────────────────────────────
// Market Order Execution Based on Signals
//─────────────────────────────────────────────────────────────
if validBuy
// Close any short positions.
strategy.close("Short", comment="")
// If not already long, enter a market long.
if strategy.position_size <= 0
strategy.entry("Long", strategy.long, comment="")
if validSell
// Close any long positions.
strategy.close("Long", comment="")
// If not already short, enter a market short.
if strategy.position_size >= 0
strategy.entry("Short", strategy.short, comment="")