ট্রেন্ডহান্টার w/MF মাল্টি-টাইমফ্রেম ট্রেন্ড কৌশল

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

img

সারসংক্ষেপ

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

কৌশল নীতি

এই কৌশলটির মূল নীতি হল একাধিক সময়সীমার মধ্যে একাধিক প্রযুক্তিগত সূচকের ব্যাপক বিশ্লেষণ। বিশেষ করেঃ

  1. ইচিমোকু ক্লাউডঃ মূল্য এবং মেঘের আপেক্ষিক অবস্থান, পাশাপাশি চলমান গড় এবং মেঘের আপেক্ষিক অবস্থান বিশ্লেষণ করে, বর্তমান বাজারের প্রবণতা নির্ধারণ করা হয়। যখন দাম মেঘের উপরে থাকে এবং চলমান গড়ও মেঘের উপরে থাকে, তখন এটি একটি আপট্রেন্ড হিসাবে বিবেচিত হয়; অন্যথায়, এটি একটি ডাউনট্রেন্ড হিসাবে বিবেচিত হয়।

  2. সুপারট্রেন্ডঃ মূল্য এবং সুপারট্রেন্ডের আপেক্ষিক অবস্থান বিশ্লেষণ করে, বর্তমান বাজারের প্রবণতা নিশ্চিত করা হয়। যখন মূল্য সুপারট্রেন্ডের উপরে থাকে, তখন এটি একটি আপট্রেন্ড হিসাবে বিবেচিত হয়; অন্যথায়, এটি একটি ডাউনট্রেন্ড হিসাবে বিবেচিত হয়।

  3. ওয়েভট্রেন্ডঃ ওয়েভট্রেন্ড সূচকের দিক এবং অবস্থান বিশ্লেষণ করে, বর্তমান বাজারের প্রবণতা নির্ধারণ করা হয়। যখন ওয়েভট্রেন্ড বাড়ছে এবং ওভারকোপ জোন পৌঁছায়নি, এটি একটি আপট্রেন্ড হিসাবে বিবেচিত হয়; যখন ওয়েভট্রেন্ড হ্রাস পাচ্ছে এবং ওভারসোল জোন পৌঁছায়নি, এটি একটি ডাউনট্রেন্ড হিসাবে বিবেচিত হয়।

  4. মানিফ্লোঃ মানিফ্লো সূচকের অবস্থা বিশ্লেষণ করে, বর্তমান বাজারের প্রবণতা নিশ্চিত করা হয়। যখন মানিফ্লো ইতিবাচক হয়, এটি একটি আপট্রেন্ড হিসাবে বিবেচিত হয়; অন্যথায়, এটি একটি ডাউনট্রেন্ড হিসাবে বিবেচিত হয়।

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

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

  1. একাধিক সূচক, উচ্চ নির্ভরযোগ্যতার উপর ভিত্তি করে বিস্তৃত বিচারঃ এই কৌশলটি একাধিক প্রযুক্তিগত সূচককে ব্যাপকভাবে বিবেচনা করে, যা বিভিন্ন বাজারের অবস্থার অধীনে একে অপরকে পরিপূরক করে, বাজারের প্রবণতাকে ব্যাপকভাবে প্রতিফলিত করে এবং একটি সূচকের সাথে ঘটতে পারে এমন ত্রুটিগুলি এড়ায়।

  2. কঠোর প্রবেশের শর্ত, ঘন ঘন ট্রেডিং এড়ানোঃ কৌশলটি কঠোর প্রবেশের শর্তাবলী নির্ধারণ করে, একটি অবস্থানে প্রবেশের আগে একাধিক সূচক একযোগে পূরণ করা প্রয়োজন, যা কার্যকরভাবে পরিসীমা সীমাবদ্ধ বাজারে ঘন ঘন ট্রেডিং এড়ায় এবং কৌশলটির অপচয় হ্রাস করে।

  3. মাল্টি-টাইমফ্রেম বিশ্লেষণ, বড় প্রবণতা উপলব্ধি করাঃ কৌশলটি একাধিক সময়সীমার উপর বিশ্লেষণ সম্পাদন করে, যা কৌশলটিকে স্বল্পমেয়াদী গোলমালের হস্তক্ষেপ এড়িয়ে বৃহত্তর দৃষ্টিকোণ থেকে বাজারের প্রধান প্রবণতা উপলব্ধি করতে সহায়তা করে।

  4. স্পষ্ট স্টপ-লস কৌশল, নিয়ন্ত্রণযোগ্য ঝুঁকিঃ কৌশলটি স্টপ-লসের শর্ত হিসাবে সুপারট্রেন্ড ব্যবহার করে। একবার বাজারের প্রবণতা পরিবর্তিত হলে, কৌশলটি সময়মতো ক্ষতি বন্ধ করতে পারে, ক্ষতিগুলি গ্রহণযোগ্য পরিসরের মধ্যে রাখতে পারে।

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

  1. গতিশীল সামঞ্জস্যের অভাব, বাজারের পরিবর্তনের প্রতিক্রিয়া জানানোর সীমিত ক্ষমতাঃ এই কৌশলটির পরামিতি সেটিংগুলি স্থির এবং বাজারের অবস্থার সাথে সামঞ্জস্য করার ক্ষমতা নেই। যখন বাজারের পরিস্থিতি উল্লেখযোগ্যভাবে পরিবর্তিত হয়, তখন কৌশলটি ব্যর্থ হতে পারে।

  2. অত্যধিক কঠোর প্রবেশের শর্তগুলি ভাল সুযোগগুলি হারাতে পারেঃ কৌশলটির প্রবেশের শর্তগুলি খুব কঠোর, যা যদিও এটি ঘন ঘন ট্রেডিং এড়াতে পারে তবে কৌশলটি কিছু ভাল প্রবেশের সুযোগ হারাতে পারে।

  3. চরম বাজারের অবস্থার সাথে অভিযোজনযোগ্যতা অজানাঃ সাধারণ বাজারের অবস্থার অধীনে কৌশলটি ভালভাবে কাজ করে, তবে কিছু চরম বাজারের অবস্থার সাথে তার অভিযোজনযোগ্যতা যেমন দ্রুত এবং উল্লেখযোগ্য বিপরীতমুখীতা এখনও পরীক্ষা করা হয়নি।

  4. তুলনামূলকভাবে সহজ স্টপ-লস কৌশল, অপ্টিমাইজেশনের জন্য জায়গাঃ বর্তমানে, কৌশলটি কেবল স্টপ-লস শর্ত হিসাবে সুপারট্রেন্ড ব্যবহার করে। যদিও এটি সহজ এবং সোজা, ঝুঁকি আরও ভালভাবে নিয়ন্ত্রণ করার জন্য স্টপ-লস কৌশলটিতে আরও অপ্টিমাইজেশনের জায়গা রয়েছে।

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

  1. বাজারের অবস্থার বিচার প্রবর্তন করুন, পরামিতিগুলিকে গতিশীলভাবে সামঞ্জস্য করুনঃ বিভিন্ন বাজারের পরিবেশে অভিযোজিত হওয়ার জন্য বাজারের অবস্থার পরিবর্তন অনুযায়ী কৌশলগত পরামিতিগুলিকে গতিশীলভাবে সামঞ্জস্য করার জন্য বাজারের অবস্থার বিচার সূচক যেমন অস্থিরতার সূচকগুলি প্রবর্তন করার বিষয়টি বিবেচনা করুন।

  2. এন্ট্রি শর্তাদি অপ্টিমাইজ করুন, সংবেদনশীলতা উন্নত করুনঃ আরও ট্রেডিং সুযোগগুলি ক্যাপচার করার জন্য নির্ভরযোগ্যতা নিশ্চিত করে কৌশলটির সংবেদনশীলতা উন্নত করার জন্য আরও নিশ্চিতকরণ সূচক প্রবর্তনের মতো এন্ট্রি শর্তাদি অপ্টিমাইজ করার বিষয়টি বিবেচনা করুন।

  3. চরম বাজার অবস্থার জন্য প্রতিক্রিয়া ব্যবস্থা যোগ করুনঃ কিছু চরম বাজার অবস্থার জন্য, যেমন দ্রুত এবং উল্লেখযোগ্য বিপরীতমুখী, চরম বাজার অবস্থার মধ্যে কৌশল ঝুঁকি হ্রাস করার জন্য স্টপ-লস বা ট্রেডিং স্থগিত করার তীব্রতা বাড়ানোর মতো কিছু বিশেষ প্রতিক্রিয়া ব্যবস্থা প্রবর্তন বিবেচনা করুন।

  4. স্টপ-লস কৌশল অপ্টিমাইজ করুন, ঝুঁকি নিয়ন্ত্রণ ক্ষমতা উন্নত করুনঃ আরও স্টপ-লস শর্ত প্রবর্তন বিবেচনা করুন, যেমন সময় স্টপ-লস, পরিসীমা স্টপ-লস ইত্যাদি। ঝুঁকি আরও ভালভাবে নিয়ন্ত্রণ করার জন্য কিছু গতিশীল স্টপ-লস কৌশল প্রবর্তন করার বিষয়টিও বিবেচনা করুন, যেমন ট্রেলিং স্টপ-লস।

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

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

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

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


/*backtest
start: 2024-02-01 00:00:00
end: 2024-02-29 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © godzcopilot / blockybears

// Thanks to anthonyf50 for his MTF Ichimoku https://www.tradingview.com/script/Pw9cBFma/
// Thanks to KivancOzbilgic for his SuperTrend https://www.tradingview.com/script/r6dAP7yi/
// Thanks to ZenAndTheArtOfTrading / PineScriptMastery for their Higher Timeframe EMA https://www.tradingview.com/script/Vh3XG9sD-Higher-Timeframe-EMA/
//  Thanks to LazyBear for WaveTrend Oscillator https://www.tradingview.com/script/2KE8wTuF-Indicator-WaveTrend-Oscillator-WT/
//  Thanks to andreholanda73 for MFI+RSI Area https://www.tradingview.com/script/UlGZzUAr/

//@version=5
strategy("TrendHunter w/MF [Blocky]", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=80, initial_capital=1000, pyramiding=0)

// ================
// Strategy Inputs
// ================

// Defines user inputs for configuring the strategy.

// Inputs for EMA
len     = input.int(title="EMA Length", defval=200, group ='== EMA ==')
col     = input.bool(title="Colour EMA", defval=true, group ='== EMA ==')

// SuperTrend
Periods = input(title='ATR: Period', defval=10, group = '== Supertrend ==', inline = 'atr')
Multiplier = input.float(title='Mult', step=0.1, defval=3.0, group = '== Supertrend ==', inline = 'atr')
Src = input.source(title='Src', defval=hl2, group = '== Supertrend ==', inline = 'atr')

// Ichimoku
conversionPeriods = input.int(9, minval=1, title='Conversion', group = '== Ichimoku ==', inline = 'ich1')
basePeriods = input.int(26, minval=1, title='Base', group = '== Ichimoku ==', inline = 'ich1')
laggingSpan2Periods = input.int(52, minval=1, title='Lagging', group = '== Ichimoku ==', inline = 'ich2')
displacement = input.int(26, minval=1, title='Displacement', group = '== Ichimoku ==', inline = 'ich2')

// Ichimoku Display Options
isActiveConversion = input(false, 'Conversion', group = '== Ichimoku ==', inline = 'lines1')
isActiveBase = input(false, 'Base', group = '== Ichimoku ==', inline = 'lines1')
isActiveLagging = input(false, 'Lagging', group = '== Ichimoku ==', inline = 'lines1')
isActiveCloud = input(true, 'Cloud', group = '== Ichimoku ==', inline = 'lines1')


// Input for WaveTrend
n1 = input(9, 'Channel Length', group = '== WaveTrend ==', inline = 'wt1')
n2 = input(12, 'Average Length', group = '== WaveTrend ==', inline = 'wt1')

obLevel = input(60, 'Over Bought', group = '== WaveTrend ==', inline = 'wt2')
osLevel = input(-60, 'Over Sold', group = '== WaveTrend ==', inline = 'wt2')

// Input for Money Flow
rsiMFIperiod = input(60, 'Money Flow Length', group = '== Money Flow ==', inline = 'mf')
rsiMFIMultiplier = input(190, 'RSI+MFI Area multiplier', group = '== Money Flow ==', inline = 'mf')
MFRSIMA = input.string(defval='SMA', title='Money Flow MA Type', options=['RMA', 'SMA', 'EMA', 'WMA', 'VWMA'], group = '== Money Flow ==', inline = 'mf')


// ================
// Strategy Options
// ================

bTable = input.bool(false, title='Trade Table', group='== Strategy Options ==', tooltip = "Show table that shows current selected options and trade trade entry parameters")

bLong = input.bool(true, title='Enter Longs', group='== Strategy Options ==', inline = 'LongShort')
bShort = input.bool(true, title='Enter Shorts', group='== Strategy Options ==', inline = 'LongShort', tooltip = "Filter long / short trade signals")

bPriceCloud = input.bool(true, title='Price outside cloud', group='== Strategy Options ==', inline='PriceCloud')
priceActionOption = input.string(title="", defval="Close", options=["Close", "Candle Body", "Full Candle"], group = "== Strategy Options ==", inline='PriceCloud')

bPriceEMA = input.bool(false, title='Price above/below EMA', group='== Strategy Options ==', inline='PriceEMA')
priceEMAOption = input.string(title="", defval="Close", options=["Close", "Candle Body", "Full Candle"], group = "== Strategy Options ==", inline='PriceEMA')

bSuper = input.bool(true, title='Supertrend transistions', group='== Strategy Options ==', tooltip = "Trade in direction of the supertrend transitions")

bEMACloud1 = input.bool(true, title='EMA Outside Cloud', group='== Strategy Options ==', tooltip = "EMA must be outside the ichimoku cloud")
bEMACloud2 = input.bool(false, title='EMA above/below Cloud', group='== Strategy Options ==', tooltip = "Longs when EMA above the cloud.\nShort when EMA below the cloud")

bMFI = input.bool(false, title='Money Flow', group='== Strategy Options ==', tooltip = "Money Flow Green for Long\nMoney Flow Red for Short")
bWT = input.bool(false, title='Wavetrend', group='== Strategy Options ==', inline = 'WT')
bWTOB = input.bool(false, title='Overbought/sold', group='== Strategy Options ==', tooltip = "Longs when WT Rising\nShort when WT Falling\n\nRestrict entries if in overbough or oversold levels",inline = 'WT')

bExitHTFTrail = input.bool(true, title='Super Trend Exits', group='== Strategy Options ==', inline = 'Exits')


// ===========================
// EMA Functions and Plotting
// ===========================

// Calculate EMA
ema = ta.ema(close, len)
emaSmooth = request.security(syminfo.tickerid, "", ema[barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_on)[barstate.isrealtime ? 0 : 1]


// Draw EMA
plot(emaSmooth, color=col ? (close > emaSmooth ? color.rgb(76, 163, 175) : color.rgb(6, 23, 173)) : color.black, linewidth=2, title="HTF EMA")


// ==================================
// Supertrend Functions and Plotting
// ==================================

// Function to calculate SuperTrend
calcSuperTrend(src, atrPeriods, multiplier) =>
    atr = ta.atr(atrPeriods)
    up = src - multiplier * atr
    up1 = nz(up[1], up)
    up := close[1] > up1 ? math.max(up, up1) : up
    dn = src + multiplier * atr
    dn1 = nz(dn[1], dn)
    dn := close[1] < dn1 ? math.min(dn, dn1) : dn
    trend = 1
    trend := nz(trend[1], trend)
    trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
    [up, dn, trend]


// Fetching the higher time frame data
[HTF_up, HTF_dn, HTF_trend] = request.security(syminfo.tickerid, "", calcSuperTrend(hl2, Periods, Multiplier), lookahead=barmerge.lookahead_on)

// Plotting for the higher time frame
plot(HTF_trend == 1 ? HTF_up : HTF_dn, title='HTF Up Trend', color= HTF_trend == 1 ? color.green : color.red, linewidth=4)


// ===============================
// Ichimoku Functions and Plotting
// ===============================

// Function to convert timeframe to hours
f_convertTimeframeToHours(tf) =>
    val = 0.0
    if tf == "1S" or tf == "S"
        val := 1.0 / 3600.0
    else if str.contains(tf, "S")
        val := str.tonumber(str.replace(tf, "S", "")) / 3600.0
    else if tf == "1D" or tf == "D"
        val := 24.0
    else if str.contains(tf, "D")
        val := str.tonumber(str.replace(tf, "D", "")) * 24.0
    else if tf == "1W" or tf == "W"
        val := 24.0 * 7.0
    else if str.contains(tf, "W")
        val := str.tonumber(str.replace(tf, "W", "")) * 24.0 * 7.0
    else if tf == "1M" or tf == "M"
        val := 24.0 * 30.0  // Approximation for a month
    else if str.contains(tf, "M")
        val := str.tonumber(str.replace(tf, "M", "")) * 24.0 * 30.0  // Approximation for months
    else
        // Default to minutes
        val := str.tonumber(tf) / 60.0
    val

// Time
timeOffset = time - time[1]


// Returns the displacement based on the chart / HTF resolution
f_getDisplacement(_res) =>
    _res == '' ? displacement : math.round(f_convertTimeframeToHours(_res) / f_convertTimeframeToHours(timeframe.period) * displacement)
    //f_avgDilationOf(_res) * displacement

// Returns average value between lowest and highest
f_avgLH(_len) =>
    math.avg(ta.lowest(_len), ta.highest(_len))

// Returns f_donchian data 
f_donchian(_tf, _src) =>
    request.security(syminfo.tickerid, _tf, _src, barmerge.gaps_off, barmerge.lookahead_on)

// Returns ichimoku data
f_ichimokuData(_tf) =>
    _isShow = _tf == '' or f_convertTimeframeToHours(_tf) >= f_convertTimeframeToHours(timeframe.period)
    _displacement = _isShow ? f_getDisplacement(_tf) : na
    _Conversion = _isShow ? f_donchian(_tf, f_avgLH(conversionPeriods)) : na
    _Base = _isShow ? f_donchian(_tf, f_avgLH(basePeriods)) : na
    _Lagging = _isShow ? f_donchian(_tf, close) : na
    _SSA = _isShow ? math.avg(_Conversion, _Base) : na
    _SSB = _isShow ? f_donchian(_tf, f_avgLH(laggingSpan2Periods)) : na
    _middleCloud = _isShow ? _SSA[0] > _SSB[0] ? _SSA[0] - math.abs(_SSA[0] - _SSB[0]) / 2 : _SSA[0] + math.abs(_SSA[0] - _SSB[0]) / 2 : na
    [_displacement, _Conversion, _Base, _Lagging, _SSA, _SSB, _middleCloud]

// Plotting ichimoku data

[Displacement, Conversion, Base, Lagging, SSA, SSB, fisrtMiddleCloud] = f_ichimokuData("")

// ————— Conversion
plot(isActiveConversion ? Conversion : na, color=color.new(color.blue, 0), title=' Conversion', linewidth=1)
// ————— Base
plot(isActiveBase ? Base : na, color=color.new(color.fuchsia, 0), title=' Base', linewidth=2)
// ————— Lagging
plot(isActiveLagging ? Lagging : na, offset=-Displacement, color=color.new(color.green, 0), title=' Lagging')

// ————— SSA + SSB
ssa = plot(isActiveCloud ? SSA : na, offset=Displacement, color=color.new(color.green, 0), title=' SSA', linewidth=1)
ssb = plot(isActiveCloud ? SSB : na, offset=Displacement, color=color.new(color.red, 0), title=' SSB', linewidth=1)
fill(ssa, ssb, color=color.new(SSA > SSB ? color.green : color.red , 80), title=' Cloud')


// ===============================
// Makret Cypher Additions
// ===============================


// WaveTrend calculations
ap = hlc3
esa = ta.ema(ap, n1)
d = ta.ema(math.abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ta.ema(ci, n2)

wt1 = tci
wt2 = ta.sma(wt1, 3)

// WaveTrend plotting
//plot(0, color=color.rgb(120, 123, 134), title='Zero Line')
//plot(emaSmooth + wt1, color=color.rgb(191, 228, 255), style=plot.style_linebr, title='WaveTrend 1')
//plot(emaSmooth + wt2, color=color.rgb(56, 56, 56, 40), style=plot.style_linebr, title='WaveTrend 2')

// WaveTrend shapes
plotshape(ta.crossover(wt1, wt2) and wt2[2] < osLevel ? close : na, title='Pos Crossover', location=location.belowbar, style=shape.cross, size=size.small, color=color.rgb(63, 255, 0, 60))
plotshape(ta.crossover(wt2, wt1) and wt1[2] > osLevel ? close : na, title='Neg Crossover', location=location.abovebar, style=shape.cross, size=size.small, color=color.rgb(255, 82, 82, 60))
plotshape(ta.crossover(wt1, wt2) and osLevel ? close : na, title='Positive Crossover', location=location.belowbar, style=shape.triangleup, size=size.tiny, color=color.rgb(63, 255, 0, 60))
plotshape(ta.crossover(wt2, wt1) and obLevel ?  close : na, title='Negative Crossover', location=location.abovebar, style=shape.triangledown, size=size.tiny, color=color.rgb(255, 82, 82, 60))

// Function to determine WaveTrend direction and steepness
isWaveTrendUp() =>
    wt1Slope = wt1 - wt1[1]
    wt2Slope = wt2 - wt2[1]
    if wt1 > wt2 // wt1Slope > 0 and wt2Slope > 0
        1  // Both are going up
    else if wt1 < wt2 // wt1Slope < 0 and wt2Slope < 0
        2 // Both are going down
    else
        na  // Trends are not in the same direction



ma(matype, src, length) =>
    if matype == 'RMA'
        ta.rma(src, length)
    else
        if matype == 'SMA'
            ta.sma(src, length)
        else
            if matype == 'EMA'
                ta.ema(src, length)
            else
                if matype == 'WMA'
                    ta.wma(src, length)
                else
                    if matype == 'VWMA'
                        ta.vwma(src, length)
                    else
                        src

// Money Flow calculations
candleValue = (close - open) / (high - low)
MVC = ma(MFRSIMA, candleValue, rsiMFIperiod)
MVC := MVC * rsiMFIMultiplier
mfi_transp = math.abs(MVC) > 35 ? 0 : math.abs(MVC) > 30 ? 20 : math.abs(MVC) > 25 ? 30 : math.abs(MVC) > 20 ? 40 : math.abs(MVC) > 15 ? 50 : math.abs(MVC) > 10 ? 60 : math.abs(MVC) > 5 ? 65 : math.abs(MVC) > 2 ? 70 : 80
color_area = MVC > 0 ? color.rgb(76, 255, 80, mfi_transp) : color.rgb(255, 82, 82, mfi_transp)

// Money Flow plotting
// RSIMFIplot = plot(MVC * rsiMFIMultiplier, title='Money Flow', color=color_area, style=plot.style_area)
// fill(RSIMFIplot, plot(0), color_area)

plotshape(MVC > 0 ? true : na, title='MFI', location=location.top, style=shape.labeldown, size= size.tiny, color=color_area)
plotshape(MVC < 0 ? true : na, title='MFI', location=location.top, style= shape.labelup, size= size.tiny, color=color_area)




// ===============================
// Strategy Entries
// ===============================

// Checks whether price is inside the Ichimoku cloud
f_PriceCloud(dir) =>
    _enter = false
    if bPriceCloud
        if bLong and dir == 1
            _enter := switch priceActionOption
                "Close" => close > math.max(SSA[Displacement], SSB[Displacement])
                "Candle Body" => open > math.max(SSA[Displacement], SSB[Displacement]) and close > math.max(SSA[Displacement], SSB[Displacement])
                "Full Candle" => low > math.max(SSA[Displacement], SSB[Displacement]) and high > math.max(SSA[Displacement], SSB[Displacement]) 
        if bShort and dir == 2
            _enter := switch priceActionOption
                "Close" => close < math.min(SSA[Displacement], SSB[Displacement])
                "Candle Body" => open < math.min(SSA[Displacement], SSB[Displacement]) and close < math.min(SSA[Displacement], SSB[Displacement])
                "Full Candle" => low < math.min(SSA[Displacement], SSB[Displacement]) and high < math.min(SSA[Displacement], SSB[Displacement]) 
    else
        _enter := na
    _enter

// Checks whether price is above / below the ema
f_PriceEMA(dir) =>
    _enter = false
    if bPriceEMA
        if bLong and dir == 1
            _enter := switch priceEMAOption
                "Close" => close > math.max(SSA[Displacement], SSB[Displacement])
                "Candle Body" => open > math.max(SSA[Displacement], SSB[Displacement]) and close > math.max(SSA[Displacement], SSB[Displacement])
                "Full Candle" => low > math.max(SSA[Displacement], SSB[Displacement]) and high > math.max(SSA[Displacement], SSB[Displacement]) 
        if bShort and dir == 2
            _enter := switch priceEMAOption
                "Close" => close < math.min(SSA[Displacement], SSB[Displacement])
                "Candle Body" => open < math.min(SSA[Displacement], SSB[Displacement]) and close < math.min(SSA[Displacement], SSB[Displacement])
                "Full Candle" => low < math.min(SSA[Displacement], SSB[Displacement]) and high < math.min(SSA[Displacement], SSB[Displacement]) 
    else
        _enter := na
    _enter

// Checks HTF supertrend direction
f_Super(dir) =>
    _enter = false
    if bSuper
        if bLong and dir == 1
            _enter := HTF_trend == 1
        if bShort and dir == 2
            _enter := HTF_trend == -1
    else
        _enter := na

    _enter

// Checks whether ema is inside the Ichimoku cloud
f_EMACloud1(dir) =>
    _enter = false
    if bEMACloud1
        if bLong and dir == 1
            _enter := (emaSmooth > math.max(SSA[Displacement], SSB[Displacement])) or (emaSmooth < math.min(SSA[Displacement], SSB[Displacement]))
        if bShort and dir == 2
            _enter := (emaSmooth > math.max(SSA[Displacement], SSB[Displacement])) or (emaSmooth < math.min(SSA[Displacement], SSB[Displacement]))
    else
        _enter := na
    _enter

// Checks whether ema is above/below Ichimoku cloud
f_EMACloud2(dir) =>
    _enter = false
    if bEMACloud2
        if bLong and dir == 1
            _enter := emaSmooth > math.max(SSA[Displacement], SSB[Displacement])
        if bShort and dir == 2
            _enter := emaSmooth < math.min(SSA[Displacement], SSB[Displacement])
    else
        _enter := na
    _enter

// Checks whether moneyflow is positive
f_MFI(dir) =>
    _enter = false
    if bMFI
        if bLong and dir == 1
            _enter := MVC > 0
        if bShort and dir == 2
            _enter := MVC < 0
    else
        _enter := na
    _enter


// Checks whether wavetrend is rising or falling
f_WT(dir) =>
    _enter = false
    if bWT
        if bLong and dir == 1
            _enter := isWaveTrendUp() == dir
        if bShort and dir == 2
            _enter := isWaveTrendUp() == dir
    else
        _enter := na
    _enter


f_WTOB(dir) =>
    _enter = false
    if bWT and bWTOB
        if bLong and dir == 1
            _enter := wt1 < obLevel
        if bShort and dir == 2
            _enter := wt1 > osLevel
    else
        _enter := na
    _enter


// Check if a value is 'na' or true.
f_NATrue(val) =>
    _enter = false
    if na(val)
        _enter := true
    if val
        _enter := true
    _enter   
    

// Consolidates entry conditions.
f_checkCondition(dir) =>
    _enter = false
    if na(f_PriceCloud(dir)) and na(f_PriceEMA(dir)) and na(f_Super(dir)) and na(f_EMACloud1(dir)) and na(f_EMACloud2(dir)) and na(f_MFI(dir)) and na(f_WT(dir)) and na(f_WTOB(dir))
        _enter := false
    else if f_NATrue(f_PriceCloud(dir)) and f_NATrue(f_PriceEMA(dir)) and f_NATrue(f_Super(dir)) and f_NATrue(f_EMACloud1(dir)) and f_NATrue(f_EMACloud2(dir)) and f_NATrue(f_MFI(dir)) and f_NATrue(f_WT(dir)) and f_NATrue(f_WTOB(dir))
        _enter := true
    _enter

        
// Execute long trade entries
longCondition = bLong and f_checkCondition(1)
if (longCondition)
    strategy.entry("Long", strategy.long)

// Execute short trade entries
shortCondition = bShort and f_checkCondition(2)
if (shortCondition)
    strategy.entry("Short", strategy.short)

// Excute trade exits
exitLong = (bExitHTFTrail and (close < HTF_up or HTF_trend == -1))
exitShort = (bExitHTFTrail and (close > HTF_dn or HTF_trend == 1))

if exitLong
    strategy.close("Long")

if exitShort
    strategy.close("Short")

// Creates a table shoing all the user options and their current status for entering a trade
if bTable
    // Create a table
    tbl = table.new(position = position.bottom_right, columns = 4, rows = 11, bgcolor=color.new(color.black,100), border_width = 0, frame_width = 0)

    table.cell(tbl, 1, 0, "Selected", text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 0, "Long", bgcolor=na(bLong) ? color.new(color.black,100) : bShort ? color.rgb(4, 112, 8) : color.rgb(100, 7, 7), text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 0, "Short", bgcolor=na(bShort) ? color.new(color.black,100) : bShort ? color.rgb(4, 112, 8) : color.rgb(100, 7, 7), text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))

    table.cell(tbl, 0, 1, "Entry", text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 1, longCondition  ? "✓" : "✗", bgcolor=longCondition ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 1, shortCondition  ? "✓" : "✗", bgcolor=shortCondition ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))


    table.cell(tbl, 0, 3, "Price Cloud", text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 1, 3, bPriceCloud ? "✓" : "✗", bgcolor=na(bPriceCloud) ? color.new(color.black,100) : bPriceCloud ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 3, f_PriceCloud(1) ? "✓" : "✗", bgcolor=na(f_PriceCloud(1)) ? color.new(color.black,100) : f_PriceCloud(1) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 3, f_PriceCloud(2)  ? "✓" : "✗", bgcolor=na(f_PriceCloud(2)) ? color.new(color.black,100) : f_PriceCloud(2) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))

    table.cell(tbl, 0, 4, "Price EMA", text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 1, 4, bPriceEMA ? "✓" : "✗", bgcolor=na(bPriceEMA) ? color.new(color.black,100) : bPriceEMA ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 4, f_PriceEMA(1) ? "✓" : "✗", bgcolor=na(f_PriceEMA(1)) ? color.new(color.black,100) : f_PriceEMA(1) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 4, f_PriceEMA(2) ? "✓" : "✗", bgcolor=na(f_PriceEMA(2)) ? color.new(color.black,100) : f_PriceEMA(2) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))

    table.cell(tbl, 0, 5, "SuperTrend", text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 1, 5, bSuper ? "✓" : "✗", bgcolor=na(bSuper) ? color.new(color.black,100) : bSuper ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 5, f_Super(1) ? "✓" : "✗", bgcolor=na(f_Super(1)) ? color.new(color.black,100) : f_Super(1) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 5, f_Super(2) ? "✓" : "✗", bgcolor=na(f_Super(2)) ? color.new(color.black,100) : f_Super(2) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))

    table.cell(tbl, 0, 6, "EMA Outside Cloud", text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 1, 6, bEMACloud1 ? "✓" : "✗", bgcolor=na(bEMACloud1) ? color.new(color.black,100) : bEMACloud1 ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 6, f_EMACloud1(1) ? "✓" : "✗", bgcolor=na(f_EMACloud1(1)) ? color.new(color.black,100) : f_EMACloud1(1) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 6, f_EMACloud1(2) ? "✓" : "✗", bgcolor=na(f_EMACloud1(2)) ? color.new(color.black,100) : f_EMACloud1(2) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))

    table.cell(tbl, 0, 7, "EMA Above/Below Cloud", text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 1, 7, bEMACloud2 ? "✓" : "✗", bgcolor=na(bEMACloud2) ? color.new(color.black,100) : bEMACloud2 ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 7, f_EMACloud2(1) ? "✓" : "✗", bgcolor=na(f_EMACloud2(1)) ? color.new(color.black,100) : f_EMACloud2(1) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 7, f_EMACloud2(2) ? "✓" : "✗", bgcolor=na(f_EMACloud2(2)) ? color.new(color.black,100) : f_EMACloud2(2) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))

    table.cell(tbl, 0, 8, "Moneyflow", text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 1, 8, bMFI ? "✓" : "✗", bgcolor=na(bMFI) ? color.new(color.black,100) : bMFI ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 8, f_MFI(1) ? "✓" : "✗", bgcolor=na(f_MFI(1)) ? color.new(color.black,100) : f_MFI(1) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 8, f_MFI(2) ? "✓" : "✗", bgcolor=na(f_MFI(2)) ? color.new(color.black,100) : f_MFI(2) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))

    table.cell(tbl, 0, 9, "WaveTrend", text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 1, 9, bWT ? "✓" : "✗", bgcolor=na(bWT) ? color.new(color.black,100) : bWT ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 9, f_WT(1) ? "✓" : "✗", bgcolor=na(f_WT(1)) ? color.new(color.black,100) : f_WT(1) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 9, f_WT(2) ? "✓" : "✗", bgcolor=na(f_WT(2)) ? color.new(color.black,100) : f_WT(2) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))

    table.cell(tbl, 0, 10, "Overbought/Sold  " + str.tostring(wt1, '#.#'), text_halign = text.align_left, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 1, 10, bWTOB ? "✓" : "✗", bgcolor=na(bWTOB) ? color.new(color.black,100) : bWTOB ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 2, 10, f_WTOB(1) ? "✓" : "✗", bgcolor=na(f_WTOB(1)) ? color.new(color.black,100) : f_WTOB(1) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))
    table.cell(tbl, 3, 10, f_WTOB(2) ? "✓" : "✗", bgcolor=na(f_WTOB(2)) ? color.new(color.black,100) : f_WTOB(2) ? color.green : color.red, text_halign = text.align_center, text_size = size.small, text_color = color.rgb(207, 207, 207))


আরো