इस रणनीति का मुख्य विचार वास्तविक समय में ट्रेडिंग का अनुकरण करना है, साप्ताहिक ट्रेडिंग डेटा एकत्र करना है, और रणनीति के प्रदर्शन को अधिक सहजता से देखने के लिए तालिकाओं के रूप में सांख्यिकीय परिणाम प्रदर्शित करना है। यह हमें रणनीति के लाभ और हानि का त्वरित आकलन करने में मदद कर सकता है, और उस समय की अवधि की पहचान कर सकता है जब रणनीति खराब प्रदर्शन कर रही है, और तदनुसार रणनीति को समायोजित और अनुकूलित कर सकती है।
गणना चक्र की शुरुआत और समाप्ति का समय सेट करें
सेट सांख्यिकीय परिणामों की सटीकता और प्रत्येक समूह में शामिल सप्ताहों की संख्या।
आरएसआई रणनीतियों को खरीदने और बेचने के लिए।
तालिका में चर को परिभाषित करना
वर्तमान चक्र के परिणाम की गणना करें
यदि चक्र बदलता है और व्यापार की अनुमति देता है, तो उस चक्र के समय और परिणामों को रिकॉर्ड करें।
यदि यह अंतिम K लाइन है और लेनदेन की अनुमति है, तो वर्तमान चक्र के समय और परिणामों को रिकॉर्ड करें।
यदि चक्र बदलता है और व्यापार की अनुमति नहीं है, तो पिछले चक्र के समय और परिणामों को रिकॉर्ड करें।
उच्चतम और निम्नतम चक्र परिणामों को ढूंढें
रेंडर सांख्यिकी
सबसे पहले, हम कुल संख्या की गणना करते हैं
प्रत्येक चक्र के माध्यम से, टेम्प्लेट, समय और परिणाम को रेंडर करें
चक्र परिणामों के प्रत्येक समूह के लिए संचयी
रंगों के साथ पॉजिटिव और नेगेटिव को चिह्नित करें
वास्तविक समय में साप्ताहिक ट्रेडिंग परिणामों को देखने के लिए, रणनीति के प्रदर्शन का त्वरित मूल्यांकन करने के लिए
परिणामों को एक नज़र में दिखाना, जो कि एक रणनीति के खराब प्रदर्शन की अवधि का पता लगाने में मदद करता है
समय अवधि के लाभ और हानि के आधार पर रणनीति पैरामीटर को समायोजित और अनुकूलित करें
लंबे समय तक स्थिति रखने की रणनीति के लिए कई हफ्तों के संचयी लाभ को आसानी से ट्रैक करें
विभिन्न समय अवधि के लिए ट्रेडिंग शैलियों का तुलनात्मक विश्लेषण करने में सक्षम
विभिन्न आवश्यकताओं के लिए अनुकूलित सांख्यिकीय सटीकता और समूह सप्ताह
कोड को सरल, स्पष्ट, समझने और पुनः उपयोग करने में आसान बनाना
यह रणनीति आरएसआई पर आधारित है और ट्रेडों का अनुकरण करती है, आरएसआई रणनीति में ही एक दोष है जो प्रवृत्ति का पालन करने के लिए पर्याप्त मजबूत नहीं है
ट्रेडिंग शुल्क का वास्तविक बाजार में परिणामों पर अधिक प्रभाव पड़ता है
ऐतिहासिक डेटा का उपयोग वास्तविक लेनदेन के परिदृश्य को प्रतिबिंबित करने के लिए नहीं किया जाता है
सांख्यिकीय परिणाम वास्तविक खाते की राशि पर निर्भर करते हैं, और पूर्वनिर्धारित राशि को वापस मापने में सटीक नहीं होना चाहिए
ओवरफिटिंग से बचने के लिए सावधानी बरतनी चाहिए, फीडबैक के आधार पर नीति पैरामीटर को अंधाधुंध रूप से संशोधित करना
रुझानों का आकलन करने के लिए और अधिक संकेतकों के साथ संयोजन करके आरएसआई रणनीति को बढ़ाया जा सकता है, प्रवेश और बाहर निकलने के बिंदुओं को अनुकूलित किया जा सकता है। वास्तविक व्यापार के लिए वास्तविक पैरामीटर पर सेट करने के लिए ध्यान दें। रिटर्निंग चरण में पूंजी की मात्रा में उतार-चढ़ाव को बढ़ाएं, ताकि यह वास्तविक स्थिति के करीब हो। संदेह रखें और सांख्यिकीय परिणामों के आधार पर रणनीति को अत्यधिक समायोजित करने से बचें।
स्टॉप लॉजिक को जोड़ने पर विचार करें, एकल नुकसान को नियंत्रित करें
रणनीति पैरामीटर को अनुकूलित करने के लिए, जैसे कि आरएसआई को समायोजित करना
आप विभिन्न ट्रेडिंग आवृत्तियों का प्रयास कर सकते हैं, जैसे कि एक दिन में ट्रेड करना या एक महीने में स्थिति रखना
बाजार के रुझान और प्रवेश के समय के बारे में अधिक संकेतकों को जोड़ना
स्टॉप लॉजिक को शामिल करने पर विचार करें
सेटिंग्स जो सांख्यिकीय मापदंडों को अनुकूलित कर सकते हैं
बहु-संपत्ति सांख्यिकी पर विचार किया जा सकता है
स्टॉप लॉस और स्टॉप रिटर्न को जोड़कर, जोखिम और रिटर्न को बेहतर तरीके से नियंत्रित किया जा सकता है। आरएसआई पैरामीटर को अनुकूलित करने से जीत की दर बढ़ सकती है। अधिक संकेतकों और विभिन्न ट्रेडिंग आवृत्तियों को अपनाने से रणनीति को अधिक स्थिर बनाया जा सकता है। सांख्यिकीय पैरामीटर को समायोजित करने से परिणामों को अधिक प्रमुखता दी जा सकती है। एकल परिसंपत्ति से बहु-संपत्ति के आंकड़ों तक विस्तार से, रणनीति की प्रभावशीलता का समग्र आकलन किया जा सकता है।
इस रणनीति का उद्देश्य चक्र ट्रेडिंग परिणामों को एकत्र करना है, जो सांख्यिकीय तालिकाओं के रूप में दृश्यमान रूप से प्रदर्शित होते हैं, जो विभिन्न समय अवधि में रणनीति के लाभप्रदता का त्वरित न्याय कर सकते हैं। यह रणनीति अनुकूलन के लिए डेटा समर्थन प्रदान करता है। इसके फायदे साप्ताहिक परिणामों को वास्तविक समय में देख सकते हैं, स्पष्ट रूप से स्पष्ट हैं, और इसे दो बार विकसित करना आसान है। यह ध्यान दिया जाना चाहिए कि सांख्यिकीय परिणामों के परिणामस्वरूप अति-निर्भरता हो सकती है और फिटिंग डेटा को फिर से तैयार किया जा सकता है। हमें तर्कसंगत रहना चाहिए, रणनीति के सिद्धांतों के संयोजन में समग्र निर्णय करना चाहिए, समस्या को खोजने के लिए सांख्यिकीय परिणामों का उपयोग करें, न कि सीधे संशोधन के आधार के रूप में। कुल मिलाकर, यह रणनीति के प्रदर्शन का त्वरित मूल्यांकन करने की सुविधा प्रदान करती है, जो रणनीति अनुकूलन में महत्वपूर्ण भूमिका निभाता है।
/*backtest
start: 2023-09-12 00:00:00
end: 2023-10-12 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
// strategy('Strategy weekly results as numbers v1', overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=25, commission_type=strategy.commission.percent, commission_value=0.04)
after = input(title='Trade after', defval=timestamp('01 Jan 2019 00:00 UTC'), tooltip="Strategy will be executed after this timestamp. The statistic table will include only periods after this date.")
before = input(title='Trade before', defval=timestamp('31 Dec 2024 23:59 UTC'), tooltip="Strategy will be executes before this timestamp. The statistic table will include only periods before this date.")
statisticPrecision = input.int(title='Statistic precision', group='Statistic visualisation', defval=1, tooltip="Defines how many digits should be rendered in every statistic cell.")
statisticGroupSize = input.int(title='Statistic group size', group='Statistic visualisation', defval=12, tooltip="Defines how many cells should be in one group inside the statistic table.")
// determinet whether the starategy should be traded between the period
isTradeEnabled = true
// *******************************************************************************************
// Core strategy simulation logic
// *******************************************************************************************
// calculate rsi strategy emulation data
rsiEmulationData = ta.rsi(close, 7)
rsiEmulationCrossover = ta.crossover(rsiEmulationData, 70)
rsiEmulationCrossunder = ta.crossunder(rsiEmulationData, 30)
// entry loogic based on the rsi calculations
if (isTradeEnabled and rsiEmulationCrossover)
strategy.entry('Long', strategy.long)
if (isTradeEnabled and rsiEmulationCrossunder)
strategy.entry('Short', strategy.short)
// *******************************************************************************************
// Weekly statistics table
// *******************************************************************************************
// define statistic variables
var statisticTable = table(na)
var statisticPeriodTime = array.new_int(0)
var statisticPeriodResult = array.new_float(0)
var statisticIsLatestCalculated = bool(na)
var statisticResultHighest = float(na)
var statisticResultLowest = float(na)
var statisticColorGray = color.new(color.gray, transp = 60)
var statisticColorGreen = color.new(color.green, transp = 60)
var statisticColorRed = color.new(color.red, transp = 60)
// claculate current period result
barResult = not na(strategy.equity[1])
? (strategy.equity / strategy.equity[1] - 1) : 0
isPeriodChanged = not na(time[1]) and weekofyear(time) != weekofyear(time[1])
currentPeriodResult = 0.0
currentPeriodResult := not na(currentPeriodResult[1]) and not isPeriodChanged
? ((1 + currentPeriodResult[1]) * (1 + barResult) - 1) : 0.0
// initialise highest and lowest results variables
statisticResultHighest := na(statisticResultHighest) ? currentPeriodResult : statisticResultHighest
statisticResultLowest := na(statisticResultLowest) ? currentPeriodResult : statisticResultLowest
// search for highest and lowest results
statisticResultHighest := currentPeriodResult > statisticResultHighest ? currentPeriodResult : statisticResultHighest
statisticResultLowest := currentPeriodResult < statisticResultLowest ? currentPeriodResult : statisticResultLowest
// new week while trade is active
if isPeriodChanged and isTradeEnabled
timeCalculated = time - 1000 * 60 * 60 * 24 * 7
resultCalculated = currentPeriodResult[1]
statisticIsLatestCalculated := false
array.push(statisticPeriodTime, timeCalculated)
array.push(statisticPeriodResult, resultCalculated)
// latest bar while trade is active
if barstate.islast and isTradeEnabled
timeCalculated = time - 1000 * 60 * 60 * 24 * (dayofweek(time) - 2)
resultCalculated = currentPeriodResult
array.push(statisticPeriodTime, timeCalculated)
array.push(statisticPeriodResult, resultCalculated)
// new week after trade disabled
if isPeriodChanged and not isTradeEnabled and not na(statisticIsLatestCalculated) and not statisticIsLatestCalculated
timeCalculated = time - 1000 * 60 * 60 * 24 * (dayofweek(time) + 5)
resultCalculated = currentPeriodResult[1]
statisticIsLatestCalculated := true
array.push(statisticPeriodTime, timeCalculated)
array.push(statisticPeriodResult, resultCalculated)
// render statistics table
if barstate.islast
statisticLength = array.size(statisticPeriodResult)
statisticTableSteps = math.floor(statisticLength / statisticGroupSize) + (statisticLength % statisticGroupSize != 0 ? 1 : 0)
statisticTable := table.new(position.bottom_right, columns = statisticGroupSize + 2, rows = statisticTableSteps + 1, border_width = 1)
// render headers
for i = 0 to (statisticGroupSize - 1)
statisticHeaderContent = str.tostring(i + 1)
table.cell(statisticTable, 1 + i, 0, statisticHeaderContent, bgcolor = statisticColorGray)
// render time points
for i = 0 to (statisticTableSteps - 1)
statisticPointContent = str.format("{0,date,medium}", array.get(statisticPeriodTime, i * statisticGroupSize))
table.cell(statisticTable, 0, 1 + i, statisticPointContent, bgcolor = statisticColorGray)
// render the result
statisticResultCummulative = 0.0
for i = 0 to (array.size(statisticPeriodTime) - 1)
statisticColumn = 1 + i % statisticGroupSize
statisticRow = 1 + math.floor(i / statisticGroupSize)
statisticResult = array.get(statisticPeriodResult, i)
statisticResultCummulative := (i % statisticGroupSize == 0) ? 0.0 : statisticResultCummulative
statisticResultCummulative := (1 + statisticResultCummulative) * (1 + statisticResult) - 1
statisticResultColor = statisticResult > 0 ? statisticColorGreen : statisticColorRed
table.cell(statisticTable, statisticColumn, statisticRow, str.tostring(math.round(statisticResult * 100, statisticPrecision)), bgcolor = statisticResultColor)
// if it is the last item of the row or data array
isStatisticLastOfTheRow = ((i + 1) % statisticGroupSize) == 0
isStatisticLastOfTheData = i == (statisticLength - 1)
if (isStatisticLastOfTheRow or isStatisticLastOfTheData)
resultsTableCummulativeCellColor = statisticResultCummulative > 0 ? statisticColorGreen : statisticColorRed
resultsTableCummulativeCellContent = str.tostring(math.round(statisticResultCummulative * 100, statisticPrecision))
table.cell(statisticTable, 1 + statisticGroupSize, statisticRow, resultsTableCummulativeCellContent, bgcolor = resultsTableCummulativeCellColor)