संसाधन लोड हो रहा है... लोड करना...

बहुस्तरीय संतुलित मात्रात्मक व्यापारिक रणनीति

लेखक:चाओझांग, दिनांकः 2024-10-14 11:23:45
टैगःएमएसीडीआरएसआईईएमए

img

अवलोकन

मल्टी-लेवल बैलेंस्ड क्वांटिटेटिव ट्रेडिंग रणनीति एक जटिल ट्रेडिंग सिस्टम है जो कई तकनीकी संकेतकों और मूल्य स्तरों को जोड़ती है। यह रणनीति विभिन्न मूल्य सीमाओं पर विभिन्न ट्रेडिंग रणनीति को लागू करने के लिए एमएसीडी, आरएसआई, ईएमए और बोलिंगर बैंड जैसे संकेतकों का उपयोग करती है।

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

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

  1. बाजार के रुझानों और गति को निर्धारित करने के लिए एमएसीडी, आरएसआई और ईएमए संकेतकों का उपयोग करना।
  2. प्रमुख समर्थन और प्रतिरोध स्तरों की पहचान करने के लिए बोलिंगर बैंड और फिबोनाची रिट्रेसमेंट स्तरों का उपयोग करना।
  3. क्रमिक स्थिति निर्माण प्राप्त करने के लिए विभिन्न मूल्य स्तरों पर कई प्रवेश बिंदु निर्धारित करना।
  4. लाभ लेने और स्टॉप लॉस के विभिन्न स्तरों के माध्यम से जोखिम का प्रबंधन करना।
  5. बाज़ार संरचना के बारे में अतिरिक्त जानकारी प्रदान करने के लिए हेकिन आशी कैंडलस्टिक्स का उपयोग करना।

रणनीति में इन कारकों का व्यापक विश्लेषण किया गया है ताकि विभिन्न बाजार स्थितियों में स्थिर रिटर्न प्राप्त करने के उद्देश्य से उचित व्यापारिक कार्रवाई की जा सके।

रणनीतिक लाभ

  1. कई पुष्टिकरणः कई तकनीकी संकेतकों का संयोजन व्यापार संकेतों की विश्वसनीयता को बढ़ाता है।
  2. लचीला पूंजी प्रबंधन: क्रमिक स्थिति निर्माण दृष्टिकोण जोखिम नियंत्रण और पूंजी उपयोग में सुधार की अनुमति देता है।
  3. उच्च अनुकूलन क्षमताः रणनीति विभिन्न बाजार स्थितियों के अनुसार व्यापार व्यवहार को समायोजित कर सकती है।
  4. व्यापक जोखिम प्रबंधन: स्टॉप-लॉस और ले-प्रॉफिट तंत्र के कई स्तर जोखिम को प्रभावी ढंग से नियंत्रित करते हैं।
  5. स्वचालन की उच्च डिग्रीः मानव हस्तक्षेप को कम करते हुए रणनीति को पूरी तरह से स्वचालित किया जा सकता है।

रणनीतिक जोखिम

  1. ओवर-ट्रेडिंगः कई ट्रेडिंग स्तरों के कारण अक्सर ट्रेडिंग हो सकती है, जिससे लेनदेन की लागत बढ़ जाती है।
  2. पैरामीटर संवेदनशीलताः रणनीति में कई संकेतकों और मापदंडों का उपयोग किया गया है, जो विभिन्न बाजार वातावरणों के अनुकूल होने के लिए सावधानीपूर्वक समायोजन की आवश्यकता है।
  3. ड्रॉडाउन जोखिमः अत्यधिक अस्थिर बाजारों में, रणनीति को महत्वपूर्ण ड्रॉडाउन जोखिम का सामना करना पड़ सकता है।
  4. तकनीकी निर्भरता: रणनीति तकनीकी संकेतकों पर बहुत अधिक निर्भर करती है, जो कुछ बाजार स्थितियों में विफल हो सकते हैं।
  5. पूंजी प्रबंधन जोखिमः धीरे-धीरे स्थिति निर्माण के दृष्टिकोण से कुछ स्थितियों में अति जोखिम हो सकता है।

रणनीति अनुकूलन दिशाएं

  1. गतिशील पैरामीटर समायोजनः बाजार की स्थितियों के आधार पर स्वचालित रूप से रणनीति मापदंडों को समायोजित करने के लिए मशीन लर्निंग एल्गोरिदम पेश करें।
  2. बाजार भावना विश्लेषणः रणनीति अनुकूलन क्षमता में सुधार के लिए बाजार भावना संकेतकों, जैसे कि VIX सूचकांक को एकीकृत करें।
  3. बहु-समय-सीमा विश्लेषणः व्यापार संकेतों की विश्वसनीयता बढ़ाने के लिए बहु-समय-सीमा विश्लेषण की शुरूआत करें।
  4. अस्थिरता समायोजनः बाजार की अस्थिरता के आधार पर व्यापारिक मात्रा और स्टॉप-लॉस स्तरों को गतिशील रूप से समायोजित करें।
  5. लेन-देन लागत अनुकूलन: व्यापार आवृत्ति और आकार को अनुकूलित करने के लिए लेन-देन लागत मॉडल पेश करें।

सारांश

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


/*backtest
start: 2019-12-23 08:00:00
end: 2024-10-12 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title='Incremental Order size +', shorttitle='TradingPost', overlay=true, default_qty_value=1, pyramiding=10)

//Heiken Ashi
isHA = input(false, 'HA Candles')

//MACD
fastLength = 12
slowlength = 26
MACDLength = 9

MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)
aMACD = ta.ema(MACD, MACDLength)
delta = MACD - aMACD

//Bollinger Bands Exponential
src = open
len = 18
e = ta.ema(src, len)
evar = (src - e) * (src - e)
evar2 = math.sum(evar, len) / len
std = math.sqrt(evar2)
Multiplier = input.float(3, minval=0.01, title='# of STDEV\'s')
upband = e + Multiplier * std
dnband = e - Multiplier * std

//EMA
ema3 = ta.ema(close, 3)

//RSIplot
length = 45
overSold = 90
overBought = 10
price = close

vrsi = ta.rsi(price, length)

notna = not na(vrsi)

macdlong = ta.crossover(delta, 0)
macdshort = ta.crossunder(delta, 0)
rsilong = notna and ta.crossover(vrsi, overSold)
rsishort = notna and ta.crossunder(vrsi, overBought)

lentt = input(14, 'Pivot Length')
    //The length defines how many periods a high or low must hold to be a "relevant pivot"

h = ta.highest(lentt)
    //The highest high over the length
h1 = ta.dev(h, lentt) ? na : h
    //h1 is a pivot of h if it holds for the full length
hpivot = fixnan(h1)
    //creates a series which is equal to the last pivot

l = ta.lowest(lentt)
l1 = ta.dev(l, lentt) ? na : l
lpivot = fixnan(l1)
    //repeated for lows

last_hpivot = 0.0
last_lpivot = 0.0
last_hpivot := h1 ? time : nz(last_hpivot[1])
last_lpivot := l1 ? time : nz(last_lpivot[1])

long_time = last_hpivot > last_lpivot ? 0 : 1

//FIBS

z = input(100, 'Z-Index')
p_offset = 2
transp = 60
a = (ta.lowest(z) + ta.highest(z)) / 2
b = ta.lowest(z)
c = ta.highest(z)
fibonacci = input(0, 'Fibonacci') / 100

//Fib Calls
fib0 = (hpivot - lpivot) * fibonacci + lpivot
fib1 = (hpivot - lpivot) * .21 + lpivot
fib2 = (hpivot - lpivot) * .3 + lpivot
fib3 = (hpivot - lpivot) * .5 + lpivot
fib4 = (hpivot - lpivot) * .62 + lpivot
fib5 = (hpivot - lpivot) * .7 + lpivot
fib6 = (hpivot - lpivot) * 1.00 + lpivot
fib7 = (hpivot - lpivot) * 1.27 + lpivot
fib8 = (hpivot - lpivot) * 2 + lpivot
fib9 = (hpivot - lpivot) * -.27 + lpivot
fib10 = (hpivot - lpivot) * -1 + lpivot

//Heiken Ashi Candles

heikenashi_1 = ticker.heikinashi(syminfo.tickerid)
data2 = isHA ? heikenashi_1 : syminfo.tickerid
res5 = input.timeframe('5', 'Resolution')

//HT Fibs

hfib0 = request.security(data2, res5, fib0[1])
hfib1 = request.security(data2, res5, fib1[1])
hfib2 = request.security(data2, res5, fib2[1])
hfib3 = request.security(data2, res5, fib3[1])
hfib4 = request.security(data2, res5, fib4[1])
hfib5 = request.security(data2, res5, fib5[1])
hfib6 = request.security(data2, res5, fib6[1])
hfib7 = request.security(data2, res5, fib7[1])
hfib8 = request.security(data2, res5, fib8[1])
hfib9 = request.security(data2, res5, fib9[1])
hfib10 = request.security(data2, res5, fib10[1])

vrsiup = vrsi > vrsi[1] and vrsi[1] > vrsi[2]
vrsidown = vrsi < vrsi[1] and vrsi[1] < vrsi[2]

long = ta.cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup
short = ta.cross(close, fib6) and delta < 0 and vrsi > overBought and vrsidown

 // long2 =  cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup 
 // short2 = cross(close, fib6) and delta < 0  and vrsi > overBought and vrsidown
// long =  cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup 
// short = cross(close, fib6) and delta < 0  and vrsi > overBought and vrsidown
// long =  cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup 
// short = cross(close, fib6) and delta < 0  and vrsi > overBought and vrsidown
// long =  cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup 
// short = cross(close, fib6) and delta < 0  and vrsi > overBought and vrsidown
// long =  cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup 
// short = cross(close, fib6) and delta < 0  and vrsi > overBought and vrsidown
// long =  cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup 
// short = cross(close, fib6) and delta < 0  and vrsi > overBought and vrsidown
// long =  cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup 
// short = cross(close, fib6) and delta < 0  and vrsi > overBought and vrsidown
// long =  cross(close, fib0) and delta > 0 and vrsi < overSold and vrsiup 
// short = cross(close, fib6) and delta < 0  and vrsi > overBought and vrsidown

reverseOpens = input(false, 'Reverse Orders')
if reverseOpens
    tmplong = long
    long := short
    short := tmplong
    short

//Strategy
ts = input(99999, 'TS')
tp = input(30, 'TP')
sl = input(15, 'SL')

last_long = 0.0
last_short = 0.0
last_long := long ? time : nz(last_long)
last_short := short ? time : nz(last_short)

in_long = last_long > last_short
in_short = last_short > last_long

long_signal = ta.crossover(last_long, last_short)
short_signal = ta.crossover(last_short, last_long)

last_open_long = 0.0
last_open_short = 0.0
last_open_long := long ? open : nz(last_open_long[1])
last_open_short := short ? open : nz(last_open_short[1])

last_open_long_signal = 0.0
last_open_short_signal = 0.0
last_open_long_signal := long_signal ? open : nz(last_open_long_signal[1])
last_open_short_signal := short_signal ? open : nz(last_open_short_signal[1])

last_high = 0.0
last_low = 0.0
last_high := not in_long ? na : in_long and (na(last_high[1]) or high > nz(last_high[1])) ? high : nz(last_high[1])
last_low := not in_short ? na : in_short and (na(last_low[1]) or low < nz(last_low[1])) ? low : nz(last_low[1])

long_ts = not na(last_high) and high <= last_high - ts and high >= last_open_long_signal
short_ts = not na(last_low) and low >= last_low + ts and low <= last_open_short_signal

long_tp = high >= last_open_long + tp and long[1] == 0
short_tp = low <= last_open_short - tp and short[1] == 0

long_sl = low <= last_open_long - sl and long[1] == 0
short_sl = high >= last_open_short + sl and short[1] == 0

last_hfib_long = 0.0
last_hfib_short = 0.0
last_hfib_long := long_signal ? fib1 : nz(last_hfib_long[1])
last_hfib_short := short_signal ? fib5 : nz(last_hfib_short[1])

last_fib7 = 0.0
last_fib10 = 0.0
last_fib7 := long ? fib7 : nz(last_fib7[1])
last_fib10 := long ? fib10 : nz(last_fib10[1])

last_fib8 = 0.0
last_fib9 = 0.0
last_fib8 := short ? fib8 : nz(last_fib8[1])
last_fib9 := short ? fib9 : nz(last_fib9[1])

last_long_signal = 0.0
last_short_signal = 0.0
last_long_signal := long_signal ? time : nz(last_long_signal[1])
last_short_signal := short_signal ? time : nz(last_short_signal[1])

last_long_tp = 0.0
last_short_tp = 0.0
last_long_tp := long_tp ? time : nz(last_long_tp[1])
last_short_tp := short_tp ? time : nz(last_short_tp[1])

last_long_ts = 0.0
last_short_ts = 0.0
last_long_ts := long_ts ? time : nz(last_long_ts[1])
last_short_ts := short_ts ? time : nz(last_short_ts[1])

long_ts_signal = ta.crossover(last_long_ts, last_long_signal)
short_ts_signal = ta.crossover(last_short_ts, last_short_signal)

last_long_sl = 0.0
last_short_sl = 0.0
last_long_sl := long_sl ? time : nz(last_long_sl[1])
last_short_sl := short_sl ? time : nz(last_short_sl[1])

long_tp_signal = ta.crossover(last_long_tp, last_long)
short_tp_signal = ta.crossover(last_short_tp, last_short)

long_sl_signal = ta.crossover(last_long_sl, last_long)
short_sl_signal = ta.crossover(last_short_sl, last_short)

last_long_tp_signal = 0.0
last_short_tp_signal = 0.0
last_long_tp_signal := long_tp_signal ? time : nz(last_long_tp_signal[1])
last_short_tp_signal := short_tp_signal ? time : nz(last_short_tp_signal[1])

last_long_sl_signal = 0.0
last_short_sl_signal = 0.0
last_long_sl_signal := long_sl_signal ? time : nz(last_long_sl_signal[1])
last_short_sl_signal := short_sl_signal ? time : nz(last_short_sl_signal[1])

last_long_ts_signal = 0.0
last_short_ts_signal = 0.0
last_long_ts_signal := long_ts_signal ? time : nz(last_long_ts_signal[1])
last_short_ts_signal := short_ts_signal ? time : nz(last_short_ts_signal[1])

true_long_signal = long_signal and last_long_sl_signal > last_long_signal[1] or long_signal and last_long_tp_signal > last_long_signal[1] or long_signal and last_long_ts_signal > last_long_signal[1]
true_short_signal = short_signal and last_short_sl_signal > last_short_signal[1] or short_signal and last_short_tp_signal > last_short_signal[1] or short_signal and last_short_ts_signal > last_short_signal[1]


// strategy.entry("BLUE", strategy.long, when=long)
// strategy.entry("RED", strategy.short, when=short)

g = delta > 0 and vrsi < overSold and vrsiup
r = delta < 0 and vrsi > overBought and vrsidown

long1 = ta.cross(close, fib1) and g and last_long_signal[1] > last_short_signal  // and last_long_signal > long
short1 = ta.cross(close, fib5) and r and last_short_signal[1] > last_long_signal  // and last_short_signal > short

last_long1 = 0.0
last_short1 = 0.0
last_long1 := long1 ? time : nz(last_long1[1])
last_short1 := short1 ? time : nz(last_short1[1])

last_open_long1 = 0.0
last_open_short1 = 0.0
last_open_long1 := long1 ? open : nz(last_open_long1[1])
last_open_short1 := short1 ? open : nz(last_open_short1[1])

long1_signal = ta.crossover(last_long1, last_long_signal)
short1_signal = ta.crossover(last_short1, last_short_signal)

last_long1_signal = 0.0
last_short1_signal = 0.0
last_long1_signal := long1_signal ? time : nz(last_long1_signal[1])
last_short1_signal := short1_signal ? time : nz(last_short1_signal[1])

long2 = ta.cross(close, fib2) and g and last_long1_signal > last_long_signal[1] and long1_signal == 0 and last_long_signal[1] > last_short_signal
short2 = ta.cross(close, fib4) and r and last_short1_signal > last_short_signal[1] and short1_signal == 0 and last_short_signal[1] > last_long_signal

last_long2 = 0.0
last_short2 = 0.0
last_long2 := long2 ? time : nz(last_long2[1])
last_short2 := short2 ? time : nz(last_short2[1])

last_open_short2 = 0.0
last_open_short2 := short2 ? open : nz(last_open_short2[1])

long2_signal = ta.crossover(last_long2, last_long1_signal) and long1_signal == 0
short2_signal = ta.crossover(last_short2, last_short1_signal) and short1_signal == 0

last_long2_signal = 0.0
last_short2_signal = 0.0
last_long2_signal := long2_signal ? time : nz(last_long2_signal[1])
last_short2_signal := short2_signal ? time : nz(last_short2_signal[1])

//Trade 4

long3 = ta.cross(close, fib3) and g and last_long1_signal > last_long_signal[1] and long1_signal == 0 and last_long_signal[1] > last_short_signal
short3 = ta.cross(close, fib3) and r and last_short1_signal > last_short_signal[1] and short1_signal == 0 and last_short_signal[1] > last_long_signal

last_long3 = 0.0
last_short3 = 0.0
last_long3 := long3 ? time : nz(last_long3[1])
last_short3 := short3 ? time : nz(last_short3[1])

last_open_short3 = 0.0
last_open_short3 := short3 ? open : nz(last_open_short3[1])

long3_signal = ta.crossover(last_long3, last_long2_signal) and long2_signal == 0
short3_signal = ta.crossover(last_short3, last_short2_signal) and short2_signal == 0

last_long3_signal = 0.0
last_short3_signal = 0.0
last_long3_signal := long3_signal ? time : nz(last_long3_signal[1])
last_short3_signal := short3_signal ? time : nz(last_short3_signal[1])


//Trade 5
long4 = long and last_long1_signal > last_long_signal[1] and long1_signal == 0 and last_long_signal[1] > last_short_signal
short4 = short and last_short1_signal > last_short_signal[1] and short1_signal == 0 and last_short_signal[1] > last_long_signal
last_long4 = 0.0
last_short4 = 0.0
last_long4 := long4 ? time : nz(last_long4[1])
last_short4 := short4 ? time : nz(last_short4[1])

long4_signal = ta.crossover(last_long4, last_long3_signal) and long2_signal == 0 and long3_signal == 0
short4_signal = ta.crossover(last_short4, last_short3_signal) and short2_signal == 0 and short3_signal == 0
last_long4_signal = 0.0
last_short4_signal = 0.0
last_long4_signal := long4_signal ? time : nz(last_long4_signal[1])
last_short4_signal := short4_signal ? time : nz(last_short4_signal[1])

//Trade 6
long5 = long and last_long1_signal > last_long_signal[1] and long1_signal == 0 and last_long_signal[1] > last_short_signal
short5 = short and last_short1_signal > last_short_signal[1] and short1_signal == 0 and last_short_signal[1] > last_long_signal

last_long5 = 0.0
last_short5 = 0.0
last_long5 := long5 ? time : nz(last_long5[1])
last_short5 := short5 ? time : nz(last_short5[1])

long5_signal = ta.crossover(last_long5, last_long4_signal) and long3_signal == 0 and long4_signal == 0
short5_signal = ta.crossover(last_short5, last_short4_signal) and short3_signal == 0 and short4_signal == 0

last_long5_signal = 0.0
last_short5_signal = 0.0
last_long5_signal := long5_signal ? time : nz(last_long5_signal[1])
last_short5_signal := short5_signal ? time : nz(last_short5_signal[1])

//Trade 7
long6 = long and last_long1_signal > last_long_signal[1] and long1_signal == 0 and last_long_signal[1] > last_short_signal
short6 = short and last_short1_signal > last_short_signal[1] and short1_signal == 0 and last_short_signal[1] > last_long_signal

last_long6 = 0.0
last_short6 = 0.0
last_long6 := long6 ? time : nz(last_long6[1])
last_short6 := short6 ? time : nz(last_short6[1])

long6_signal = ta.crossover(last_long6, last_long5_signal) and long2_signal == 0 and long4_signal == 0 and long5_signal == 0
short6_signal = ta.crossover(last_short6, last_short5_signal) and short2_signal == 0 and short4_signal == 0 and short5_signal == 0

last_long6_signal = 0.0
last_short6_signal = 0.0
last_long6_signal := long6_signal ? time : nz(last_long6_signal[1])
last_short6_signal := short6_signal ? time : nz(last_short6_signal[1])


//Trade 8
long7 = long and last_long1_signal > last_long_signal[1] and long1_signal == 0 and last_long_signal[1] > last_short_signal
short7 = short and last_short1_signal > last_short_signal[1] and short1_signal == 0 and last_short_signal[1] > last_long_signal

last_long7 = 0.0
last_short7 = 0.0
last_long7 := long7 ? time : nz(last_long7[1])
last_short7 := short7 ? time : nz(last_short7[1])

long7_signal = ta.crossover(last_long7, last_long6_signal) and long2_signal == 0 and long4_signal == 0 and long5_signal == 0 and long6_signal == 0
short7_signal = ta.crossover(last_short7, last_short6_signal) and short2_signal == 0 and short4_signal == 0 and short5_signal == 0 and short6_signal == 0

last_long7_signal = 0.0
last_short7_signal = 0.0
last_long7_signal := long7_signal ? time : nz(last_long7_signal[1])
last_short7_signal := short7_signal ? time : nz(last_short7_signal[1])


//Trade 9
long8 = long and last_long1_signal > last_long_signal[1] and long1_signal == 0 and last_long_signal[1] > last_short_signal
short8 = short and last_short1_signal > last_short_signal[1] and short1_signal == 0 and last_short_signal[1] > last_long_signal
last_long8 = 0.0
last_short8 = 0.0
last_long8 := long8 ? time : nz(last_long8[1])
last_short8 := short8 ? time : nz(last_short8[1])

long8_signal = ta.crossover(last_long8, last_long7_signal) and long2_signal == 0 and long4_signal == 0 and long5_signal == 0 and long6_signal == 0 and long7_signal == 0
short8_signal = ta.crossover(last_short8, last_short7_signal) and short2_signal == 0 and short4_signal == 0 and short5_signal == 0 and short6_signal == 0 and short7_signal == 0

last_long8_signal = 0.0
last_short8_signal = 0.0
last_long8_signal := long8_signal ? time : nz(last_long8_signal[1])
last_short8_signal := short8_signal ? time : nz(last_short8_signal[1])

//Trade 10
long9 = long and last_long1_signal > last_long_signal[1] and long1_signal == 0 and last_long_signal[1] > last_short_signal
short9 = short and last_short1_signal > last_short_signal[1] and short1_signal == 0 and last_short_signal[1] > last_long_signal
last_long9 = 0.0
last_short9 = 0.0
last_long9 := long9 ? time : nz(last_long9[1])
last_short9 := short9 ? time : nz(last_short9[1])

long9_signal = ta.crossover(last_long9, last_long8_signal) and long2_signal == 0 and long4_signal == 0 and long5_signal == 0 and long6_signal == 0 and long7_signal == 0 and long8_signal == 0
short9_signal = ta.crossover(last_short9, last_short8_signal) and short2_signal == 0 and short4_signal == 0 and short5_signal == 0 and short6_signal == 0 and short7_signal == 0 and short8_signal == 0
last_long9_signal = 0.0
last_short9_signal = 0.0
last_long9_signal := long9_signal ? time : nz(last_long9_signal[1])
last_short9_signal := short9_signal ? time : nz(last_short9_signal[1])


strategy.entry('Long', strategy.long, qty=1, when=long_signal)
strategy.entry('Short', strategy.short, qty=1, when=short_signal)
strategy.entry('Long', strategy.long, qty=2, when=long1_signal)
strategy.entry('Short1', strategy.short, qty=2, when=short1_signal)
strategy.entry('Long', strategy.long, qty=4, when=long2_signal)
strategy.entry('Short2', strategy.short, qty=4, when=short2_signal)
strategy.entry('Long', strategy.long, qty=8, when=long3_signal)
strategy.entry('Short3', strategy.short, qty=8, when=short3_signal)
strategy.entry('Long', strategy.long, qty=5, when=long4_signal)
strategy.entry('Short', strategy.short, qty=5, when=short4_signal)
strategy.entry('Long', strategy.long, qty=6, when=long5_signal)
strategy.entry('Short', strategy.short, qty=6, when=short5_signal)
strategy.entry('Long', strategy.long, qty=7, when=long6_signal)
strategy.entry('Short', strategy.short, qty=7, when=short6_signal)
strategy.entry('Long', strategy.long, qty=8, when=long7_signal)
strategy.entry('Short', strategy.short, qty=8, when=short7_signal)
strategy.entry('Long', strategy.long, qty=9, when=long8_signal)
strategy.entry('Short', strategy.short, qty=9, when=short8_signal)
strategy.entry('Long', strategy.long, qty=10, when=long9_signal)
strategy.entry('Short', strategy.short, qty=10, when=short9_signal)

short1_tp = low <= last_open_short1 - tp and short1[1] == 0
short2_tp = low <= last_open_short2 - tp and short2[1] == 0
short3_tp = low <= last_open_short3 - tp and short3[1] == 0
short1_sl = high >= last_open_short1 + sl and short1[1] == 0
short2_sl = high >= last_open_short2 + sl and short2[1] == 0
short3_sl = high >= last_open_short3 + sl and short3[1] == 0

close_long = ta.cross(close, fib6)
close_short = ta.cross(close, fib0)

// strategy.close("Long", when=close_long)
// strategy.close("Long", when=long_tp)
// strategy.close("Long", when=long_sl)

// strategy.close("Short", when=long_signal)
// strategy.close("Short1", when=long_signal)
// strategy.close("Short2", when=long_signal)
// strategy.close("Short3", when=long_signal)
strategy.close('Short', when=short_tp)
strategy.close('Short1', when=short1_tp)
strategy.close('Short2', when=short2_tp)
strategy.close('Short3', when=short3_tp)
strategy.close('Short', when=short_sl)
strategy.close('Short1', when=short1_sl)
strategy.close('Short2', when=short2_sl)
strategy.close('Short3', when=short3_sl)



संबंधित

अधिक