Pine Script v5 · Strategy
CITI Moku Strategy(Free) by @MiaIsTheNewBird
A Pine Script v5 strategy built on ATR (length), Cross (src, spt) and Crossover (close, tenkan). It has 7 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 25% of equity and pays 0.025 commission. 111 settings; defaults include Tenkan 9, Tenkan mult 2. and Kijun 26.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does CITI Moku Strategy(Free) by @MiaIsTheNewBird repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did CITI Moku Strategy(Free) by @MiaIsTheNewBird do on BTCUSDT 1D with default settings?
- −8.74%
- From 26 Jan 2024 to 21 Oct 2026, over 48 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does CITI Moku Strategy(Free) by @MiaIsTheNewBird run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 48 before, 48 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does CITI Moku Strategy(Free) by @MiaIsTheNewBird use a stop loss?
- Yes
- strategy.exit sets a stop on line 407, 408, 409, 410, 411.
- Does CITI Moku Strategy(Free) by @MiaIsTheNewBird run in Zeal Terminal?
- Yes
- It compiles in 228 ms and runs 1,000 bars in 600 ms, in the browser.
BTCUSDT · 1D · default settings
- Tenkan-Sen
- Kinjun-Sen
- Chikou Span
- Senkou Span A
- Senkou Span B
- Moving Average 1
- Price
- Bullish Signals
- Long Exit
- Bearish Signals
- Short Exit
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −8.74%
- −$873.93
- Buy and hold
- +102.5%
- same period
- Closed trades
- 48
- 34 won · 14 lost
- Profitable
- 70.8%
- of closed trades
- Profit factor
- 0.81
- gross profit ÷ gross loss
- Max drawdown
- 16.60%
- −$1,660.12
One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Note
13 settings have no label
In the settings dialog tenkan_mult (line 21), kijun_mult (line 23), spanB_mult (line 25), FilterType1MAType (line 159), FilterType1Len (line 160), setmaxLosingStreak (line 202), setmaxWinStreak (line 204), setmaxLosingDaysStreak (line 206), setMaxDrawdown (line 208), setMaxIntradayLoss (line 210), setNumberDailyTrades (line 212), setNumberWeeklyTrades (line 214), ontpBE (line 280) show an empty name. The labels on this page come from the variable names.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Ichimoku Lines & Cloud Settings | |||
| Tenkan | 9 | int | tenkan |
| Tenkan mult (no label in the script) | 2. | float | tenkan |
| Kijun | 26 | int | kijun |
| Kijun mult (no label in the script) | 8. | float | kijun |
| Senkou Span B | 52 | int | senkouB |
| Span B mult (no label in the script) | 8. | float | senkouB |
| Chikou Offset | 26 | int | Chikou Span |
| Kumo Offset | 26 | int | Senkou Span A Senkou Span B Filter2Long Filter2Short Filter3Long Filter3Short Filter4Long Filter4Short |
| Entry Signals Settings - Select Conditions for Entry | |||
| Price Crossing Tenkan Line | false | bool | Entry1Long Entry1Short |
| Tenkan Line Crossing Kijun Line | true | bool | Entry2Long Entry2Short |
| Price Crossing Kijun Line | false | bool | Entry3Long Entry3Short |
| Exit Signals Settings- Use as Indicator | |||
| Price Crossunder Tenkan Line | false | bool | Exit1Long Exit1Short |
| Tenkan Line Crossunder Kijun Line | true | bool | Exit2Long Exit2Short |
| Price Crossunder Kijun Line | false | bool | Exit3Long Exit3Short |
| Use as Indicator | |||
| Plot Buy Trades | true | bool | plotshape |
| Plot Sell Trades | true | bool | plotshape |
| Plot Buy- Exit Trades | true | bool | plotshape |
| Plot Sell- Exit Trades | true | bool | plotshape |
| Trade Direction | |||
| Long Deals | true | bool | goLong |
| Short Deals | true | bool | goShort |
| TP-SL Strategy | |||
| Wait End Deal | true | bool | goLong goShort |
| ReEntry Deal | true | bool | direction |
| 𝐓𝐚𝐤𝐞 𝐏𝐫𝐨𝐟𝐢𝐭 | ATR TP | string · options ['None', 'FIXED %', 'FIXED $', 'ATR TP', 'R:R', 'HH / LL'] | TypeStop stop0 tpcolor Take Stop line 305 line 310 line 328 line 340 line 350 plotchar |
| 𝐒𝐭𝐨𝐩 𝐋𝐨𝐬𝐬 Fixed%- Fixed SL/TP in percent. \n' + 'Fixed$- Fixed SL/TP in cash. \n' + 'Trailing %- Trailing stop in % like on exchanges. Regulated by the "Trailing%" parameter. \n' + 'Fast Trail- If in a long, it immediately follows the price when it rises otherwise it stands still. Vice versa for shorts. Regulated by the "Trailing% parameter. \n' + 'ATR - Fixed TP/SL depending on the current ATR. It is regulated by the "ATR period" | "Multiplier" parameters. \n' + 'R:R- Risk Reward sets the TP depending on the size of the SL. For example, if SL is $100, and R:R = 2, then the TP is $200. \n' + 'HH/LL- Searches for the last Extremum (High/Low) for the specified number of bars and sets a fixed Take. \n' + 'LO/HI Sets the SL for High/Low candles. "LO/HI" = 1 Sets the SL for the last High/Low. \n' + 'MA- Movinng Average SL. A very diverse type of SL. | ATR SL | string · options ['None', 'FIXED %', 'FIXED $', 'TRAILING', 'FAST TRAIL', 'ATR SL','ATR TRAIL','LO / HI', 'MA'] | DynamicStops TypeStop line 307 line 312 line 315 line 321 line 332 line 335 line 345 |
| Profit % | 4.5 | float · min 0.1 · step 0.1 | tpPrice |
| Stop % | 1.5 | float · min 0.1 · step 0.1 | slPrice |
| Profit $ | 333 | float · min 1 · step 5 | tpPrice |
| Stop $ | 100 | float · min 1 · step 5 | slPrice |
| ATR TP Period | 30 | int · min 1 · step 1 | StopATRTP |
| TP Multiplier | 3 | float · min 0.1 · step 0.1 | StopATRTP |
| ATR SL Period | 30 | int · min 1 · step 1 | StopATRSL |
| SL Multiplier | 4 | float · min 0.1 · step 0.1 | StopATRSL |
| Trailing % | 3 | float · min 0.1 · step 0.1 | StopL StopS stop |
| R:R 1: | 2 | float · min 0.5 · step 0.1 | tpPrice |
| Fixed RR𝐅𝐢𝐱𝐞𝐝 𝗥:𝗥 ➖ If the stop loss is Dynamic (Trailing or MA) then R:R can also be made Dynamic | true | bool | check |
| HH / LL | 200 | int · min 1 · step 5 | HiStop LoStop |
| LO / HI | 5 | int · min 1 · step 1 | HiStop LoStop |
| Add %𝐀𝐝𝐝 % ➖ If true, then with the "𝗦𝘁𝗼𝗽 %" parameter you can add percentages to any of the current SL. \nCan be especially useful when using Stop - 𝗔𝗧𝗥 or 𝗠𝗔 or 𝗟𝗢/𝗛𝗜. \nFor example with 𝗟𝗢/𝗛𝗜 to put a stop for the last High/Low and add 0.5% additional Stoploss | false | bool | line 354 |
| MA Stop | EMA | string · options ['EMA', 'HMA','SMA'] | maSType |
| Len | 15 | int · min 1 · step 2 | maSType |
| Step𝐌𝐀 𝐒𝐭𝐨𝐩 ➖ allows to choose which MA to use. \n𝐋𝐞𝐧 ➖ Length of chosen MA. \n𝐒𝐭𝐞𝐩 ➖% step of change MA. Step = 0 will use the selected MA without changes. \nWARNING: When 𝐀𝐝𝐝 % is on, the MA calculation changes.. | 0.1 | float · min 0 · step 0.1 | Stop |
| Take Profit Levels | |||
| 🇹🇵¹ | true | bool | slbecheck exit End_1 TP 1 |
| � | 5 | int · min 1 · max 100 · step 5 | exit End_1 |
| 🇹🇵² | false | bool | slbecheck exit End_2 TP 2 |
| � | 20 | int · min 1 · max 100 · step 5 | exit End_2 |
| 🇹🇵³ | false | bool | slbecheck exit End_3 TP 3 |
| � | 50 | int · min 1 · max 100 · step 5 | exit End_3 |
| 🇸🇱⁰ | false | bool | exit End_0 SL 0 |
| � | 30 | int · min 1 · max 100 · step 5 | exit End_0 |
| Paint Strategy and TP/SL on ChartPlots trades for TP-SL Strategy | false | bool | plotColx plotColy Take Stop Price plotchar TP 1 TP 2 TP 3 SL 0 |
| SL 0 Position | 1 | int · min 1 · max 2 | stop0 |
| Ontp BE (no label in the script) | false | bool | line 384 |
| Breakeven on TP𝐒𝐋 𝟎 𝐏𝐨𝐬𝐢𝐭𝐢𝐨𝐧 ➖ Changes the position of the intermediate Stop Loss.\nThe value = 3 - the middle. \n𝐁𝐫𝐞𝐚𝐤𝐞𝐯𝐞𝐧 𝐨𝐧 𝐓𝐏 ➖ If true Set StopLoss to Breakeven after the specified TakeProfit is reached. | 2 | int · min 1 · max 3 | slbecheck slbe |
| CoolDown # BarsDo Not open a new position until # bars have passed since the last trade.\nValue=0 - disables the function. | 0 | int · min 0 | checkCoolDwn |
| Colors: FG | color.new(color.teal,70) | color | plotColx tpcolor Take plotchar |
| Bearcolor (no label in the script) | color.new(color.red,70) | color | plotColx Stop plotchar SL 0 |
| BG | color.new(color.teal,80) | color | plotColy fill |
| Bearcolorb (no label in the script) | color.new(color.red,80) | color | plotColy fill |
| 📆 Time Filter 📆 | |||
true | bool | start ftimestamp | |
true | bool | end etimestamp | |
| Start Timeㅤㅤ | timestamp('UTC 01 Jan 2020 00:00') | time | start ftimestamp |
| End Time ㅤ ㅤ | timestamp('UTC 31 Dec 2050 23:45') | time | end etimestamp |
| Time Session 00:00 - 00:00 to disable. | 0000-0000 | session | ses |
| UTC Match this time zone with that of your graph so that all values are displayed correctly. | UTC | string · options ["UTC-10", "UTC-8", "UTC-7", "UTC-6", "UTC-5", "UTC-4", "UTC-3", "UTC", "UTC+1", "UTC+2", "UTC+3", "UTC+4", "UTC+4:30", "UTC+5", "UTC+5:30", "UTC+6", "UTC+7", "UTC+8", "UTC+9", "UTC+9:30", "UTC+10", "UTC+11", "UTC+12", "UTC+12:45", "UTC+13"] | ses monF tueF wedF thuF friF satF sunF ftimestamp etimestamp |
| Monㅤ | true | bool | monF |
| Tueㅤ | true | bool | tueF |
| Wedㅤ | true | bool | wedF |
| Thuㅤ | true | bool | thuF |
| Friㅤ | true | bool | friF |
| Satㅤ | true | bool | satF |
| Sunㅤ | true | bool | sunF |
| Signal Filters | |||
| 1. MA Filter | true | bool | Filter1Ma Filter1Long Filter1Short |
| Filter Type1MAType (no label in the script) | EMA | string · options ['EMA','HMA','SMA'] | ma Filter1Ma |
| Filter Type1Len (no label in the script)MA Type, MA Source, MA Length\nLong = close > MA\nShort = close < MA | 21 | int · min 1 | ma Filter1Ma |
| Show MA Line? | false | bool | Moving Average 1 |
| 2. Above/Below Kumo Cloud Settings | true | bool | Filter2Long Filter2Short |
| 3. Bullish/Bearish Kumo Cloud Filter Settings | false | bool | Filter3Long Filter3Short |
| 4. Bullish/Bearish Kijun Filter Settings | false | bool | Filter4Long Filter4Short |
| Risk Management | |||
| Setmax Losing Streak (no label in the script) | false | bool | okToTradeLossStreak |
| Loss Streak | 15 | int · min 1 | okToTradeLossStreak |
| Setmax Win Streak (no label in the script) | false | bool | okToTradeWinStreak |
| Win Streak 𝐋𝐨𝐬𝐬 𝐒𝐭𝐫𝐞𝐚𝐤 ➖ Set Max number of consecutive loss trades. \n𝐖𝐢𝐧 𝐒𝐭𝐫𝐞𝐚𝐤 ➖ Max Winning Streak Length. | 15 | int · min 1 | okToTradeWinStreak |
| Setmax Losing Days Streak (no label in the script) | false | bool | countConsLossDays |
| Row Loss InDay | 3 | int · min 1 | countConsLossDays |
| Set Max Drawdown (no label in the script) | false | bool | condmaxdrawdown |
| DrawDown %𝐑𝐨𝐰 𝐋𝐨𝐬𝐬 𝐈𝐧𝐃𝐚𝐲 ➖ Max of consecutive days with a loss in a row. \n𝐃𝐫𝐚𝐰𝐃𝐨𝐰𝐧% ➖ Max DrawDown (in % of strategy equity). | 10 | int · min 1 · max 100 | condmaxdrawdown |
| Set Max Intraday Loss (no label in the script) | false | bool | condintradayloss |
| InDay Loss % | 3 | int · min 1 · max 100 | condintradayloss |
| Set Number Daily Trades (no label in the script) | false | bool | tradesIntradayCount |
| Daily Trades 𝐈𝐧𝐃𝐚𝐲 𝐋𝐨𝐬𝐬 % ➖ Set Max Intraday Loss. \n𝐃𝐚𝐢𝐥𝐲 𝐓𝐫𝐚𝐝𝐞𝐬 ➖ Limit the number of MAX trades per day. | 10 | int · min 1 · max 100 | tradesIntradayCount |
| Set Number Weekly Trades (no label in the script) | false | bool | okToTradeWeekly |
| Weekly Trades𝐖𝐞𝐞𝐤𝐥𝐲 𝐓𝐫𝐚𝐝𝐞𝐬 ➖ Limit the number of MAX trades per week. | 50 | int · min 1 · max 100 | okToTradeWeekly |
| Order Size | EQUITY | string · options ['NONE', 'EQUITY', 'SIZE', 'CONTRACTS'] | eqty line 397 |
| Use Net Profit𝐔𝐬𝐞 𝐍𝐞𝐭 𝐏𝐫𝐨𝐟𝐢𝐭 ➖ On/Off the use of profit in the following trades. *Only works if the type is EQUITY | true | bool | line 397 |
| 🇪🇶🇺🇮🇹🇾 | 30 | int · min 1 · max 100 | eqty |
| 🇸🇮🇿🇪 | 1000 | int · min 1 | eqty |
| 🇨🇴🇳🇹🇷🇦🇨🇹🇸𝐎𝐫𝐝𝐞𝐫 𝐒𝐢𝐳𝐞: \n𝐍𝐎𝐍𝐄 ➖ Use the default position size settings in Tab "Properties". \n𝐄𝐐𝐔𝐈𝐓𝐘 ➖ % per trade from the initial capital. \n𝐒𝐈𝐙𝐄 ➖ Fixed size amount of trade. \n𝐂𝐎𝐍𝐓𝐑𝐀𝐂𝐓𝐒 ➖ The fixed amount of the deal in contracts. \n | 1 | int · min 1 | eqty |
| API for Long Bot Alerts | |||
| API Long Entry | | text_area | entry Short |
| API for Short Bot Alerts | |||
| API Short Entry | | text_area | entry Short |
| API TP-SL Strategy Exit Alerts | |||
| API Exit 0 | | text_area | exit End_0 |
| API Exit 1 | | text_area | exit End_1 |
| API Exit 2 | | text_area | exit End_2 |
| API Exit 3 | | text_area | exit End_3 |
| API Exit X | | text_area | exit End_X |
| 📊 Plots 📊 | |||
| Plot Dashboard | true | bool | la |
| Profit ㅤ ㅤ🟢 if > to: | 0.1 | float | statusProfit |
| ㅤ🔴 if < to: | 0 | float | statusProfit |
| Win Rateㅤ🟢 if > to: | 70 | float · min 0 · max 100 | statusWinRate |
| ㅤ🔴 if < to: | 50 | float · min 0 · max 100 | statusWinRate |
| P. Factorㅤ🟢 if > to: | 2 | float · min 0 | statusPFactor |
| ㅤ🔴 if < to: | 1 | float · min 0 | statusPFactor |
What it calculates
- ATRlength
atr · line 30 - Crosssrc, spt
max · line 40 - Crosssrc, spt
min · line 41 - Crossoverclose, tenkan
Entry1Long · line 61 - Crossovertenkan, kijun
Entry2Long · line 62 - Crossoverclose, kijun
Entry3Long · line 63 - Crossunderclose, tenkan
Entry1Short · line 64 - Crossundertenkan, kijun
Entry2Short · line 65 - Crossunderclose, kijun
Entry3Short · line 66 - Crossunderclose, tenkan
Exit1Long · line 75 - Crossundertenkan, kijun
Exit2Long · line 76 - Crossunderclose, kijun
Exit3Long · line 77 - Crossoverclose, tenkan
Exit1Short · line 78 - Crossovertenkan, kijun
Exit2Short · line 79 - Crossoverclose, kijun
Exit3Short · line 80 - ATR ATR TP Period (30)
StopATRTP · line 327 - ATR ATR SL Period (30)
StopATRSL · line 331 - Highesthigh, HH / LL (200)
HiStop · line 341 - Lowestlow, HH / LL (200)
LoStop · line 342 - Valuewhenbarstate.isfirst, time, 0 · chosen by UTC
ftimestamp · line 485
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
The script has 184 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Short long | goLong | On | 400 |
| Open Short short | goShort | On | 403 |
| Exit End_0 stop and limit | inTrade | On | 407 |
| Exit End_1 stop and limit | inTrade | On | 408 |
| Exit End_2 stop and limit | inTrade | On | 409 |
| Exit End_3 stop and limit | inTrade | On | 410 |
| Exit End_X stop and limit | inTrade | On | 411 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationuses varip; reads realtime-only state. Live values can differ from history.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −8.7% | +102.5% | 48 | 71% | 0.81 | 16.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −2.8% | +5.5% | 36 | 69% | 0.76 | 4.5% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −13.1% | +9.8% | 50 | 74% | 0.82 | 17.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +4.2% | +8.4% | 46 | 78% | 1.27 | 5.4% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −29.2% | +16.7% | 35 | 69% | 0.54 | 37.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +3.4% | +21.5% | 55 | 73% | 1.15 | 8.7% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −19.7% | +148.3% | 49 | 65% | 0.65 | 31.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 49 | 71% | 1.00 | 6.3% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 16 | 69% | −$271.55 |
| Sideways market | 22 | 73% | −$490.69 |
| Falling market | 10 | 70% | −$111.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
27.2%
The 95th percentile of the worst drawdown when the same 48 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 13.9% to 27.2%; the tick is what actually happened, 15.4%. Order luck alone moves it this much.
All 48 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 2 May 2024 58,365.00 | 20 May 2024 71,023.70 | 18 | −$32.62 |
| short | 2 May 2024 58,365.00 | 20 May 2024 71,023.70 | 18 | −$619.71 |
| short | 30 Jun 2024 60,986.70 | 4 Jul 2024 59,355.20 | 4 | $3.68 |
| short | 30 Jun 2024 60,986.70 | 5 Jul 2024 54,460.90 | 5 | $283.81 |
| short | 6 Jul 2024 56,628.80 | 8 Jul 2024 54,924.70 | 2 | $4.28 |
| short | 6 Jul 2024 56,628.80 | 17 Jul 2024 65,717.40 | 11 | −$442.21 |
| short | 5 Aug 2024 58,161.00 | 6 Aug 2024 54,018.80 | 1 | $9.76 |
| short | 5 Aug 2024 58,161.00 | 20 Oct 2024 69,169.80 | 76 | −$497.58 |
| long | 7 Nov 2024 75,572.00 | 10 Nov 2024 77,341.10 | 3 | $2.99 |
| long | 7 Nov 2024 75,572.00 | 11 Nov 2024 82,648.20 | 4 | $231.12 |
| long | 12 Nov 2024 88,648.00 | 13 Nov 2024 90,667.70 | 1 | $2.99 |
| long | 12 Nov 2024 88,648.00 | 21 Nov 2024 96,726.80 | 9 | $230.96 |
| long | 22 Nov 2024 98,317.10 | 5 Dec 2024 100,582.00 | 13 | $3.10 |
| long | 22 Nov 2024 98,317.10 | 16 Dec 2024 107,375.00 | 24 | $239.60 |
| long | 17 Dec 2024 106,059.00 | 30 Dec 2024 91,640.50 | 13 | −$19.28 |
| long | 17 Dec 2024 106,059.00 | 30 Dec 2024 91,640.50 | 13 | −$366.23 |
| long | 3 Jan 2025 96,984.80 | 6 Jan 2025 99,745.00 | 3 | $3.79 |
| long | 3 Jan 2025 96,984.80 | 20 Jan 2025 108,025.00 | 17 | $291.76 |
| long | 21 Jan 2025 102,260.00 | 22 Jan 2025 106,144.00 | 1 | $5.24 |
| long | 21 Jan 2025 102,260.00 | 26 Feb 2025 85,787.20 | 36 | −$429.57 |
| short | 27 Feb 2025 84,250.10 | 28 Feb 2025 81,429.70 | 1 | $4.41 |
| short | 27 Feb 2025 84,250.10 | 8 May 2025 99,291.90 | 70 | −$454.54 |
| long | 9 May 2025 103,262.00 | 12 May 2025 105,644.00 | 3 | $2.86 |
| long | 9 May 2025 103,262.00 | 10 Jul 2025 112,790.00 | 62 | $221.12 |
| long | 11 Jul 2025 116,010.00 | 12 Jul 2025 118,158.00 | 1 | $2.35 |
| long | 11 Jul 2025 116,010.00 | 5 Oct 2025 124,604.00 | 86 | $181.96 |
| long | 6 Oct 2025 123,482.00 | 10 Oct 2025 112,815.00 | 4 | −$11.55 |
| long | 6 Oct 2025 123,482.00 | 10 Oct 2025 112,815.00 | 4 | −$219.44 |
| short | 17 Oct 2025 108,194.00 | 3 Nov 2025 105,477.00 | 17 | $3.19 |
| short | 17 Oct 2025 108,194.00 | 14 Nov 2025 97,324.80 | 28 | $246.01 |
| short | 15 Nov 2025 94,594.00 | 17 Nov 2025 91,710.10 | 2 | $4.00 |
| short | 15 Nov 2025 94,594.00 | 21 Nov 2025 83,058.40 | 6 | $307.52 |
| short | 22 Nov 2025 85,129.40 | 30 Jan 2026 82,095.50 | 69 | $4.85 |
| short | 22 Nov 2025 85,129.40 | 3 Feb 2026 72,993.80 | 73 | $372.31 |
| short | 4 Feb 2026 75,770.20 | 5 Feb 2026 73,165.80 | 1 | $4.86 |
| short | 4 Feb 2026 75,770.20 | 5 Feb 2026 66,081.30 | 1 | $347.52 |
| short | 6 Feb 2026 62,909.90 | 17 Apr 2026 77,965.60 | 70 | −$35.71 |
| short | 6 Feb 2026 62,909.90 | 17 Apr 2026 77,965.60 | 70 | −$678.42 |
| long | 27 Apr 2026 78,657.60 | 4 May 2026 80,585.00 | 7 | $3.32 |
| long | 27 Apr 2026 78,657.60 | 2 Jun 2026 68,377.70 | 36 | −$344.24 |
| short | 3 Jun 2026 66,760.80 | 4 Jun 2026 64,142.80 | 1 | $5.15 |
| short | 3 Jun 2026 66,760.80 | 5 Jun 2026 59,950.60 | 2 | $256.63 |
| short | 6 Jun 2026 61,056.50 | 24 Jun 2026 59,271.70 | 18 | $3.94 |
| short | 6 Jun 2026 61,056.50 | 20 Aug 2026 70,575.30 | 75 | −$407.07 |
| long | 21 Aug 2026 73,027.00 | 22 Aug 2026 78,338.00 | 1 | $9.45 |
| long | 21 Aug 2026 73,027.00 | 22 Aug 2026 78,800.80 | 1 | $195.36 |
| long | 23 Aug 2026 77,074.90 | 24 Aug 2026 78,542.70 | 1 | $2.48 |
| long | 23 Aug 2026 77,074.90 | 21 Sep 2026 82,946.00 | 29 | $192.58 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| CITI Moku Strategy(Free) by @MiaIsTheNewBird this page | — | v5 strategy | −8.7% | 48 | 16.6% |
| Positive Bars - Strategy by tweakerID | lowest highest valuewhen atr | v4 strategy | −40.3% | 7 | 54.7% |
| Big Bar Strategy by tweakerID | lowest highest valuewhen atr | v4 strategy | −56.6% | 13 | 57.1% |
| SuperTrend Multi Time Frame Long and Short Trading Strategy by ranga_technologies | atr highest lowest valuewhen | v5 strategy | No trades on this market | ||
| Inside Bar Strategy w- SL by tweakerID | lowest highest valuewhen atr | v4 strategy | −61.3% | 25 | 65.0% |
| Modulo Logic + EMA Strat by tweakerID | lowest highest valuewhen atr | v4 strategy | −50.8% | 16 | 54.7% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- 8 settings use the untyped input() (line 20, 21, 22, 23, 24, 25, 26, 27). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Same 48 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 20: input() → input.int()
- Line 21: input() → input.float()
- Line 22: input() → input.int()
- Line 23: input() → input.float()
- Line 24: input() → input.int()
- Line 25: input() → input.float()
- Line 26: input() → input.int()
- Line 27: input() → input.int()
⋯//-------------------------------------------------------------------------------tenkan_len = input(9,'Tenkan',inline='tenkan',group="Ichimoku Lines & Cloud Settings")+tenkan_len = input.int(9,'Tenkan',inline='tenkan',group="Ichimoku Lines & Cloud Settings")-tenkan_mult = input(2.,'',inline='tenkan',group="Ichimoku Lines & Cloud Settings")+tenkan_mult = input.float(2.,'',inline='tenkan',group="Ichimoku Lines & Cloud Settings")-kijun_len = input(26,'Kijun',inline='kijun',group="Ichimoku Lines & Cloud Settings")+kijun_len = input.int(26,'Kijun',inline='kijun',group="Ichimoku Lines & Cloud Settings")-kijun_mult = input(8.,'',inline='kijun',group="Ichimoku Lines & Cloud Settings")+kijun_mult = input.float(8.,'',inline='kijun',group="Ichimoku Lines & Cloud Settings")-spanB_len = input(52,'Senkou Span B',inline='span',group="Ichimoku Lines & Cloud Settings")+spanB_len = input.int(52,'Senkou Span B',inline='span',group="Ichimoku Lines & Cloud Settings")-spanB_mult = input(8.,'',inline='span',group="Ichimoku Lines & Cloud Settings")+spanB_mult = input.float(8.,'',inline='span',group="Ichimoku Lines & Cloud Settings")-chikou_offset = input(26,'Chikou Offset',group="Ichimoku Lines & Cloud Settings")+chikou_offset = input.int(26,'Chikou Offset',group="Ichimoku Lines & Cloud Settings")-kumo_offset = input(26,'Kumo Offset',group="Ichimoku Lines & Cloud Settings")+kumo_offset = input.int(26,'Kumo Offset',group="Ichimoku Lines & Cloud Settings")//------------------------------------------------------------------------------⋯Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 48 before, 48 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=5+//@version=6//@strategy_alert_message {{strategy.order.alert_message}}"⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 228 ms | With a workaround 1,000 bars in 600 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0///@version=5//@strategy_alert_message {{strategy.order.alert_message}}"//Base Indicator SuperIchi from LuxALgo with changes//Created by Mia & Nomi//Backtester template from @Haldro //Dashboard & Time filter template from Vermtstrategy('CITI Moku Strategy(Free) by @MiaIsTheNewBird', shorttitle = "CITI Moku Strategy (Free)", overlay = true, initial_capital = 10000, commission_value = 0.025, default_qty_value = 25, slippage = 1, pyramiding = 0, max_lines_count = 500, max_labels_count = 500, currency = currency.USD, default_qty_type = strategy.percent_of_equity)//------------------------------------------------------------------------------tenkan_len = input(9,'Tenkan',inline='tenkan',group="Ichimoku Lines & Cloud Settings")tenkan_mult = input(2.,'',inline='tenkan',group="Ichimoku Lines & Cloud Settings")kijun_len = input(26,'Kijun',inline='kijun',group="Ichimoku Lines & Cloud Settings")kijun_mult = input(8.,'',inline='kijun',group="Ichimoku Lines & Cloud Settings")spanB_len = input(52,'Senkou Span B',inline='span',group="Ichimoku Lines & Cloud Settings")spanB_mult = input(8.,'',inline='span',group="Ichimoku Lines & Cloud Settings")chikou_offset = input(26,'Chikou Offset',group="Ichimoku Lines & Cloud Settings")kumo_offset = input(26,'Kumo Offset',group="Ichimoku Lines & Cloud Settings")//------------------------------------------------------------------------------avg(src,length,mult)=> atr = ta.atr(length)*mult up = hl2 + atr dn = hl2 - atr upper = 0.,lower = 0. upper := src[1] < upper[1] ? math.min(up,upper[1]) : up lower := src[1] > lower[1] ? math.max(dn,lower[1]) : dn os = 0,max = 0.,min = 0. os := src > upper ? 1 : src < lower ? 0 : os[1] spt = os == 1 ? lower : upper max := ta.cross(src,spt) ? math.max(src,max[1]) : os == 1 ? math.max(src,max[1]) : spt min := ta.cross(src,spt) ? math.min(src,min[1]) : os == 0 ? math.min(src,min[1]) : spt math.avg(max,min)tenkan = avg(close,tenkan_len,tenkan_mult)kijun = avg(close,kijun_len,kijun_mult)senkouA = math.avg(kijun,tenkan)senkouB = avg(close,spanB_len,spanB_mult)chikou = close//------------------------------------------------------------------------------plot(tenkan, title = 'Tenkan-Sen', linewidth=1, color=#32C4EE )plot(kijun, title = 'Kinjun-Sen', linewidth=1, color=#EC3E6F )plot(chikou, title = 'Chikou Span', linewidth=1, offset = -chikou_offset+1, color=color.fuchsia, display=display.none)cloud_a = #0C3D4E cloud_b = #451721 A = plot(senkouA,'Senkou Span A',na,offset=kumo_offset-1)B = plot(senkouB,'Senkou Span B',na,offset=kumo_offset-1)fill(A,B,senkouA > senkouB ? cloud_a : cloud_b)//Entry SignalsEntry1 = input.bool(false, title="Price Crossing Tenkan Line", group="Entry Signals Settings - Select Conditions for Entry")Entry2 = input.bool(true, title="Tenkan Line Crossing Kijun Line", group="Entry Signals Settings - Select Conditions for Entry")Entry3 = input.bool(false, title="Price Crossing Kijun Line", group="Entry Signals Settings - Select Conditions for Entry")Entry1Long = Entry1 ? ta.crossover(close,tenkan) : trueEntry2Long = Entry2 ? ta.crossover(tenkan,kijun) : trueEntry3Long = Entry3 ? ta.crossover(close,kijun) : trueEntry1Short = Entry1 ? ta.crossunder(close,tenkan) : trueEntry2Short = Entry2 ? ta.crossunder(tenkan,kijun) : trueEntry3Short = Entry3 ? ta.crossunder(close,kijun) : true//Assemble EntrieslongEntry = Entry1Long and Entry2Long and Entry3Long shortEntry = Entry1Short and Entry2Short and Entry3Short // Exit SignalsExit1 = input.bool(false, title="Price Crossunder Tenkan Line", group="Exit Signals Settings- Use as Indicator")Exit2 = input.bool(true, title="Tenkan Line Crossunder Kijun Line", group="Exit Signals Settings- Use as Indicator")Exit3 = input.bool(false, title="Price Crossunder Kijun Line", group="Exit Signals Settings- Use as Indicator")//Assemble Exit FiltersExit1Long = Exit1 ? ta.crossunder(close,tenkan) : trueExit2Long = Exit2 ? ta.crossunder(tenkan,kijun) : trueExit3Long = Exit3 ? ta.crossunder(close,kijun) : trueExit1Short = Exit1 ? ta.crossover(close,tenkan) : trueExit2Short = Exit2 ? ta.crossover(tenkan,kijun) : trueExit3Short = Exit3 ? ta.crossover(close,kijun) : true//Assemble ExitslongExit = Exit1Long and Exit2Long and Exit3Long shortExit = Exit1Short and Exit2Short and Exit3Short ///Plot Letters as Indicatorsvar bool PlotLong = input.bool (true, "Plot Buy Trades" , group="Use as Indicator")var bool PlotShorts = input.bool (true, "Plot Sell Trades" , group="Use as Indicator")var bool PlotLongExit = input.bool (true, "Plot Buy- Exit Trades" , group="Use as Indicator")var bool PlotShortsExit = input.bool (true, "Plot Sell- Exit Trades" , group="Use as Indicator")//Backtester from @Haldro// —————— ToolTipsTTreversesignal = 'Wait End Deal- Enable/Disable waiting for a trade to close at Stop Loss/Take Profit. Until the trade closes on the Stop Loss or Take Profit, no new trade will open.'TTreOpenDeal = 'ReEntry Deal- If true trade was long and SL/TP was reached then go long again and vice versa. \n' + 'ReOpen Deal- If true and Wait End Deal is false then in case you are in a Long position and a new signal to Long, you will reEnter a new Long position and vice versa for Shorts.'TTslType = 'Fixed%- Fixed SL/TP in percent. \n' + 'Fixed$- Fixed SL/TP in cash. \n' + 'Trailing %- Trailing stop in % like on exchanges. Regulated by the "Trailing%" parameter. \n' + 'Fast Trail- If in a long, it immediately follows the price when it rises otherwise it stands still. Vice versa for shorts. Regulated by the "Trailing% parameter. \n' + 'ATR - Fixed TP/SL depending on the current ATR. It is regulated by the "ATR period" | "Multiplier" parameters. \n' + 'R:R- Risk Reward sets the TP depending on the size of the SL. For example, if SL is $100, and R:R = 2, then the TP is $200. \n' + 'HH/LL- Searches for the last Extremum (High/Low) for the specified number of bars and sets a fixed Take. \n' + 'LO/HI Sets the SL for High/Low candles. "LO/HI" = 1 Sets the SL for the last High/Low. \n' + 'MA- Movinng Average SL. A very diverse type of SL.'// —————— Main InputsbullDeal = input.bool (true, ' Long Deals ', group='Trade Direction', inline='deal') bearDeal = input.bool (true, ' Short Deals', group='Trade Direction', inline='deal') groupset = 'TP-SL Strategy'waitEndDeal = input.bool (true, ' Wait End Deal ', group=groupset, inline='ord1') reEntryDeal = input.bool (true, ' ReEntry Deal ', group=groupset, inline='ord1')tpType = input.string ('ATR TP', ' 𝐓𝐚𝐤𝐞 𝐏𝐫𝐨𝐟𝐢𝐭', group=groupset, inline='type', options=['None', 'FIXED %', 'FIXED $', 'ATR TP', 'R:R', 'HH / LL'])slType = input.string ('ATR SL', ' 𝐒𝐭𝐨𝐩 𝐋𝐨𝐬𝐬 ', group=groupset, inline='type', options=['None', 'FIXED %', 'FIXED $', 'TRAILING', 'FAST TRAIL', 'ATR SL','ATR TRAIL','LO / HI', 'MA'], tooltip=TTslType)grouptakes = 'Take Profit Levels'ontake1 = input.bool (true, '🇹🇵¹', group=grouptakes, inline='take')qtake1 = input.int (5, '�', group=grouptakes, inline='take', minval=1, step=5, maxval=100)ontake2 = input.bool (false, '🇹🇵²', group=grouptakes, inline='take')qtake2 = input.int (20, '�', group=grouptakes, inline='take', minval=1, step=5, maxval=100)ontake3 = input.bool (false, '🇹🇵³', group=grouptakes, inline='take')qtake3 = input.int (50, '�', group=grouptakes, inline='take', minval=1, step=5, maxval=100)onstop0 = input.bool (false, '🇸🇱⁰ ', group=grouptakes, inline='take')qstop0 = input.int (30, '�', group=grouptakes, inline='take', minval=1, step=5, maxval=100)// ———————————————— SIGNAL FOR BACKTEST SYSTEM ————————————————Entrysignals_ = longEntry ? +1 : shortEntry ? -1 : 0// —————— Variables InitialisationEntrysignals = nz(Entrysignals_)bull = Entrysignals == +1 // +1 is bull signalbear = Entrysignals == -1 // -1 is bear signal//Backtester //Credit ©VertMTstartFilter = input.bool (group='📆 Time Filter 📆', title=" ", defval=true, inline="Start")endFilter = input.bool (group='📆 Time Filter 📆', title=" ", defval=true, inline="End")startTime = input.time (group='📆 Time Filter 📆', title="Start Timeㅤㅤ", defval=timestamp('UTC 01 Jan 2020 00:00'), inline="Start")endTime = input.time (group='📆 Time Filter 📆', title="End Time ㅤ ㅤ", defval=timestamp('UTC 31 Dec 2050 23:45'), inline="End")session = input.session (group='📆 Time Filter 📆', title="Time Session ", defval='0000-0000', tooltip="00:00 - 00:00 to disable.")zoneTime = input.string (group='📆 Time Filter 📆', title="UTC ", defval="UTC", options = ["UTC-10", "UTC-8", "UTC-7", "UTC-6", "UTC-5", "UTC-4", "UTC-3", "UTC", "UTC+1", "UTC+2", "UTC+3", "UTC+4", "UTC+4:30", "UTC+5", "UTC+5:30", "UTC+6", "UTC+7", "UTC+8", "UTC+9", "UTC+9:30", "UTC+10", "UTC+11", "UTC+12", "UTC+12:45", "UTC+13"], tooltip="Match this time zone with that of your graph so that all values are displayed correctly.")mon = input.bool (group='📆 Time Filter 📆', title="Monㅤ ", defval=true, inline="Days")tue = input.bool (group='📆 Time Filter 📆', title="Tueㅤ ", defval=true, inline="Days")wed = input.bool (group='📆 Time Filter 📆', title="Wedㅤ ", defval=true, inline="Days")thu = input.bool (group='📆 Time Filter 📆', title="Thuㅤ ", defval=true, inline="Days")fri = input.bool (group='📆 Time Filter 📆', title="Friㅤ ", defval=true, inline="Days")sat = input.bool (group='📆 Time Filter 📆', title="Satㅤ ", defval=true, inline="Days")sun = input.bool (group='📆 Time Filter 📆', title="Sunㅤ ", defval=true, inline="Days")// 📆 Time Filter 📆 —————tradeDateIsAllowed() => start = startFilter ? time >= startTime : true end = endFilter ? time <= endTime : true ses = time == time("S", session, zoneTime) ? true : false monF = ( dayofweek(time, zoneTime) == dayofweek.monday ) and mon ? true : false tueF = ( dayofweek(time, zoneTime) == dayofweek.tuesday ) and tue ? true : false wedF = ( dayofweek(time, zoneTime) == dayofweek.wednesday ) and wed ? true : false thuF = ( dayofweek(time, zoneTime) == dayofweek.thursday ) and thu ? true : false friF = ( dayofweek(time, zoneTime) == dayofweek.friday ) and fri ? true : false satF = ( dayofweek(time, zoneTime) == dayofweek.saturday ) and sat ? true : false sunF = ( dayofweek(time, zoneTime) == dayofweek.sunday ) and sun ? true : false dayF = monF or tueF or wedF or thuF or friF or satF or sunF ? true : false filter = start ? end ? ses ? dayF ? true : false : false : false : falsedateRange = tradeDateIsAllowed()// ————————————————————————————————————————————— Signal Filters ——————————————————————————————————————————————————————————— \\ // Credit @pAulseperformancegroupsignal = 'Signal Filters'FilterType1 = input.bool (true, '1. MA Filter', group=groupsignal, inline='FT1')FilterType1MAType = input.string ('EMA', '', group=groupsignal, inline='FT1', options=['EMA','HMA','SMA'])FilterType1Len = input.int (21, '', group=groupsignal, inline='FT1', minval=1, tooltip='MA Type, MA Source, MA Length\nLong = close > MA\nShort = close < MA')var bool ma1Status = input.bool(false, group=groupsignal, title="Show MA Line?")source = closeMA(FilterType4MAType, source, FilterType4Len) => ma = 0.0 if FilterType4MAType == "SMA" // Simple ma := ta.sma(source, FilterType4Len) if FilterType4MAType == "EMA" // Exponential ma := ta.ema(source, FilterType4Len) if FilterType4MAType == "VWMA" // Volume Weighted ma := ta.vwma(source, FilterType4Len) if FilterType4MAType == "HMA" // Hull MA ma := ta.hma(source, FilterType4Len) resultMA = mama = MA(FilterType1MAType, source, FilterType1Len)plot(ma, "Moving Average 1", color = ma1Status ? color.yellow : na)FilterType2 = input.bool (true, '2. Above/Below Kumo Cloud Settings', group=groupsignal, inline='FT2')FilterType3 = input.bool (false, '3. Bullish/Bearish Kumo Cloud Filter Settings', group=groupsignal, inline='FT3')FilterType4 = input.bool (false, '4. Bullish/Bearish Kijun Filter Settings', group=groupsignal, inline='FT4')// —————— Filter 1: Moving AverageFilter1Ma = FilterType1 ? MA(FilterType1MAType, close, FilterType1Len) : 0.Filter1Long = FilterType1 ? close > Filter1Ma : trueFilter1Short = FilterType1 ? close < Filter1Ma : true// Filter 2: Above/Below Kumo Cloud SettingsFilter2Long = FilterType2 ? close > math.max(senkouA[kumo_offset-1],senkouB[kumo_offset-1]): trueFilter2Short = FilterType2 ? close < math.min(senkouA[kumo_offset-1],senkouB[kumo_offset-1]): true// Filter 3: Bullish/Bearish Kumo Cloud Filter SettingsFilter3Long = FilterType3 ? senkouA[kumo_offset-1] > senkouB[kumo_offset-1] : true Filter3Short = FilterType3 ? senkouA[kumo_offset-1] < senkouB[kumo_offset-1] : true// Filter 4: Bullish/Bearish Kijun Filter SettingsFilter4Long = FilterType4 ? kijun > math.max(senkouA[kumo_offset-1],senkouB[kumo_offset-1]) : trueFilter4Short = FilterType4 ? kijun < math.min(senkouA[kumo_offset-1],senkouB[kumo_offset-1]) : true// —————— Filter 12: Bullish/Bearish Chikou Span Settings// —————— Assemble FiltersFilterLongOK = Filter1Long and Filter2Long and Filter3Long and Filter4LongFilterShortOK = Filter1Short and Filter2Short and Filter3Short and Filter4Short// Risk Managment \\ // Credit @Daveattgrouprisk = 'Risk Management'setmaxLosingStreak = input.bool (false, '', group=grouprisk, inline='1')maxLosingStreak = input.int (15, 'Loss Streak ', group=grouprisk, inline='1', minval=1)setmaxWinStreak = input.bool (false, '', group=grouprisk, inline='1')maxWinStreak = input.int (15, 'Win Streak ', group=grouprisk, inline='1', minval=1, tooltip='𝐋𝐨𝐬𝐬 𝐒𝐭𝐫𝐞𝐚𝐤 ➖ Set Max number of consecutive loss trades. \n𝐖𝐢𝐧 𝐒𝐭𝐫𝐞𝐚𝐤 ➖ Max Winning Streak Length.')setmaxLosingDaysStreak = input.bool (false, '', group=grouprisk, inline='2')maxLosingDaysStreak = input.int (3, 'Row Loss InDay', group=grouprisk, inline='2', minval=1)setMaxDrawdown = input.bool (false, '', group=grouprisk, inline='2')maxPercDd = input.int (10, 'DrawDown %', group=grouprisk, inline='2', minval=1, maxval=100, tooltip='𝐑𝐨𝐰 𝐋𝐨𝐬𝐬 𝐈𝐧𝐃𝐚𝐲 ➖ Max of consecutive days with a loss in a row. \n𝐃𝐫𝐚𝐰𝐃𝐨𝐰𝐧% ➖ Max DrawDown (in % of strategy equity).')setMaxIntradayLoss = input.bool (false, '', group=grouprisk, inline='3')maxIntradayLoss = input.int (3, 'InDay Loss % ', group=grouprisk, inline='3', minval=1, maxval=100)setNumberDailyTrades = input.bool (false, '', group=grouprisk, inline='3')maxDailyTrades = input.int (10, 'Daily Trades ', group=grouprisk, inline='3', minval=1, maxval=100, tooltip='𝐈𝐧𝐃𝐚𝐲 𝐋𝐨𝐬𝐬 % ➖ Set Max Intraday Loss. \n𝐃𝐚𝐢𝐥𝐲 𝐓𝐫𝐚𝐝𝐞𝐬 ➖ Limit the number of MAX trades per day.')setNumberWeeklyTrades = input.bool (false, '', group=grouprisk, inline='4')maxWeeklyTrades = input.int (50, 'Weekly Trades', group=grouprisk, inline='4', minval=1, maxval=100, tooltip='𝐖𝐞𝐞𝐤𝐥𝐲 𝐓𝐫𝐚𝐝𝐞𝐬 ➖ Limit the number of MAX trades per week.')QTYMethod = input.string ('EQUITY', ' Order Size', group=grouprisk, inline=' ', options=['NONE', 'EQUITY', 'SIZE', 'CONTRACTS'])useNetProfit = input.bool (true, 'Use Net Profit', group=grouprisk, inline=' ', tooltip='𝐔𝐬𝐞 𝐍𝐞𝐭 𝐏𝐫𝐨𝐟𝐢𝐭 ➖ On/Off the use of profit in the following trades. *Only works if the type is EQUITY')riskPerc = input.int (30, '🇪🇶🇺🇮🇹🇾', group=grouprisk, inline='.', minval=1, maxval=100)riskSize = input.int (1000, '🇸🇮🇿🇪', group=grouprisk, inline='.', minval=1)riskCntr = input.int (1, '🇨🇴🇳🇹🇷🇦🇨🇹🇸', group=grouprisk, inline='.', minval=1, tooltip='𝐎𝐫𝐝𝐞𝐫 𝐒𝐢𝐳𝐞: \n𝐍𝐎𝐍𝐄 ➖ Use the default position size settings in Tab "Properties". \n𝐄𝐐𝐔𝐈𝐓𝐘 ➖ % per trade from the initial capital. \n𝐒𝐈𝐙𝐄 ➖ Fixed size amount of trade. \n𝐂𝐎𝐍𝐓𝐑𝐀𝐂𝐓𝐒 ➖ The fixed amount of the deal in contracts. \n')// —————— Order Sizeeqty = switch QTYMethod 'NONE' => na 'EQUITY' => riskPerc / close 'SIZE' => riskSize / close 'CONTRACTS' => riskCntr//// —————— Intraday Loss %condintradayloss = setMaxIntradayLoss ? maxIntradayLoss : 100strategy.risk.max_intraday_loss(value=condintradayloss, type=strategy.percent_of_equity)// —————— Max Drawdown %condmaxdrawdown = setMaxDrawdown ? maxPercDd : 100strategy.risk.max_drawdown(value=condmaxdrawdown, type=strategy.percent_of_equity)// —————— Daily trades calculationtradesIntradayCount = setNumberDailyTrades ? maxDailyTrades : 1000strategy.risk.max_intraday_filled_orders(count=tradesIntradayCount)// —————— Weekly trades calculationtradesLastWeek = 0tradesLastWeek := dayofweek == dayofweek.monday and dayofweek != dayofweek[1] ? strategy.closedtrades[1] + strategy.opentrades[1] : tradesLastWeek[1]// —————— Calculate number of trades this weekweeklyTrades = strategy.closedtrades + strategy.opentrades - tradesLastWeekokToTradeWeekly = setNumberWeeklyTrades ? weeklyTrades < maxWeeklyTrades : true// —————— Consecutive loss days in a rowcountConsLossDays = setmaxLosingDaysStreak ? maxLosingDaysStreak : 1000strategy.risk.max_cons_loss_days(countConsLossDays)// —————— Calculate the total losing streaksnewLoss = strategy.losstrades > strategy.losstrades[1] and strategy.wintrades == strategy.wintrades[1] and strategy.eventrades == strategy.eventrades[1]// —————— Determine current losing streak lengthstreakLossLen = 0streakLossLen := newLoss ? nz(streakLossLen[1]) + 1 : strategy.wintrades > strategy.wintrades[1] or strategy.eventrades > strategy.eventrades[1] ? 0 : nz(streakLossLen[1])// —————— Check if losing streak is under max allowedokToTradeLossStreak = setmaxLosingStreak ? streakLossLen < maxLosingStreak : true// —————— Calculate the total winning streaksnewWin = strategy.wintrades > strategy.wintrades[1] and strategy.losstrades == strategy.losstrades[1] and strategy.eventrades == strategy.eventrades[1]// —————— Figure out current winning streak lengthstreakWinLen = 0streakWinLen := newWin ? nz(streakWinLen[1]) + 1 : strategy.losstrades > strategy.losstrades[1] or strategy.eventrades > strategy.eventrades[1] ? 0 : nz(streakWinLen[1])// —————— Check if winning streak is under max allowedokToTradeWinStreak = setmaxWinStreak ? streakWinLen < maxWinStreak : true// TP-SL Exit StrategypercentTP = input.float (4.5, ' Profit % ', group=groupset, inline='fix', minval=0.1, step=0.1)percentSL = input.float (1.5, ' Stop % ', group=groupset, inline='fix', minval=0.1, step=0.1)moneyTP = input.float (333, ' Profit $ ', group=groupset, inline='mon', minval=1, step=5)moneySL = input.float (100, ' Stop $ ', group=groupset, inline='mon', minval=1, step=5)ATRLenTP = input.int (30, ' ATR TP Period ', group=groupset, inline='atrTP', minval=1, step=1)ATRMultTP = input.float (3, ' TP Multiplier', group=groupset, inline='atrTP', minval=0.1, step=0.1)ATRLenSL = input.int (30, ' ATR SL Period ', group=groupset, inline='atrSL', minval=1, step=1)ATRMultSL = input.float (4, 'SL Multiplier', group=groupset, inline='atrSL', minval=0.1, step=0.1)trailPerc = input.float (3, ' Trailing % ', group=groupset, inline='trl', minval=0.1, step=0.1)riskReward = input.float (2, ' R:R 1:', group=groupset, inline='trl', minval=0.5, step=0.1)fixedRR = input.bool (true, ' Fixed RR', group=groupset, inline='trl', tooltip='𝐅𝐢𝐱𝐞𝐝 𝗥:𝗥 ➖ If the stop loss is Dynamic (Trailing or MA) then R:R can also be made Dynamic')HHLL = input.int (200, ' HH / LL ', group=groupset, inline='hls', minval=1, step=5)LoHi = input.int (5, ' LO / HI ', group=groupset, inline='hls', minval=1, step=1)addPerc = input.bool (false, ' Add %', group=groupset, inline='hls', tooltip='𝐀𝐝𝐝 % ➖ If true, then with the "𝗦𝘁𝗼𝗽 %" parameter you can add percentages to any of the current SL. \nCan be especially useful when using Stop - 𝗔𝗧𝗥 or 𝗠𝗔 or 𝗟𝗢/𝗛𝗜. \nFor example with 𝗟𝗢/𝗛𝗜 to put a stop for the last High/Low and add 0.5% additional Stoploss')maStopType = input.string ('EMA', ' MA Stop', group=groupset, inline='mas', options=['EMA', 'HMA','SMA'])maStopLen = input.int (15, ' Len', group=groupset, inline='mas', minval=1, step=2)maPerc = input.float (0.1, ' Step', group=groupset, inline='mas', minval=0, step=0.1, tooltip='𝐌𝐀 𝐒𝐭𝐨𝐩 ➖ allows to choose which MA to use. \n𝐋𝐞𝐧 ➖ Length of chosen MA. \n𝐒𝐭𝐞𝐩 ➖% step of change MA. Step = 0 will use the selected MA without changes. \nWARNING: When 𝐀𝐝𝐝 % is on, the MA calculation changes..')var bool PaintStrategy= input.bool (false, "Paint Strategy and TP/SL on Chart" , group=grouptakes, tooltip="Plots trades for TP-SL Strategy")slNumber = input.int (1, ' SL 0 Position', group=grouptakes, inline='pos', minval=1, maxval=2)ontpBE = input.bool (false, '', group=grouptakes, inline='pos')tpBEnumber = input.int (2, 'Breakeven on TP', group=grouptakes, inline='pos', minval=1, maxval=3, tooltip='𝐒𝐋 𝟎 𝐏𝐨𝐬𝐢𝐭𝐢𝐨𝐧 ➖ Changes the position of the intermediate Stop Loss.\nThe value = 3 - the middle. \n𝐁𝐫𝐞𝐚𝐤𝐞𝐯𝐞𝐧 𝐨𝐧 𝐓𝐏 ➖ If true Set StopLoss to Breakeven after the specified TakeProfit is reached.')barCoolDwn = input.int (0, ' CoolDown # Bars', group=grouptakes, inline=' ', minval=0, tooltip='Do Not open a new position until # bars have passed since the last trade.\nValue=0 - disables the function.')// —————— Trade variablesentry = strategy.position_avg_pricesizePos = strategy.position_sizeinLong = sizePos > 0inShort = sizePos < 0inTrade = inLong or inShortinPos = (inLong and not inShort[1]) or (inShort and not inLong[1])var ID = 'TradeID'var tpPrice = float(na)var slPrice = float(na)// —————— Entry solutionsdirection = 0directionL = bull and (nz(direction[1]) == 0 or nz(direction[1]) == -1)directionS = bear and (nz(direction[1]) == 0 or nz(direction[1]) == +1)direction := directionL ? +1 : directionS ? -1 : (reEntryDeal ? direction[1] : direction[0])checkCoolDwn = barCoolDwn >0 ? not inTrade[barCoolDwn] : trueOkToTrade = dateRange and okToTradeLossStreak and okToTradeWinStreak and checkCoolDwngoLong = ( waitEndDeal ? not inTrade and direction==+1 : direction==+1 ) and bullDeal and OkToTrade and FilterLongOK goShort = ( waitEndDeal ? not inTrade and direction==-1 : direction==-1 ) and bearDeal and OkToTrade and FilterShortOK // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\DynamicStops = (slType == 'TRAILING' or slType == 'FAST TRAIL' or slType == 'MA')// —————— Fixed SL/TPif tpType == 'FIXED %' tpPrice := inLong and not inTrade[1] ? entry * (1 + percentTP/100) : inShort and not inTrade[1] ? entry * (1 - percentTP/100) : tpPriceif slType == 'FIXED %' slPrice := inLong and not inTrade[1] ? entry * (1 - percentSL/100) : inShort and not inTrade[1] ? entry * (1 + percentSL/100) : slPrice// —————— Money SL/TPif tpType == 'FIXED $' tpPrice := inLong and not inTrade[1] ? entry + (moneyTP / math.abs(sizePos)) : inShort and not inTrade[1] ? entry - (moneyTP / math.abs(sizePos)) : tpPriceif slType == 'FIXED $' slPrice := inLong and not inTrade[1] ? entry - (moneySL / math.abs(sizePos)) : inShort and not inTrade[1] ? entry + (moneySL / math.abs(sizePos)) : slPrice// —————— Trailing Stopif slType == 'TRAILING' StopL = 0., StopS = 0. StopL := inLong ? math.max(close * (1 - trailPerc/100), StopL[1]) : 0 StopS := inShort ? math.min(close * (1 + trailPerc/100), StopS[1]) : 999999 slPrice := inLong ? StopL : inShort ? StopS : slPrice// —————— Fast Trailing Stopif slType == 'FAST TRAIL' var stop = float(na) stop := inLong and not inTrade[1] ? entry * (1 - trailPerc/100) : inShort and not inTrade[1] ? entry * (1 + trailPerc/100) : stop stop := inLong and close > close[1] ? stop + (close - close[1]) : inShort and close < close[1] ? stop + (close - close[1]) : stop slPrice := stop// —————— ATR Fixed TPStopATRTP = ta.atr(ATRLenTP) * ATRMultTPif tpType == 'ATR TP' tpPrice := inLong and not inTrade[1] ? entry + StopATRTP: inShort and not inTrade[1] ? entry - StopATRTP : tpPrice// —————— ATR Fixed SLStopATRSL = ta.atr(ATRLenSL) * ATRMultSLif slType == 'ATR SL' slPrice := inLong and not inTrade[1] ? entry - StopATRSL : inShort and not inTrade[1] ? entry + StopATRSL : slPrice// —————— LO / HI Stopif slType == 'LO / HI' HiStop = ta.highest(high, LoHi) LoStop = ta.lowest (low, LoHi) slPrice := inLong and not inTrade[1] ? LoStop : inShort and not inTrade[1] ? HiStop : slPrice// —————— HH / LL Takeif tpType == 'HH / LL' HiStop = ta.highest(high, HHLL) LoStop = ta.lowest (low, HHLL) tpPrice := inLong and not inTrade[1] ? HiStop : inShort and not inTrade[1] ? LoStop : tpPrice// —————— MA's Stopsif slType == 'MA' maSType = MA(maStopType, close, maStopLen) Stop = maSType * (maPerc / 100) slPrice := inLong ? math.max(nz(slPrice[1], 0), maSType - Stop) : inShort ? math.min(nz(slPrice[1], 999999), maSType + Stop) : na// —————— Risk Reward Takeif tpType == 'R:R' check = fixedRR ? not inTrade[1] : true tpPrice := inLong and check ? entry + (entry - slPrice) * riskReward : inShort and check ? entry - (slPrice - entry) * riskReward : tpPrice// —————— Add Percents to SLif addPerc check = DynamicStops ? true : not inTrade[1] slPrice := inLong and check ? slPrice * (1 - percentSL/100) : inShort and check ? slPrice * (1 + percentSL/100) : slPrice// —————— TPSL'sTypeStop = tpType != 'None' or slType == 'FIXED %' or slType == 'FIXED $' or slType == 'ATR' or slType == 'LO / HI'BuildLeveles(take, nTake) => // Creating Intermediate Levels of the SL/TP - by shifting the current TP/SL to the entry level nTakes = 4 var offset = float(na) offset := not inPos[1] ? (entry - take) : offset xentry = take + offset levels = array.new_float() for i = 1 to nTakes - 1 array.push(levels, xentry + (take - xentry) * i / (nTakes)) result = nTake >= 0 and nTake <= nTakes ? array.get(levels, nTake) : naCheckLevels(lvl, isTake) => // Check if the SL/TP is reached var float level = na if isTake and ((inLong and high >= lvl) or (inShort and low <= lvl)) level := entry if not isTake and ((inLong and low <= lvl) or (inShort and high >= lvl)) level := entry if not inTrade level := na level// —————— Get and Check Levelsstop0 = tpType != 'None' ? BuildLeveles(slPrice, slNumber-1) : slPrice , checkStop0 = TypeStop ? CheckLevels(stop0, false) : CheckLevels(stop0, true )take1 = BuildLeveles(TypeStop ? tpPrice : slPrice, 0) , checkTake1 = TypeStop ? CheckLevels(take1, true ) : CheckLevels(take1, false)take2 = BuildLeveles(TypeStop ? tpPrice : slPrice, 1) , checkTake2 = TypeStop ? CheckLevels(take2, true ) : CheckLevels(take2, false)take3 = BuildLeveles(TypeStop ? tpPrice : slPrice, 2) , checkTake3 = TypeStop ? CheckLevels(take3, true ) : CheckLevels(take3, false)// —————— Move Stop to Breakevenslbecheck = (tpBEnumber==1 and ontake1) or (tpBEnumber==2 and ontake2) or (tpBEnumber==3 and ontake3) if ontpBE and slbecheck and not DynamicStops slbe = TypeStop ? CheckLevels(BuildLeveles(tpPrice, tpBEnumber-1), true) : CheckLevels(BuildLeveles(slPrice, tpBEnumber-1), false) slPrice := slbe > 0 ? slbe : slPrice stop0 := slPrice == entry ? slPrice : stop0// ALERTSi_alert_message_long_txt = input.text_area(defval = "",title = 'API Long Entry' , group = 'API for Long Bot Alerts')i_alert_message_short_txt =input.text_area(defval = "",title = 'API Short Entry' , group = 'API for Short Bot Alerts')i_alert_txt_exit_TPSL0 = input.text_area(defval = "",title = 'API Exit 0' , group = 'API TP-SL Strategy Exit Alerts')i_alert_txt_exit_TPSL1 = input.text_area(defval = "",title = 'API Exit 1' , group = 'API TP-SL Strategy Exit Alerts')i_alert_txt_exit_TPSL2 = input.text_area(defval = "",title = 'API Exit 2' , group = 'API TP-SL Strategy Exit Alerts')i_alert_txt_exit_TPSL3 = input.text_area(defval = "",title = 'API Exit 3' , group = 'API TP-SL Strategy Exit Alerts')i_alert_txt_exit_TPSLX = input.text_area(defval = "",title = 'API Exit X' , group = 'API TP-SL Strategy Exit Alerts')// —————— Entry'seqty(qty) => QTYMethod=='EQUITY' ? qty / 100 * (strategy.initial_capital + (useNetProfit ? strategy.netprofit : 0)) : QTYMethod=='SIZE' ? qty / syminfo.pointvalue : qtyif goLong ID := 'Long' strategy.entry(ID, strategy.long, qty=eqty(eqty), comment=ID, alert_message = ID + i_alert_message_long_txt)if goShort ID := 'Short' strategy.entry(ID, strategy.short, qty=eqty(eqty), comment=ID, alert_message = ID + i_alert_message_short_txt)// —————— Exit'sqty(perc) => math.abs(sizePos*perc/100)if inTrade strategy.exit('End_0', onstop0 ? ID : 'na', qty=qty(qstop0), limit=tpPrice, stop=stop0, comment_profit='TP 0', comment_loss='SL 0', alert_message= ID + i_alert_txt_exit_TPSL0) strategy.exit('End_1', ontake1 ? ID : 'na', qty=qty(qtake1), limit=TypeStop ? take1 : tpPrice, stop=TypeStop ? slPrice : take1, comment_profit='TP 1', comment_loss='SL 1', alert_message= ID + i_alert_txt_exit_TPSL1) strategy.exit('End_2', ontake2 ? ID : 'na', qty=qty(qtake2), limit=TypeStop ? take2 : tpPrice, stop=TypeStop ? slPrice : take2, comment_profit='TP 2', comment_loss='SL 2', alert_message= ID + i_alert_txt_exit_TPSL2) strategy.exit('End_3', ontake3 ? ID : 'na', qty=qty(qtake3), limit=TypeStop ? take3 : tpPrice, stop=TypeStop ? slPrice : take3, comment_profit='TP 3', comment_loss='SL 3', alert_message= ID + i_alert_txt_exit_TPSL3) strategy.exit('End_X', ID, limit=tpPrice, stop=slPrice, comment_profit='TP X', comment_loss='SL X', alert_message= ID + i_alert_txt_exit_TPSLX)// ========================================================================================================================///==============================================================================================================// Plotting and Debugging - Style 1 - Paint Strategy// ========================================================================================================================bullcolor = input.color (color.new(color.teal,70), 'Colors: FG', group=grouptakes, inline='col')bearcolor = input.color (color.new(color.red,70), '', group=grouptakes, inline='col')bullcolorb = input.color (color.new(color.teal,80), 'BG', group=grouptakes, inline='col')bearcolorb = input.color (color.new(color.red,80), '', group=grouptakes, inline='col')//Style 1- Paint Strategy on ChartplotColx = inLong and PaintStrategy? bullcolor : inShort ? bearcolor : naplotColy = inLong and PaintStrategy ? bullcolorb : inShort ? bearcolorb : natpcolor = tpType != 'None' ? bullcolor : plotColxtp1 = plot(inPos and PaintStrategy? tpPrice : na, 'Take', color=tpType != 'None' ? bullcolor : plotColx, style=plot.style_linebr, editable=false)sl1 = plot(inPos and PaintStrategy ? slPrice : na, 'Stop', color=tpType != 'None' ? bearcolor : plotColx, style=plot.style_linebr, editable=false)en1 = plot(TypeStop and PaintStrategy ? (inLong and slPrice > entry or inShort and slPrice < entry ? slPrice : entry) : inPos ? close : na, 'Price', color=TypeStop ? #787b86 : na, style=plot.style_linebr)fill(tp1, en1, color=TypeStop ? bullcolorb : plotColy, editable=false)fill(sl1, en1, color=TypeStop ? bearcolorb : plotColy, editable=false)plotchar(inPos and not inPos[1] and PaintStrategy? tpPrice : na, 'Take Start', color=tpType != 'None' ? bullcolor : plotColx, char='?', location=location.absolute, size=size.tiny)plotchar(inPos and not inPos[1] and PaintStrategy? slPrice : na, 'Stop Start', color=tpType != 'None' ? bearcolor : plotColx, char='?', location=location.absolute, size=size.tiny)plot(inPos and ontake1 and not checkTake1[1] and PaintStrategy? take1 : na, 'TP 1', color=tpcolor, style=plot.style_linebr, editable=false)plot(inPos and ontake2 and not checkTake2[1] and PaintStrategy? take2 : na, 'TP 2', color=tpcolor, style=plot.style_linebr, editable=false)plot(inPos and ontake3 and not checkTake3[1] and PaintStrategy? take3 : na, 'TP 3', color=tpcolor, style=plot.style_linebr, editable=false)plot(inPos and onstop0 and not checkStop0[1] and PaintStrategy? stop0 : na, 'SL 0', color=bearcolor, style=plot.style_linebr, editable=false)//Style- Plot Letters on Chartplotshape(goLong and PlotLong,'Bullish Signals',text='Buy',location=location.belowbar, style=shape.labelup, size=size.tiny , color=#32C4EE , textcolor=color.white,offset=0)plotshape(inLong and longExit and PlotLong and PlotLongExit,'Long Exit',location=location.abovebar, style=shape.xcross , size=size.tiny, color=#32C4EE , textcolor=color.white,offset=2)plotshape(goShort and PlotShorts ,'Bearish Signals',text='Sell', location=location.abovebar, style=shape.labeldown, size=size.tiny , color=#EC3E6F , textcolor=color.white,offset=0)plotshape(inShort and shortExit and PlotShorts and PlotShortsExit ,'Short Exit',location=location.belowbar, style=shape.xcross, size=size.tiny, color=#EC3E6F , textcolor=color.white,offset=2)//Plot Dashboard// 📊 Plots 📊//The data collected during the backtest will be displayed on screen within a dashboard and various drawings to visualize the operations.plotDashboard = input.bool (group="📊 Plots 📊", title="Plot Dashboard ", defval=true)maxProfit = input.float (group="📊 Plots 📊", title="Profit ㅤ ㅤ🟢 if > to:", defval=0.1, inline="Profit")minProfit = input.float (group="📊 Plots 📊", title="ㅤ🔴 if < to: ", defval=0, inline="Profit")maxWinRate = input.float (group="📊 Plots 📊", title="Win Rateㅤ🟢 if > to: ", defval=70, inline="Winrate", minval = 0, maxval=100)minWinRate = input.float (group="📊 Plots 📊", title="ㅤ🔴 if < to: ", defval=50, inline="Winrate", minval = 0, maxval=100)maxPFactor = input.float (group="📊 Plots 📊", title="P. Factorㅤ🟢 if > to: ", defval=2, inline="PFactor", minval=0)minPFactor = input.float (group="📊 Plots 📊", title="ㅤ🔴 if < to: ", defval=1, inline="PFactor", minval=0)bgcolor(dateRange ? na : color.new(color.white, 80))MTLabel(ftimestamp, etimestamp, statusProfit, statusWinRate, statusPFactor, maxWinRow, maxLossRow) => timefr = timeframe.isminutes ? 'min' : '' string _text = ' 🔰CITI Moku (Free)🔰' + '\n' _text += '➖➖➖➖➖➖➖➖➖➖' + '\n' _text += '' + '\n' _text += ' Ticker:' + '\n' _text += ' ' + syminfo.ticker + ' ' + timeframe.period + timefr _text += '' + '\n\n' _text += ' Since:' + '\n' _text += str.format(" {0,date,long} ", ftimestamp) + str.format("{0,time,HH:mm}", ftimestamp) + '\n' _text += ' To:' + '\n' _text += str.format(" {0,date,long} ", etimestamp) + str.format("{0,time,HH:mm}", etimestamp) + '\n' _text += '' + '\n' _text += '➖➖➖➖➖➖➖➖➖➖' + '\n' _text += '' + '\n' _text += ' #Trades: ' + str.tostring(strategy.closedtrades, '##.##') + '\n' _text += '' + '\n' _text += ' Profit:' + '\n' _text += ' ' + str.tostring(statusProfit) + str.tostring(( strategy.netprofit / strategy.initial_capital ) * 100, '##.##') + '% \n' _text += ' Win Rate:' + '\n' _text += ' ' + str.tostring(statusWinRate) + str.tostring(( strategy.wintrades / strategy.closedtrades ) * 100, '##.##') + '% \n' _text += ' Profit Factor:' + '\n' _text += ' ' + str.tostring(statusPFactor) + str.tostring(( strategy.grossprofit / strategy.grossloss ), '##.###') + '\n' _text += '' + '\n' _text += ' Win Trades: ' + str.tostring(strategy.wintrades, '######') + '\n' _text += ' Loss Trades: ' + str.tostring(strategy.losstrades, '######') + '\n' _text += '' + '\n' _text += ' Avg Win: ' + str.tostring((( strategy.grossprofit / strategy.wintrades ) * 100 ) / strategy.initial_capital, '##.##') + '%\n' _text += ' Avg Loss: ' + str.tostring((( strategy.grossloss / strategy.losstrades ) * 100 ) / strategy.initial_capital, '##.##') + '%\n' _text += '' + '\n' _text += ' Max Win in a Row: ' + str.tostring(maxWinRow, '######') + '\n' _text += ' Max Loss in a Row: ' + str.tostring(maxLossRow, '######') + '\n' _text += '' + '\n' _text += '➖➖➖➖➖➖➖➖➖➖' + '\n'ftimestamp = startFilter ? timestamp(year(startTime, zoneTime), month(startTime, zoneTime), dayofmonth(startTime, zoneTime), hour(startTime, zoneTime), minute(startTime, zoneTime), second(startTime, zoneTime)) : timestamp(year(ta.valuewhen(barstate.isfirst, time, 0), zoneTime), month(ta.valuewhen(barstate.isfirst, time, 0), zoneTime), dayofmonth(ta.valuewhen(barstate.isfirst, time, 0), zoneTime), hour(ta.valuewhen(barstate.isfirst, time, 0), zoneTime), minute(ta.valuewhen(barstate.isfirst, time, 0), zoneTime))etimestamp = endFilter ? timestamp(year(endTime, zoneTime), month(endTime, zoneTime), dayofmonth(endTime, zoneTime), hour(endTime, zoneTime), minute(endTime, zoneTime), second(endTime, zoneTime)) : timestamp(year(timenow, zoneTime), month(timenow, zoneTime), dayofmonth(timenow, zoneTime), hour(timenow, zoneTime), minute(timenow, zoneTime))statusProfit = (( strategy.netprofit / strategy.initial_capital ) * 100) + 0.001 >= maxProfit ? "🟢 " : (( strategy.netprofit / strategy.initial_capital ) * 100) - 0.001 <= minProfit ? "🔴 " : "🟡 "statusWinRate = (( strategy.wintrades / strategy.closedtrades ) * 100) + 0.001 >= maxWinRate ? "🟢 " : (( strategy.wintrades / strategy.closedtrades ) * 100) - 0.001 <= minWinRate ? "🔴 " : "🟡 "statusPFactor = ( strategy.grossprofit / strategy.grossloss ) + 0.001 >= maxPFactor ? "🟢 " : ( strategy.grossprofit / strategy.grossloss ) - 0.001 <= minPFactor ? "🔴 " : "🟡 "varip int winRow = 0varip int lossRow = 0varip int maxWinRow = 0varip int maxLossRow = 0if (strategy.wintrades > strategy.wintrades[1]) and (strategy.losstrades == strategy.losstrades[1]) and (strategy.eventrades == strategy.eventrades[1]) lossRow := 0 winRow := winRow + 1 if winRow > maxWinRow maxWinRow := winRowif (strategy.wintrades == strategy.wintrades[1]) and (strategy.losstrades > strategy.losstrades[1]) and (strategy.eventrades == strategy.eventrades[1]) winRow := 0 lossRow := lossRow + 1 if lossRow > maxLossRow maxLossRow := lossRowlabel la = nalabel.delete(la[1])la := plotDashboard ? label.new(x=bar_index + 5, y=close, text=MTLabel(ftimestamp, etimestamp, statusProfit, statusWinRate, statusPFactor, maxWinRow, maxLossRow), color=color.new(color.black, 50), style=label.style_label_left, textcolor=color.white, size=size.normal, textalign=text.align_left) : na