
Z-मूल्य आधारित प्रवृत्ति ट्रैकिंग रणनीति प्रवृत्ति के अवसरों को पकड़ने के लिए Z-मूल्य का उपयोग करती है, जो एक सांख्यिकीय संकेतक है, जो कीमतों के अपने चलती औसत से विचलन को मापता है, और मानक विचलन को एक सामान्यीकरण पैमाने के रूप में उपयोग करता है। यह रणनीति अपनी सादगी और प्रभावशीलता के लिए जानी जाती है, विशेष रूप से उन बाजारों में जहां मूल्य आंदोलन अक्सर सममूल्य पर लौटते हैं। कई संकेतकों पर निर्भर जटिल प्रणालियों के विपरीत, Z-मूल्य प्रवृत्ति रणनीति स्पष्ट, सांख्यिकीय रूप से महत्वपूर्ण मूल्य परिवर्तन पर ध्यान केंद्रित करती है, जो उन व्यापारियों के लिए उपयुक्त है जो सरल, सटीक डेटा-संचालित दृष्टिकोण पसंद करते हैं।
इस रणनीति का मूल Z मान की गणना में निहित है। Z मान को वर्तमान मूल्य और उपयोगकर्ता द्वारा परिभाषित लंबाई के मूल्य सूचकांक चलती औसत (EMA) के बीच अंतर की गणना करके और फिर उसी लंबाई के मूल्य मानकों के बीच अंतर को विभाजित करके प्राप्त किया जाता हैः
z = (x - μ) / σ
इसमें, x वर्तमान मूल्य है, μ ईएमए औसत है, और σ मानक अंतर है।
ट्रेडिंग सिग्नल Z मान के आधार पर उत्पन्न होता है जो पूर्वनिर्धारित थ्रेशोल्ड को पार करता हैः
उपरोक्त जोखिमों को निरंतर बाजार विश्लेषण, पैरामीटर अनुकूलन और फीडबैक के आधार पर सावधानीपूर्वक लागू करके नियंत्रित और कम किया जा सकता है।
“Z-value-based trend tracking strategy” अपनी सरल, मजबूत और लचीली विशेषताओं के साथ, ट्रेंडिंग अवसरों को पकड़ने के लिए एक अद्वितीय परिप्रेक्ष्य प्रदान करता है। उचित पैरामीटर सेटिंग, सावधानीपूर्वक जोखिम प्रबंधन और निरंतर अनुकूलन के माध्यम से, यह रणनीति क्वांटिटेटिव व्यापारियों के लिए एक मजबूत सहायक बनने की उम्मीद है।
/*backtest
start: 2023-04-23 00:00:00
end: 2024-04-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PresentTrading
// This strategy employs a statistical approach by using a Z-score, which measures the deviation of the price from its moving average normalized by the standard deviation.
// Very simple and effective approach
//@version=5
strategy('Price Based Z-Trend - strategy [presentTrading]',shorttitle = 'Price Based Z-Trend - strategy [presentTrading]', overlay=false, precision=3,
commission_value=0.1, commission_type=strategy.commission.percent, slippage=1,
currency=currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=10, initial_capital=10000)
// User-definable parameters for the Z-score calculation and bar coloring
tradeDirection = input.string("Both", "Trading Direction", options=["Long", "Short", "Both"]) // User selects trading direction
priceDeviationLength = input.int(100, "Standard Deviation Length", step=1) // Length for standard deviation calculation
priceAverageLength = input.int(100, "Average Length", step=1) // Length for moving average calculation
Threshold = input.float(1, "Threshold", step=0.1) // Number of standard deviations for Z-score threshold
priceBar = input(title='Bar Color', defval=true) // Toggle for coloring price bars based on Z-score
// Z-score calculation based on user input for the price source (typically the closing price)
priceSource = input(close, title="Source")
priceZScore = (priceSource - ta.ema(priceSource, priceAverageLength)) / ta.stdev(priceSource, priceDeviationLength) // Z-score calculation
// Conditions for entering and exiting trades based on Z-score crossovers
priceLongCondition = ta.crossover(priceZScore, Threshold) // Condition to enter long positions
priceExitLongCondition = ta.crossunder(priceZScore, -Threshold) // Condition to exit long positions
longEntryCondition = ta.crossover(priceZScore, Threshold)
longExitCondition = ta.crossunder(priceZScore, -Threshold)
shortEntryCondition = ta.crossunder(priceZScore, -Threshold)
shortExitCondition = ta.crossover(priceZScore, Threshold)
// Strategy conditions and execution based on Z-score crossovers and trading direction
if (tradeDirection == "Long" or tradeDirection == "Both") and longEntryCondition
strategy.entry("Long", strategy.long) // Enter a long position
if (tradeDirection == "Long" or tradeDirection == "Both") and longExitCondition
strategy.close("Long") // Close the long position
if (tradeDirection == "Short" or tradeDirection == "Both") and shortEntryCondition
strategy.entry("Short", strategy.short) // Enter a short position
if (tradeDirection == "Short" or tradeDirection == "Both") and shortExitCondition
strategy.close("Short") // Close the short position
// Dynamic Thresholds Visualization using 'plot'
plot(Threshold, "Dynamic Entry Threshold", color=color.new(color.green, 50))
plot(-Threshold, "Dynamic Short Entry Threshold", color=color.new(color.red, 50))
// Color-coding Z-Score
priceZScoreColor = priceZScore > Threshold ? color.green :
priceZScore < -Threshold ? color.red : color.blue
plot(priceZScore, "Z-Score", color=priceZScoreColor)
// Lines
hline(0, color=color.rgb(255, 255, 255, 50), linestyle=hline.style_dotted)
// Bar Color
priceBarColor = priceZScore > Threshold ? color.green :
priceZScore > 0 ? color.lime :
priceZScore < Threshold ? color.maroon :
priceZScore < 0 ? color.red : color.black
barcolor(priceBar ? priceBarColor : na)