गतिशील ढलान प्रवृत्ति रेखा व्यापार रणनीति

लेखक:चाओझांग, दिनांकः 2024-02-06 11:51:14
टैगः

img

अवलोकन

इस रणनीति का मूल विचार मूल्य प्रवृत्ति दिशा निर्धारित करने के लिए गतिशील ढलान का उपयोग करना और ब्रेकआउट निर्णय के साथ संयोजन में ट्रेडिंग संकेत उत्पन्न करना है। विशेष रूप से, यह गतिशील ढलान की गणना करने के लिए विभिन्न समय अवधि में मूल्य परिवर्तन के आधार पर वास्तविक समय में मूल्य उच्च और निम्न को ट्रैक करता है, और फिर प्रवृत्ति रेखाओं के खिलाफ मूल्य के ब्रेकआउट के अनुसार लंबे और छोटे संकेत निर्धारित करता है।

रणनीतिक सिद्धांत

इस रणनीति के मुख्य चरण इस प्रकार हैंः

  1. उच्चतम और निम्नतम मूल्य का न्याय करें: एक निश्चित चक्र (जैसे 20 बार) के दौरान उच्चतम और निम्नतम कीमतों को ट्रैक करें ताकि यह निर्धारित किया जा सके कि क्या एक नया उच्च या निम्न स्तर तक पहुंच गया है।

  2. गतिशील ढलान की गणना करें: जब कोई नया उच्च या निम्न स्तर प्राप्त होता है तो बार संख्या दर्ज करें और एक निश्चित चक्र (जैसे 9 बार) के बाद नए उच्च/निम्न बिंदु से उच्च/निम्न बिंदु तक गतिशील ढलान की गणना करें।

  3. ग्राफ ट्रेंड लाइनें: गतिशील ढलानों के आधार पर ग्राफ बढ़ते और घटते ट्रेंड लाइनें।

  4. प्रवृत्ति रेखाओं का विस्तार और अद्यतन करें: जब मूल्य प्रवृत्ति रेखाओं के माध्यम से टूटता है, तो प्रवृत्ति रेखाओं का विस्तार और अद्यतन करें।

  5. ट्रेडिंग सिग्नलः प्रवृत्ति रेखाओं के विरुद्ध मूल्य ब्रेकआउट के आधार पर लंबी और छोटी सिग्नल निर्धारित करें।

रणनीति के फायदे

इस रणनीति के लाभों में निम्नलिखित शामिल हैंः

  1. बाजार परिवर्तनों के जवाब में लचीलापन के लिए गतिशील रूप से प्रवृत्ति की दिशा निर्धारित करें।

  2. उचित रूप से रोक को नियंत्रित करें और कम से कम ड्रॉडाउन करें।

  3. स्पष्ट सफलता व्यापार संकेत जो लागू करने में आसान हैं।

  4. मजबूत अनुकूलन क्षमता के लिए अनुकूलन योग्य मापदंड।

  5. स्वच्छ कोड संरचना जिसे समझना और आगे विकसित करना आसान हो।

जोखिम और समाधान

इस रणनीति के साथ कुछ जोखिम भी हैंः

  1. जब रुझान रेंज-बाउंड हो तो लगातार लॉन्ग और शॉर्ट्स करें। फ़िल्टर स्थितियां जोड़ें।

  2. संभावित रूप से अधिक झूठे संकेत पर breakouts. पैरामीटर समायोजित या फिल्टर जोड़ें.

  3. जब बाजार हिंसक रूप से आगे बढ़ता है तो स्टॉप लॉस जोखिम।

  4. सीमित अनुकूलन स्थान और लाभ क्षमता, अल्पकालिक व्यापार के लिए उपयुक्त।

अनुकूलन दिशाएँ

रणनीति के अनुकूलन के लिए निम्नलिखित क्षेत्रों में शामिल हैंः

  1. फ़िल्टर संकेतों के रूप में अधिक तकनीकी संकेतक जोड़ें।

  2. सर्वोत्तम मापदंडों के लिए पैरामीटर संयोजनों का अनुकूलन करें।

  3. जोखिम को कम करने के लिए स्टॉप लॉस रणनीतियों में सुधार करने का प्रयास करें।

  4. प्रवेश मूल्य सीमा को स्वचालित रूप से समायोजित करने के लिए कार्यक्षमता जोड़ें.

  5. अधिक अवसरों की खोज करने के लिए अन्य रणनीतियों के साथ संयोजन करने का प्रयास करें।

सारांश

कुल मिलाकर यह एक कुशल अल्पकालिक रणनीति है जो रुझानों और ट्रेडिंग ब्रेकआउट को निर्धारित करने के लिए गतिशील ढलान का उपयोग करने पर आधारित है। इसमें सटीक निर्णय, नियंत्रित जोखिम हैं, और बाजार में अल्पकालिक अवसरों को पकड़ने के लिए उपयुक्त है। मापदंडों पर आगे के अनुकूलन और फ़िल्टर जोड़ने से जीत की दर और लाभप्रदता में सुधार हो सकता है।


/*backtest
start: 2024-01-06 00:00:00
end: 2024-01-19 00:00:00
period: 2h
basePeriod: 15m
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/
// © pune3tghai

//Originally posted by matsu_bitmex

//tried adding alerts on plots and cleared the chart for a cleaner view.
//Publishing the script in hope of getting it improved by someone else.

//Added strategy code for easier calculations

//Needs work on TP and SL part.

//P.S - THE ORIGINAL CODE IS MUCH BETTER BUT I have tried to be more usable and understandable.

//@version=4
strategy("TrendLines with Alerts", overlay=true)     //study("TrendLines with Alerts", overlay=true)
//update

length1 = input(20)
check = input(9)
//length2 = input(200)


u=0.0
u := u[1]

l=0.0
l := l[1]

y=0.0
y := y[1]

yl=0.0
yl := yl[1]

angle = 0.0
angle := angle[1]

anglel = 0.0
anglel := anglel[1]

if (highest(length1) == high[check] and highest(length1) == highest(length1)[check] and barssince(barstate.isfirst) > check)
    u := high[check]

    
if (lowest(length1) == low[check] and lowest(length1) == lowest(length1)[check] and barssince(barstate.isfirst) > check)
    l := low[check]
    

    
p = round(barssince(u == high[check]))

pl = round(barssince(l == low[check]))

if p == 0 and barssince(barstate.isfirst) > check
    y := high[abs(p[1]+1+check)]
    
if pl == 0 and barssince(barstate.isfirst) > check
    yl := low[abs(pl[1]+1+check)]    
    

if p == 0
    angle := (u-y)/p[1]

if pl == 0
    anglel := (l-yl)/pl[1]

uppertrend = u+ (p * angle)

lowertrend = l+ (pl * anglel)

extendup = if barssince(barstate.isfirst) > check
    uppertrend[check] + angle[check] * check*2

extenddown = if barssince(barstate.isfirst) > check
    lowertrend[check] + anglel[check] * check*2




//plot(l[offset]-u,color=red)
//plot(u[offset]-l,color = green )
plot(lowertrend, color = color.green, transp=30,offset = -check)
plot(extenddown, color = color.green, transp=100)
plot(uppertrend, color = color.red, transp=30, offset = -check)
plot(extendup, color = color.red, transp=100)
//plot(l[offset], color = red)

l1 = lowertrend
l2 = extenddown
u1 = uppertrend
u2 = extendup



l2sell = crossunder(high, l2)
u2buy = crossover(low, u2)
buy1 = (low<=lowertrend) and open>lowertrend and high>lowertrend and close>lowertrend
buy2 = (low<=extenddown) and open>extenddown and high>extenddown and close>extenddown
buy = buy1 or buy2 or u2buy
plotshape(series=buy, title="Buy", style=shape.triangleup, size=size.tiny, color=color.lime, location=location.belowbar)
sell1 = (high>=uppertrend) and open<uppertrend and low<uppertrend and close<uppertrend
sell2 = (high>=extendup) and open<extendup and low<extendup and close<extendup
sell = sell1 or sell2 or l2sell
plotshape(series=sell, title="Sell", style=shape.triangledown, size=size.tiny, color=color.red, location=location.abovebar)

longCond = buy
shortCond = sell

tp = input(0.2, title="Take Profit")

tpbuyval = valuewhen(buy, close, 1) + (tp/100)*(valuewhen(buy, close, 1))
tpsellval = valuewhen(sell, close, 1) - (tp/100)*(valuewhen(sell, close, 1))


sl = input(0.2, title="Stop Loss")
slbuyval = valuewhen(buy, close, 0) - (sl/100)*(valuewhen(buy, close, 0))
slsellval = valuewhen(sell, close, 0) + (sl/100)*(valuewhen(sell, close, 0))
// === STRATEGY ===
tradeType = input("BOTH", title="What trades should be taken : ", options=["LONG", "SHORT", "BOTH", "NONE"])

// stop loss
slPoints = input(defval=0, title="Initial Stop Loss Points (zero to disable)", minval=0)
tpPoints = input(defval=0, title="Initial Target Profit Points (zero for disable)", minval=0)

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>//

testStartYear = input(2019, "Backtest Start Year", minval=1980)
testStartMonth = input(1, "Backtest Start Month", minval=1, maxval=12)
testStartDay = input(1, "Backtest Start Day", minval=1, maxval=31)
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)

testStopYear = input(9999, "Backtest Stop Year", minval=1980)
testStopMonth = input(12, "Backtest Stop Month", minval=1, maxval=12)
testStopDay = input(31, "Backtest Stop Day", minval=1, maxval=31)
testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)

testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false

//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//

//
//set up exit parameters
TP = tpPoints > 0 ? tpPoints : na
SL = slPoints > 0 ? slPoints : na

// Make sure we are within the bar range, Set up entries and exit conditions
if testPeriod() and tradeType != "NONE"
    strategy.entry("long", strategy.long, when=longCond == true and tradeType != "SHORT")
    strategy.entry("short", strategy.short, when=shortCond == true and tradeType != "LONG")
    strategy.close("long", when=shortCond == true and tradeType == "LONG")
    strategy.close("short", when=longCond == true and tradeType == "SHORT")
    strategy.exit("XL", from_entry="long", profit=tpbuyval, loss=slbuyval)
    strategy.exit("XS", from_entry="short", profit=tpsellval, loss=slsellval)

// === /STRATEGY ===
//EOF


////ALERT SYNTEX
//alertcondition(longCond, title="Long", message="Killer Market")
//alertcondition(shortCond, title="Short", message="Poopy Market")

अधिक