انکولی حرکت پذیری اوسط مقداری حکمت عملی


تخلیق کی تاریخ: 2023-11-17 17:14:36 آخر میں ترمیم کریں: 2023-11-17 17:14:36
کاپی: 0 کلکس کی تعداد: 713
1
پر توجہ دیں
1617
پیروکار

انکولی حرکت پذیری اوسط مقداری حکمت عملی

جائزہ

یہ حکمت عملی ایک متحرک اوسط پر مبنی ہے ، جس میں پیرامیٹرز کو خود بخود ایڈجسٹ کیا جاسکتا ہے ، اور یہ اعلی وقت کے دورانیے میں اتار چڑھاؤ کی منڈیوں کے لئے موزوں ہے۔ یہ خود بخود بہترین پیرامیٹرز کا مجموعہ تلاش کرنے کے قابل ہے ، اور جب قیمت متحرک اوسط سے ٹوٹ جاتی ہے تو تجارتی سگنل پیدا کرتی ہے۔

حکمت عملی کا اصول

اس حکمت عملی میں ٹریڈنگ سگنل کے طور پر خود کو ایڈجسٹ کرنے والی حرکت پذیر اوسط کا استعمال کیا گیا ہے۔ پہلے ، ایک مقررہ مدت کے لئے ایک سادہ حرکت پذیر اوسط (CMA) کا حساب لگایا گیا ہے۔ اس کے بعد ، CMA کے ارد گرد پیرامیٹرز کے مجموعے کی جانچ کی گئی ہے تاکہ یہ معلوم کیا جاسکے کہ کون سا مجموعہ CMA لائن K لائن کی ہستی اور سائے کی لائن سے کم سے کم بار ٹچ کیا گیا ہے۔ آخر میں ، کم سے کم ٹچ ہونے والا CMA سگنل لائن کے طور پر استعمال کیا گیا۔

خاص طور پر ، حکمت عملی سی ایم اے لائنوں ، اعدادوشمار کی اصل لائنوں اور سائے کی لائنوں کو سی ایم اے کی مدت 1 ((CMA_P1) اور 1 ((CMA_M1) کے بعد ان کے رابطوں کی تعداد کی جانچ کرتی ہے۔ اگر سی ایم اے کی رابطے کی تعداد سی ایم اےP1 اور سی ایم اے ایم 1 سے کم ہے تو ، موجودہ سی ایم اے کی مدت برقرار رکھی جائے۔ اگر سی ایم اےP1 کی رابطے کی تعداد کم ہے تو ، سی ایم اے کی مدت 1 کو شامل کریں۔ اگر سی ایم اے ایم 1 کی رابطے کی تعداد کم ہے تو ، سی ایم اے کی مدت 1 کو کم کریں۔ اس طرح سگنل لائن کے طور پر ایک نسبتا smooth ہموار سی ایم اے پایا جاسکتا ہے۔

جب قیمت نیچے سے اوپر کی طرف سے CMA کو توڑتی ہے تو ، خریدنے کا اشارہ پیدا ہوتا ہے۔ جب قیمت اوپر سے نیچے کی طرف سے CMA کو توڑتی ہے تو ، فروخت کا اشارہ پیدا ہوتا ہے۔

طاقت کا تجزیہ

اس طرح کی ایک متحرک اوسط حکمت عملی کے درج ذیل فوائد ہیں:

  1. خودکار طور پر زیادہ سے زیادہ پیرامیٹرز تلاش کریں۔ متحرک اوسط کے دورانیے کو دستی طور پر منتخب کرنے کی ضرورت نہیں ہے۔ حکمت عملی خود بخود مختلف دورانیوں کی جانچ کرتی ہے تاکہ زیادہ سے زیادہ پیرامیٹرز مل سکیں۔

  2. جعلی سگنل کو کم کرنا۔ مستقل دورانیے کی حرکت پذیری اوسط کے مقابلے میں ، موافقت پذیر حرکت پذیری اوسط زیادہ شور کو ختم کرسکتا ہے ، جس سے بہت سے جعلی سگنل کم ہوجاتے ہیں۔

  3. مارکیٹ میں تبدیلیوں کے مطابق ڈھالنا۔ جب مارکیٹ رجحان میں داخل ہونے کے لئے جمع ہوجاتی ہے تو ، متحرک اوسط کا دورانیہ خود بخود بڑھ جاتا ہے تاکہ سگنل پیدا کیا جاسکے۔ جب مارکیٹ رجحان سے جمع ہوجاتی ہے تو ، متحرک اوسط کا دورانیہ خود بخود کم ہوجاتا ہے۔ لہذا حکمت عملی مارکیٹ میں تبدیلیوں کے مطابق متحرک طور پر ڈھال سکتی ہے۔

  4. ٹریڈنگ سسٹم کو آسان بنائیں۔ اس طرح کے موافقت سے پورے ٹریڈنگ سسٹم کو آسان بنایا جاسکتا ہے ، جس میں پیرامیٹرز کو دستی طور پر بہتر بنانے کی ضرورت نہیں ہے۔

  5. توسیع پذیر۔ اس حکمت عملی کے خیالات کو دوسرے اشارے تک پھیلا دیا جاسکتا ہے ، جس میں برن بینڈ ، کے ڈی اور دیگر حکمت عملیوں کو ڈیزائن کیا جاسکتا ہے۔

خطرے کا تجزیہ

اس حکمت عملی کے کچھ خطرات بھی ہیں جن کے بارے میں آگاہ ہونا ضروری ہے:

  1. بیعانہ اختیارات کا خطرہ۔ جب مارکیٹ میں بیعانہ اختیارات کا رجحان ہوتا ہے تو ، جسمانی لائنوں کو منتقل کرنے والی اوسط سے تجاوز کرنے سے قاصر ہے ، جس سے غلط سگنل ملتا ہے۔ اس طرح کے خطرات کو کم کرنے کے لئے فلٹرنگ شرائط کو شامل کرنے کی ضرورت ہے۔

  2. توڑنے کی ناکامی کا خطرہ منتقل اوسط توڑنے کے لئے ہمیشہ نہیں کر سکتے ہیں continuation، کچھ توڑنے کی ناکامی کا خطرہ موجود لہذا توڑنے کی تصدیق کی ضرورت ہے، توڑنے کی کامیابی کی شرح کو یقینی بنانے

  3. رجحان کی واپسی کا خطرہ۔ رجحان کی مارکیٹ میں داخل ہونے کے بعد الٹ جانے کی ضرورت ہے وقت پر سمت تبدیل کریں ، ورنہ نقصان کا سبب بنے گا۔ نقصان کو کنٹرول کرنے کے لئے اسٹاپ نقصان کی شرائط طے کی جاسکتی ہیں۔

  4. پیرامیٹرز کو بہتر بنانے کا خطرہ۔ خود بخود ایڈجسٹ شدہ پیرامیٹرز مقامی اصلاحات میں گر سکتے ہیں ، جس سے واضح طور پر اضافی منتقل اوسط پیدا ہوتا ہے۔ اس مسئلے سے بچنے کے لئے ماڈل کی تشخیص کے طریقوں کو متعارف کرانے کی ضرورت ہے۔

  5. اوور اوپٹیمائزیشن کا خطرہ۔ خود کو ایڈجسٹ کرنے والے ایڈجسٹمنٹ پیرامیٹرز کو زیادہ سے زیادہ بہتر بنایا جاسکتا ہے ، اور ماڈل کی عمومی صلاحیت کو کھو دیا جاتا ہے۔ مختلف مارکیٹ کے ماحول میں طویل وقت کی توثیق کی ضرورت ہوتی ہے ، اور نتائج پر زیادہ انحصار نہیں کیا جاسکتا ہے۔

اصلاح کی سمت

اس طرح کی ایک متحرک اوسط حکمت عملی کو بہتر بنانے کے لئے:

  1. ٹرینڈ بریک کی توثیق کے طریقہ کار کو شامل کریں ، جعلی بریک کو مسلسل توڑنے کے ذریعے فلٹر کریں۔

  2. اسٹاپ نقصان کی حکمت عملی میں اضافہ کریں ، جب قیمت منتقل اوسط کی دوسری طرف واپس آجائے تو اسٹاپ نقصان کریں۔

  3. آپشن فلٹرنگ کے طریقہ کار میں اضافہ کریں تاکہ آپشن مارکیٹ میں غلط سگنلوں سے بچایا جاسکے۔

  4. پیرامیٹرز کو ایڈجسٹ کرنے پر پابندی لگانے کے لئے تشخیصی اشارے متعارف کروائیں ، جیسے آئی سی ، ایل آئی سی ، ایس آئی سی وغیرہ ، تاکہ پیرامیٹرز کو زیادہ سے زیادہ بہتر نہ بنایا جاسکے۔

  5. دوسرے اشارے تک توسیع کریں ، گولڈ فورک ڈیڈ فورک ، بلین بینڈ ، وغیرہ کے مطابق ڈھالنے والی حکمت عملی تیار کریں۔

  6. منتقل اوسط کا حساب لگانے کے طریقہ کار کو بہتر بنانا ، وزن والے منتقل اوسط ، اشاریہ منتقل اوسط وغیرہ کے ساتھ ہموار منتقل اوسط کا استعمال کریں۔

خلاصہ کریں۔

یہ حکمت عملی خود کو ایڈجسٹ کرنے کے لئے منتقل اوسط سائیکل کو ایڈجسٹ کرکے ، بہترین پیرامیٹرز کی تلاش کرتی ہے ، جس سے تجارتی سگنل پیدا ہوتا ہے۔ فکسڈ پیرامیٹرز کے مقابلے میں ، اس سے بہت سارے جھوٹے سگنل کم ہوسکتے ہیں ، مارکیٹ میں تبدیلیوں کے مطابق ڈھال لیا جاسکتا ہے۔ لیکن ہمیں کچھ ممکنہ خطرات سے بھی آگاہ ہونا چاہئے ، حکمت عملی کی تصدیق اور واک فارورڈ کو بہتر بنانے کی ضرورت ہے ، تاکہ اصل تجارت میں مستحکم منافع حاصل کیا جاسکے۔

||

Overview

This strategy is based on moving average, can automatically adjust parameters, and is suitable for wavy markets at high timeframes. It can automatically find the optimal parameter combination and generate trading signals when price breaks through the moving average line.

Strategy Logic

This strategy uses an adaptive moving average as trading signal. First it calculates the simple moving average (CMA) of the specified period (start). Then it tests the CMA parameters around the period, judging which combination has the least touches by candlestick body and wick. Finally it uses the CMA with the least touches as the signal line.

Specifically, the strategy tests the CMA with period plus 1 (CMA_P1) and minus 1 (CMA_M1), counts the number of touches by body and wick. If CMA has less touches than CMA_P1 and CMA_M1, then keep the current period; if CMA_P1 has less touches, then increase the period by 1; if CMA_M1 has less touches, then decrease the period by 1. This finds a relatively smooth CMA as the signal line.

When price breaks through CMA upward, a buy signal is generated; when price breaks through CMA downward, a sell signal is generated.

Advantage Analysis

This adaptive moving average strategy has the following advantages:

  1. Automatically find optimal parameters. No need to manually select moving average period, the strategy will test different periods and find the optimum.

  2. Reduce false signals. Compared with fixed period MA, the adaptive MA can filter out more noise and reduce many false signals.

  3. Adapt to market changes. When market switches from range-bound to trending, the MA period will automatically increase to generate signals; when market switches from trending to range-bound, the MA period will automatically decrease. So the strategy can dynamically adapt to market changes.

  4. Simplify trading system. This adaptive method can simplify the whole trading system without manual parameter optimization.

  5. Good scalability. The concept can be applied to other indicators like adaptive Bollinger Bands, adaptive KD etc.

Risk Analysis

There are also some risks to note for this strategy:

  1. Call option risk. When market has a call option pattern, the candle body may fail to break the MA line, resulting in wrong signals. Filter conditions need to be added to reduce such risk.

  2. Failed breakout risk. MA breakout does not always continuation, some failed breakouts may occur. Breakout validation is needed to ensure high success rate.

  3. Trend reversal risk. Trend reversal after entering the trend needs to be switched timely, otherwise it may cause losses. Stop loss should be set to control the loss.

  4. Parameter optimization risk. Adaptive adjusted parameters may fall into local optimization, resulting in redundant MAs. Model evaluation methods need to be introduced to avoid this problem.

  5. Overfitting risk. Excessive parameter tuning may lead to overfitting and lose the model generalization ability. Prolonged verification in different market environments is needed, not just rely on backtest results.

Improvement Directions

Some directions to improve this adaptive MA strategy:

  1. Add trend breakout validation via consecutive breakouts to filter false breakouts.

  2. Increase stop loss strategy, stop loss when price moves back to the other side of MA.

  3. Add option filter to avoid wrong signals when call option appears.

  4. Introduce evaluation metrics like IC, LIC, SIC etc. to constrain parameter tuning and prevent overfitting.

  5. Expand to other indicators like adaptive golden cross strategy, adaptive Bollinger Bands etc.

  6. Optimize MA calculation by using weighted MA, exponential MA etc. to get smoother MA.

Summary

This strategy generates trading signals by adaptively adjusting the MA period to find optimal parameters. Compared with fixed parameters, it can reduce many false signals and adapt to market changes. But we also need to watch out for potential risks, and do verification and walk-forward optimization before applying it in live trading for steady profits.

[/trans]

حکمت عملی کا ماخذ کوڈ
/*backtest
start: 2022-11-10 00:00:00
end: 2023-11-16 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fondDealer96636

//@version=5

strategy('Automatic Moving Average', overlay=true, max_bars_back=201, pyramiding=0, currency=currency.USD, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000)

// input
start = 20
lookback = input(20, "Sensitivity", tooltip="Low (High Sensitivity), High (Low Sensitivity).\n\nAdjust according to timeframe and asset.")
smoothing = input(3, "Smoothing")
source = input(close, "Source")
startYear = input(2020, "Start year")
resp = 1

in_date_range = time >= timestamp(syminfo.timezone, startYear, 1, 1, 0, 0)

// global
var ix = -1
var mal = array.new_int(0)


// functions
avg(source, len) =>
    sum = 0.0
    for i = 0 to len-1
        sum += source[i]
    sum/len

bull = close > open

wick_touch(x) =>
    bull ? ((close <= x and x <= high) or (low <= x and x <= open)) : ((open <= x and x <= high) or (low <= x and x <= close))

body_touch(x) =>
    bull ? (open < x and x < close) : (close < x and x < open)

touches(t) =>
    touches = 0
    for i = 0 to lookback-1
        touches += t[i] ? 1 : 0
    touches


// local
ix := ix+1
prev_mal = ix >= 1 ? array.get(mal, ix-1) : start

cma = avg(source, prev_mal)
cma_p1 = avg(source, prev_mal+1)
cma_m1 = avg(source, prev_mal-1)

d = touches(wick_touch(cma))
d_p1 = touches(wick_touch(cma_p1))
d_m1 = touches(wick_touch(cma_m1))

d_b = touches(body_touch(cma))
d_p1_b = touches(body_touch(cma_p1))
d_m1_b = touches(body_touch(cma_m1))

any_body_touch = d_b > 0 or d_p1_b > 0 or d_m1_b > 0
no_wick_touch = d <= 0 and d_p1 <= 0 and d_m1 <= 0
wick_maximized = d >= d_p1 and d >= d_m1 ? prev_mal : (d_p1 >= d and d_p1 >= d_m1 ? prev_mal+resp : (d_m1 >= d and d_m1 >= d_p1 ? prev_mal-resp : na))

up = cma > cma[1]
down = cma < cma[1]
against_trend = (up and close < cma) or (down and close > cma)

new_mal = no_wick_touch or against_trend ? prev_mal-resp : (any_body_touch ? prev_mal+resp : wick_maximized)
next_mal = na(new_mal) ? prev_mal : new_mal

array.push(mal, next_mal < 2 ? 2 : (next_mal > 200 ? 200 : next_mal))


// graph
scma = ta.ema(cma, smoothing)

uptrend = scma > scma[1]
downtrend = scma < scma[1]

plot(scma, "Automatic MA", color=uptrend ? color.green : color.red)

uptrending = close > scma and uptrend
downtrending = close < scma and downtrend

defy = not uptrending and not downtrending
defy_cross = defy and body_touch(scma)

barcolor(uptrending ? color.lime : (downtrending ? color.red : (defy_cross ? color.black : color.white)))


// strategy
change_to_uptrend = uptrending and downtrend[1]
change_to_downtrend = downtrending and uptrend[1]

long = in_date_range and change_to_uptrend
short = in_date_range and change_to_downtrend

if long
    strategy.entry("Long", strategy.long)
if short
    strategy.entry("Short", strategy.short)