गतिशील रणनीति विश्लेषण उपकरण

लेखक:चाओझांग, दिनांक: 2023-10-13 15:54:35
टैगः

अवलोकन

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

रणनीति तर्क

  1. गणना अवधि के लिए प्रारंभ और समाप्ति समय निर्धारित करें।

  2. प्रत्येक समूह में सांख्यिकी की सटीकता और सप्ताहों की संख्या निर्धारित करें।

  3. प्रवेश और निकास के लिए आरएसआई रणनीति का अनुकरण करें।

  4. सांख्यिकी तालिका के लिए चर को परिभाषित करें।

  5. वर्तमान अवधि के लिए परिणाम की गणना करें।

  6. यदि अवधि बदलती है और व्यापार सक्षम है, तो इस अवधि के लिए समय और परिणाम दर्ज करें।

  7. यदि यह अंतिम पट्टी है और ट्रेडिंग सक्षम है, तो वर्तमान अवधि के लिए समय और परिणाम दर्ज करें।

  8. यदि अवधि बदलती है और व्यापार अक्षम है, तो पिछली अवधि के लिए समय और परिणाम दर्ज करें।

  9. उच्चतम और निम्नतम अवधि परिणाम खोजें.

  10. सांख्यिकीय तालिका प्रस्तुत करें।

  • पहले सांख्यिकीय अवधियों की कुल संख्या की गणना करें

  • प्रत्येक अवधि के माध्यम से दोहराएं, हेडर, समय और परिणाम प्रस्तुत करें

  • प्रत्येक समूह के लिए परिणाम की संचयी गणना करें

  • रंग कोड सकारात्मक और नकारात्मक परिणाम

लाभ विश्लेषण

  • त्वरित रणनीति मूल्यांकन के लिए वास्तविक समय में साप्ताहिक परिणामों का निरीक्षण कर सकता है

  • स्पष्ट अंतर्दृष्टि के लिए परिणामों की सहज प्रस्तुति

  • रणनीतिक समायोजन के लिए खराब प्रदर्शन के समय की पहचान करने में मदद करें

  • दीर्घकालिक रणनीतियों के लिए संचयी लाभों को ट्रैक करने के लिए सुविधाजनक

  • विभिन्न समय अवधि में ट्रेडिंग शैलियों की तुलना कर सकता है

  • विभिन्न आवश्यकताओं को पूरा करने के लिए अनुकूलन योग्य परिशुद्धता और समूह

  • सरल और स्पष्ट कोड, समझने और विस्तार करने में आसान

जोखिम विश्लेषण

  • यह रणनीति आरएसआई पर आधारित है, जिसमें सीमाओं के बाद अंतर्निहित प्रवृत्ति है।

  • व्यापार लागत वास्तविक परिणामों को काफी प्रभावित कर सकती है

  • बैकटेस्ट डेटा वास्तविक बाजार स्थितियों को प्रतिबिंबित नहीं कर सकता

  • बैकटेस्ट में डिफॉल्ट पूंजी वास्तविक खाता आकार से मेल नहीं खा सकती है

  • आँकड़ों के आधार पर मापदंडों को अंधाधुंध समायोजित करके ओवरफिटिंग से बचें

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

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

  • डाउनसाइड को सीमित करने के लिए स्टॉप लॉस जोड़ने पर विचार करें

  • ओवरबॉट और ओवरसोल्ड स्तर जैसे आरएसआई मापदंडों का अनुकूलन करें

  • विभिन्न ट्रेडिंग आवृत्तियों जैसे इंट्राडे बनाम मासिक होल्डिंग का प्रयास करें

  • प्रवृत्ति और समय के लिए अधिक संकेतक शामिल करें

  • लाभ लेने का तर्क जोड़ें

  • सांख्यिकीय पैरामीटर सेटिंग्स का अनुकूलन करें

  • कई परिसंपत्तियों को ट्रैक करने के लिए विस्तार करें

स्टॉप जोखिम / इनाम का बेहतर प्रबंधन कर सकते हैं। आरएसआई ट्यूनिंग जीत दर में सुधार करता है। अधिक संकेतक और आवृत्तियां रणनीति को मजबूत बनाती हैं। सांख्यिकीय ट्यूनिंग महत्वपूर्ण डेटा को उजागर करती है। कई परिसंपत्तियों में विस्तार पूर्ण दृश्य देता है।

सारांश

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


/*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)

अधिक