हेकिन-अशी पीएसएआर ट्रेंड ट्रेडिंग रणनीति

लेखक:चाओझांग, दिनांकः 2023-09-12 15:16:17
टैगः

यह रणनीति ट्रेंड पहचान और व्यापार संकेतों के लिए हेकिन-अशी कैंडलस्टिक और पीएसएआर संकेतक को जोड़ती है। इसका उद्देश्य मध्यम और दीर्घकालिक रुझानों को पकड़ना है।

रणनीति तर्क:

  1. हेकिन-अशी की गणना करें, खुला, बंद, उच्च और निम्न।

  2. मोमबत्ती का रंग अंतरिम बैल/हरे का रुझान निर्धारित करता है।

  3. पीएसएआर की गणना करें और हेकिन-अशी मूल्य को पार करते समय रुझान उलटने की पहचान करें।

  4. पीएसएआर डाउनट्रेंड पर लॉन्ग और पीएसएआर अपट्रेंड पर शॉर्ट करें।

  5. पीएसएआर नए उच्च/निम्न और त्वरण कारक के आधार पर अनुकूलित होता है।

लाभः

  1. संयोजन सटीकता में सुधार करता है - हेकिन-अशी शोर को फ़िल्टर करता है, पीएसएआर उलटफेर को पकड़ता है।

  2. अनुकूलित पीएसएआर को बदलती बाजार स्थितियों के अनुकूल बनाया जा सकता है।

  3. स्पष्ट नियम पैरामीटर अनुकूलन को लाभान्वित करते हैं।

जोखिमः

  1. हेकिन-अशी और पीएसएआर के पीछे पड़ने से सर्वश्रेष्ठ प्रविष्टियां चूक सकती हैं।

  2. पीएसएआर चंचल रुझानों में झूठे संकेतों के लिए प्रवण है।

  3. सख्त जोखिम प्रबंधन की आवश्यकता है, ताकि वे पिस्तौल से बच सकें।

संक्षेप में, यह रणनीति ट्रेंड संदर्भ के लिए हेकिन-अशी को पीएसएआर के साथ जोड़ती है। देरी और झूठे संकेतों के लिए सावधानी की आवश्यकता होती है लेकिन दीर्घकालिक स्थिर लाभ के लिए अनुकूलन के माध्यम से दूर किया जा सकता है।


/*backtest
start: 2023-08-12 00:00:00
end: 2023-09-11 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("QuantNomad - Heikin-Ashi PSAR Strategy", shorttitle = "HA-PSAR[QN]", overlay = false)

////////////
// INPUTS //

start      = input(0.02, title = "PSAR Start")
increment  = input(0.02, title = "PSAR Increment")
maximum    = input(0.2,  title = "PSAR Max")

start_year  = input(2018, 'Start Year',  input.integer)
start_month = input(1,    'Start Month', input.integer)
start_day   = input(1,    'Start Day',   input.integer)

end_year  = input(2100, 'End Year',  input.integer)
end_month = input(1,    'End Month', input.integer)
end_day   = input(1,    'End Day',   input.integer)

date_start = timestamp(start_year, start_month, start_day, 00, 00)
date_end   = timestamp(end_year,   end_month,   end_day,   00, 00)

// if time is in correct period
time_cond = time >= date_start and time <= date_end

// Calculation HA Values 
haopen  = 0.0
haclose = (open + high + low + close) / 4
haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2
hahigh  = max(high, max(haopen, haclose))
halow   = min(low,  min(haopen, haclose))

// HA colors
hacolor = haclose > haopen ? color.green : color.red

psar        = 0.0 // PSAR
af          = 0.0 // Acceleration Factor
trend_dir   = 0   // Current direction of PSAR
ep          = 0.0 // Extreme point
trend_bars  = 0

sar_long_to_short = trend_dir[1] == 1  and haclose <= psar[1] // PSAR switches from long to short
sar_short_to_long = trend_dir[1] == -1 and haclose >= psar[1] // PSAR switches from short to long

trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long

// Calculate trend direction
trend_dir    := barstate.isfirst[1] and haclose[1] > haopen[1] ? 1 : 
   barstate.isfirst[1] and haclose[1] <= haopen[1] ? -1 : 
   sar_long_to_short ? -1 : 
   sar_short_to_long ?  1 : nz(trend_dir[1])

trend_bars := sar_long_to_short ? -1 : 
              sar_short_to_long ?  1 : 
              trend_dir ==  1   ? nz(trend_bars[1]) + 1 : 
              trend_dir == -1   ? nz(trend_bars[1]) - 1 : 
              nz(trend_bars[1])

// Calculate  Acceleration Factor
af := trend_change ? start : 
   (trend_dir == 1 and hahigh > ep[1]) or  
   (trend_dir == -1 and low < ep[1]) ? 
   min(maximum, af[1] + increment) : 
   af[1]

// Calculate extreme point
ep := trend_change and trend_dir == 1 ? hahigh :  
   trend_change and trend_dir == -1 ? halow : 
   trend_dir == 1 ? max(ep[1], hahigh) : 
   min(ep[1], halow)

// Calculate PSAR
psar := barstate.isfirst[1] and haclose[1] > haopen[1] ? halow[1] : 
   barstate.isfirst[1] and haclose[1] <= haopen[1] ? hahigh[1] : 
   trend_change ? ep[1] :    
   trend_dir == 1 ? psar[1] + af * (ep - psar[1]) : psar[1] - af * (psar[1] - ep) 

plotcandle(haopen, hahigh, halow, haclose, title = "HA", color = hacolor)
plot(psar, style=plot.style_cross, color=trend_dir == 1 ? color.green : color.red,  linewidth = 2)

// Strategy
strategy.entry("long",  true,  when = sar_short_to_long and time_cond)
strategy.entry("short", false, when = sar_long_to_short and time_cond)


अधिक