গতিশীল কৌশল বিশ্লেষণ সরঞ্জাম

লেখক:চাওঝাং, তারিখ: ২০২৩-১০-১৩
ট্যাগঃ

সারসংক্ষেপ

এই কৌশলটির মূল ধারণা হ'ল রিয়েল-টাইম ট্রেডিং সিমুলেট করা, সাপ্তাহিক ট্রেডিং ডেটা সংগ্রহ করা এবং কৌশলটির পারফরম্যান্সের আরও স্বজ্ঞাত পর্যালোচনার জন্য একটি টেবিলে পরিসংখ্যান উপস্থাপন করা। এটি আমাদের কৌশলটির লাভ এবং ক্ষতি দ্রুত মূল্যায়ন করতে, দুর্বল পারফরম্যান্সের সময়গুলি সনাক্ত করতে এবং সেই অনুযায়ী কৌশলটি অনুকূল করতে সহায়তা করতে পারে।

কৌশলগত যুক্তি

  1. গণনা সময়ের জন্য শুরু এবং শেষ সময় সেট করুন।

  2. পরিসংখ্যানের নির্ভুলতা এবং প্রতিটি গ্রুপে সপ্তাহের সংখ্যা নির্ধারণ করুন।

  3. প্রবেশ এবং প্রস্থান জন্য RSI কৌশল অনুকরণ করুন।

  4. পরিসংখ্যান টেবিলের জন্য ভেরিয়েবল সংজ্ঞায়িত করুন।

  5. বর্তমান সময়ের জন্য ফলাফল গণনা করুন।

  6. যদি সময় পরিবর্তন হয় এবং ট্রেডিং সক্ষম করা হয়, তাহলে এই সময়ের জন্য সময় এবং ফলাফল রেকর্ড করুন।

  7. যদি এটি শেষ বার এবং ট্রেডিং সক্ষম থাকে, তাহলে বর্তমান সময়ের সময় এবং ফলাফল রেকর্ড করুন।

  8. যদি সময় পরিবর্তন হয় এবং ট্রেডিং নিষ্ক্রিয় থাকে, তাহলে আগের সময়ের সময় এবং ফলাফল রেকর্ড করুন।

  9. সর্বোচ্চ এবং সর্বনিম্ন সময়ের ফলাফল খুঁজুন।

  10. পরিসংখ্যানের টেবিলটা দাও।

  • প্রথমে পরিসংখ্যানিক সময়ের মোট সংখ্যা গণনা করুন

  • প্রতিটি সময়ের মাধ্যমে পুনরাবৃত্তি করুন, শিরোনাম, সময় এবং ফলাফল রেন্ডার করুন

  • প্রতিটি গ্রুপের জন্য ফলটি সমষ্টিগতভাবে গণনা করুন

  • রঙ কোড ইতিবাচক এবং নেতিবাচক ফলাফল

সুবিধা বিশ্লেষণ

  • দ্রুত কৌশল মূল্যায়নের জন্য রিয়েল টাইমে সাপ্তাহিক ফলাফল পর্যবেক্ষণ করতে পারে

  • স্পষ্ট অন্তর্দৃষ্টির জন্য ফলাফলের স্বজ্ঞাত উপস্থাপনা

  • কৌশলগত সমন্বয়ের জন্য দুর্বল পারফরম্যান্সের সময়গুলি সনাক্ত করতে সহায়তা করুন

  • দীর্ঘমেয়াদী কৌশলগুলির জন্য ক্রমবর্ধমান লাভের জন্য সুবিধাজনক

  • বিভিন্ন সময়ের মধ্যে ট্রেডিং স্টাইল তুলনা করতে পারে

  • বিভিন্ন চাহিদা পূরণের জন্য কাস্টমাইজযোগ্য নির্ভুলতা এবং গ্রুপ

  • সহজ এবং পরিষ্কার কোড, সহজেই বুঝতে এবং প্রসারিত

ঝুঁকি বিশ্লেষণ

  • কৌশলটি RSI এর উপর ভিত্তি করে, যা সীমাবদ্ধতা অনুসরণ করে অন্তর্নিহিত প্রবণতা আছে

  • ট্রেডিং খরচ প্রকৃত ফলাফল উল্লেখযোগ্যভাবে প্রভাবিত করতে পারে

  • ব্যাকটেস্ট ডেটা প্রকৃত বাজারের পরিস্থিতি প্রতিফলিত করতে পারে না

  • ব্যাকটেস্টে ডিফল্ট মূলধন প্রকৃত অ্যাকাউন্টের আকারের সাথে মেলে না

  • পরিসংখ্যান ভিত্তিক পরামিতি অন্ধভাবে মিটিং দ্বারা overfitting এড়াতে

ট্রেন্ডের জন্য আরও সূচক অন্তর্ভুক্ত করতে পারে এবং মৌলিক আরএসআই কৌশল উন্নত করতে এন্ট্রি এবং প্রস্থানগুলি অনুকূল করতে পারে। লাইভ ট্রেডিংয়ে প্রকৃত ট্রেডিং ব্যয় ব্যবহার করুন। ব্যাকটেস্টে মূলধনের আকারে এলোমেলোতা যুক্ত করুন। পরিসংখ্যানের উপর ভিত্তি করে ওভার-টিউনিংয়ের পরিবর্তে সংশয়বাদ বজায় রাখুন।

অপ্টিমাইজেশান নির্দেশাবলী

  • ডাউনসাইড সীমাবদ্ধ করার জন্য স্টপ লস যোগ করার বিষয়টি বিবেচনা করুন

  • অতিরিক্ত ক্রয় এবং অতিরিক্ত বিক্রয় স্তরের মতো আরএসআই পরামিতিগুলি অনুকূল করুন

  • বিভিন্ন ট্রেডিং ফ্রিকোয়েন্সি যেমন ইনট্রাডে বনাম মাসিক হোল্ডিং চেষ্টা করুন

  • প্রবণতা এবং সময়সূচির জন্য আরও সূচক অন্তর্ভুক্ত করুন

  • মুনাফা গ্রহণ যুক্ত যুক্তি

  • পরিসংখ্যানগত পরামিতি সেটিংস অপ্টিমাইজ করুন

  • একাধিক সম্পদ ট্র্যাক করার জন্য প্রসারিত করুন

স্টপগুলি ঝুঁকি / পুরষ্কারকে আরও ভালভাবে পরিচালনা করতে পারে। আরএসআই টিউনিং জয়ের হারকে উন্নত করে। আরও সূচক এবং ফ্রিকোয়েন্সি কৌশলটিকে শক্তিশালী করে তোলে। পরিসংখ্যানগত টিউনিং গুরুত্বপূর্ণ ডেটা হাইলাইট করে। একাধিক সম্পদে প্রসারিত করা সম্পূর্ণ দৃষ্টিভঙ্গি দেয়।

সংক্ষিপ্তসার

লক্ষ্য হল সময়ের সাথে সাথে পারফরম্যান্সের দ্রুত বিচার করার জন্য স্বজ্ঞাত পরিসংখ্যানমূলক ভিজ্যুয়ালাইজেশনের জন্য পর্যায়ক্রমিক ফলাফল সংগ্রহ করা। এটি কৌশলগুলি অনুকূল করার জন্য ডেটা সরবরাহ করে। শক্তিগুলির মধ্যে রিয়েল-টাইম সাপ্তাহিক ফলাফল, স্বচ্ছতা এবং প্রসারণযোগ্যতা অন্তর্ভুক্ত রয়েছে। পরিসংখ্যানগত আউটপুটগুলির সাথে অতিরিক্ত নির্ভরতা এবং বক্ররেখা ফিটিংয়ের বিষয়ে সতর্ক থাকুন। অন্তর্দৃষ্টিগুলির জন্য মূল কৌশল যুক্তির সাথে যৌক্তিকভাবে ব্যবহার করুন, পরিবর্তনের ভিত্তি হিসাবে নয়। সামগ্রিকভাবে, কার্য সম্পাদন মূল্যায়নের সুবিধাজনক উপায় এবং অনুকূলিতকরণের জন্য গুরুত্বপূর্ণ।


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

আরো