Pine Script v4 · Strategy
Korea premium(KIMP)
A Pine Script v4 strategy built on ALMA (kimp_, basisLen), Highest (kimp_alma_h, 254) and Lowest (kimp_alma_l, 254). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.25% commission. 24 settings; defaults include What trades should be taken : LONG, MA Period 10 and Offset for ALMA 0.5.
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 Korea premium(KIMP) repaint?
- No
- No repainting patterns were found in the source.
- Can Korea premium(KIMP) be converted to Pine Script v5?
- Not tested
- The steps are shown below, but the original does not run in Zeal Terminal's engine, so they could not be checked.
- Does Korea premium(KIMP) use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Korea premium(KIMP) run in Zeal Terminal?
- No
- Not yet: Pine Script v4 Error at @L78:C38: Undeclared identifier 'tonumber'.
Review
What a careful reader of this script would point out, found by checking the source.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses an argument v6 removed
when = on line 133, 134, 135, 136. The upgraded version below moves each call inside an if block.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames security → request.security, alma → ta.alma, highest → ta.highest, lowest → ta.lowest, ema → ta.ema, bb → ta.bb.
- 4 strategy calls use the when = argument (line 133, 134, 135, 136). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
Not verifiedThe v4 script does not run in Zeal Terminal's engine (Pine Script v4 Error at @L78:C38: Undeclared identifier 'tonumber'.), so this step could not be checked.
- Line 3: //@version=4 → //@version=5
- Line 14: input(type = input.time) → input.time()
- Line 15: input(type = input.time) → input.time()
- Line 43: input(type = input.bool) → input.bool()
- Line 45: security → request.security
- Line 46: security → request.security
23 more edits
- Line 47: security → request.security
- Line 48: security → request.security
- Line 49: security → request.security
- Line 50: security → request.security
- Line 51: security → request.security
- Line 52: security → request.security
- Line 53: security → request.security
- Line 57: security → request.security
- Line 58: security → request.security
- Line 59: security → request.security
- Line 60: security → request.security
- Line 79: alma → ta.alma
- Line 80: alma → ta.alma
- Line 81: alma → ta.alma
- Line 84: highest → ta.highest
- Line 85: lowest → ta.lowest
- Line 86: ema → ta.ema
- Line 87: ema → ta.ema
- Line 88: ema → ta.ema
- Line 89: highest → ta.highest
- Line 90: lowest → ta.lowest
- Line 103: bb → ta.bb
- Line 104: ema → ta.ema
⋯// © roses27-//@version=4+//@version=5// Ver. 1.4⋯high_low_Len= input(defval = 254, title = "High Low Period", minval = 1)-i_startTime = input(defval = timestamp(" 1 Mar 2021 00:00 +0000"), title ="Start Time", type = input.time)+i_startTime = input.time(defval = timestamp(" 1 Mar 2021 00:00 +0000"), title ="Start Time")-i_endTime = input(defval = timestamp(" 1 Dec 2022 00:00 +0000"), title ="End Time", type = input.time)+i_endTime = input.time(defval = timestamp(" 1 Dec 2022 00:00 +0000"), title ="End Time")use_index_btc= input(defval = false, title = "Use INDEX:BTCUSD KIMP?", group = "Select data to use for calculation")⋯var string id0_1 = Dealer_1 + ':' + id + st1-showPlot = input(defval = true, title = "Show Plot", type = input.bool)+showPlot = input.bool(defval = true, title = "Show Plot")inDateRange = time >= i_startTime and time <= i_endTime-coin_0 = security(id0_0, "", close)+coin_0 = request.security(id0_0, "", close)-coin_0_high = security(id0_0, "", high)+coin_0_high = request.security(id0_0, "", high)-coin_0_low = security(id0_0, "", low)+coin_0_low = request.security(id0_0, "", low)-coin_1 = security(id0_1, "", close)+coin_1 = request.security(id0_1, "", close)-coin_1_high = security(id0_1, "", high)+coin_1_high = request.security(id0_1, "", high)-coin_1_low = security(id0_1, "", low)+coin_1_low = request.security(id0_1, "", low)-btc_krw = security('BITHUMB:BTCKRW',"", close)+btc_krw = request.security('BITHUMB:BTCKRW',"", close)-btc_krw_high = security('BITHUMB:BTCKRW',"", high)+btc_krw_high = request.security('BITHUMB:BTCKRW',"", high)-btc_krw_low = security('BITHUMB:BTCKRW',"", low)+btc_krw_low = request.security('BITHUMB:BTCKRW',"", low)// btc_usd = security('BINANCE:BTCUSDT',"", close)⋯// btc_usd_low = security('BINANCE:BTCUSDT',"", low)-btc_usd = security('INDEX:BTCUSD',"", close)+btc_usd = request.security('INDEX:BTCUSD',"", close)-btc_usd_high = security('INDEX:BTCUSD',"", high)+btc_usd_high = request.security('INDEX:BTCUSD',"", high)-btc_usd_low = security('INDEX:BTCUSD',"", low)+btc_usd_low = request.security('INDEX:BTCUSD',"", low)-usd_krw = security('USDKRW',"",close)+usd_krw = request.security('USDKRW',"",close)kimp_ = 0.0⋯var int basisLen = int(3 * basisLen0/tonumber(timeframe.period)) > 3 ? int(3 * basisLen0/tonumber(timeframe.period)) : 3-kimp_alma = alma(kimp_, basisLen, alma_offset, alma_sigma)+kimp_alma = ta.alma(kimp_, basisLen, alma_offset, alma_sigma)-kimp_alma_h = alma(kimp_high, basisLen, alma_offset, alma_sigma)+kimp_alma_h = ta.alma(kimp_high, basisLen, alma_offset, alma_sigma)-kimp_alma_l = alma(kimp_low, basisLen, alma_offset, alma_sigma)+kimp_alma_l = ta.alma(kimp_low, basisLen, alma_offset, alma_sigma)// kimp_alma_high = highest(kimp_alma, high_low_Len)// kimp_alma_low = lowest( kimp_alma, high_low_Len)-kimp_alma_high = highest(kimp_alma_h, high_low_Len)+kimp_alma_high = ta.highest(kimp_alma_h, high_low_Len)-kimp_alma_low = lowest( kimp_alma_l, high_low_Len)+kimp_alma_low = ta.lowest( kimp_alma_l, high_low_Len)-kimp_ema = ema(kimp_, basisLen0)+kimp_ema = ta.ema(kimp_, basisLen0)-kimp_ema_h = ema(kimp_high, basisLen0)+kimp_ema_h = ta.ema(kimp_high, basisLen0)-kimp_ema_l = ema(kimp_low, basisLen0)+kimp_ema_l = ta.ema(kimp_low, basisLen0)-kimp_ema_high = highest(kimp_ema_h, high_low_Len)+kimp_ema_high = ta.highest(kimp_ema_h, high_low_Len)-kimp_ema_low = lowest( kimp_ema_l, high_low_Len)+kimp_ema_low = ta.lowest( kimp_ema_l, high_low_Len)kimp_plot_ = 0.0 ⋯ kimp_plot_ := btc_krw / usd_krw-[middle, upper, lower] = bb(kimp_, length0, stddev0)+[middle, upper, lower] = ta.bb(kimp_, length0, stddev0)-close_ema = ema(kimp_, length_ema)+close_ema = ta.ema(kimp_, length_ema)value = 0.0⋯Clean v5
Not verifiedThe v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L78:C38: 'tonumber' was renamed to 'str.tonumber' in Pine Script v5.), so this step could not be checked.
- Line 8: input() → input.string()
- Line 9: input() → input.bool()
- Line 10: input() → input.int()
- Line 11: input() → input.float()
- Line 12: input() → input.float()
- Line 13: input() → input.int()
19 more edits
- Line 16: input() → input.bool()
- Line 17: input() → input.bool()
- Line 18: input() → input.float()
- Line 19: input() → input.float()
- Line 20: input() → input.float()
- Line 21: input() → input.float()
- Line 22: input() → input.bool()
- Line 23: input() → input.int()
- Line 24: input() → input.float()
- Line 25: input() → input.int()
- Line 26: input() → input.string()
- Line 27: input() → input.string()
- Line 28: input() → input.string()
- Line 29: input() → input.string()
- Line 30: input() → input.string()
- Line 133: when = chgPAL ==true and tradeType!="SHORT" and inDateRange → if block
- Line 134: when = chgPAS ==true and tradeType!="LONG" and inDateRange → if block
- Line 135: when = chgPAS ==true and tradeType=="LONG" and inDateRange → if block
- Line 136: when = chgPAL ==true and tradeType=="SHORT" and inDateRange → if block
⋯ default_qty_value=100, pyramiding = 0, commission_type=strategy.commission.percent, commission_value=0.25)-tradeType = input("LONG", title="What trades should be taken : ", options=["LONG", "SHORT", "BOTH"])+tradeType = input.string("LONG", title="What trades should be taken : ", options=["LONG", "SHORT", "BOTH"])-use_ema = input(defval = false, title = "use EMA?")+use_ema = input.bool(defval = false, title = "use EMA?")-basisLen0 = input(defval = 10, title = "MA Period", minval = 1)+basisLen0 = input.int(defval = 10, title = "MA Period", minval = 1)-alma_offset = input(defval = 0.5, title = "Offset for ALMA", minval = 0.0, step = 0.02)+alma_offset = input.float(defval = 0.5, title = "Offset for ALMA", minval = 0.0, step = 0.02)-alma_sigma = input(defval = 20.0, title = "Sigma for ALMA", minval = 0.0, step = 1.0)+alma_sigma = input.float(defval = 20.0, title = "Sigma for ALMA", minval = 0.0, step = 1.0)-high_low_Len= input(defval = 254, title = "High Low Period", minval = 1)+high_low_Len= input.int(defval = 254, title = "High Low Period", minval = 1)i_startTime = input.time(defval = timestamp(" 1 Mar 2021 00:00 +0000"), title ="Start Time")i_endTime = input.time(defval = timestamp(" 1 Dec 2022 00:00 +0000"), title ="End Time")-use_index_btc= input(defval = false, title = "Use INDEX:BTCUSD KIMP?", group = "Select data to use for calculation")+use_index_btc= input.bool(defval = false, title = "Use INDEX:BTCUSD KIMP?", group = "Select data to use for calculation")-use_absolute= input(defval = false, title = "Use Absolute Percentage?", group = "Absolute Percentage")+use_absolute= input.bool(defval = false, title = "Use Absolute Percentage?", group = "Absolute Percentage")-bias_low_A = input(defval = 13.2, title = "Absolute bias_low %", group = "Absolute Percentage", step=0.1)+bias_low_A = input.float(defval = 13.2, title = "Absolute bias_low %", group = "Absolute Percentage", step=0.1)-bias_high_A = input(defval = 16.7, title = "Absolute bias_high %", group = "Absolute Percentage", minval=0, step=0.1)+bias_high_A = input.float(defval = 16.7, title = "Absolute bias_high %", group = "Absolute Percentage", minval=0, step=0.1)-bias_low = input(defval = 30.0 , title = "Relative bias_low %", group = "Relative Percentage", minval=0, step=1.0)/100.0+bias_low = input.float(defval = 30.0 , title = "Relative bias_low %", group = "Relative Percentage", minval=0, step=1.0)/100.0-bias_high = input(defval = 95.0 , title = "Relative bias_high %", group = "Relative Percentage", step=1.0)/100.0+bias_high = input.float(defval = 95.0 , title = "Relative bias_high %", group = "Relative Percentage", step=1.0)/100.0-bb = input(defval = false, title = "use BB?")+bb = input.bool(defval = false, title = "use BB?")-length0 = input(defval = 70, title = "BB Length")+length0 = input.int(defval = 70, title = "BB Length")-stddev0 = input(defval = 0.3, title = "BB Stddev", step = 0.01)+stddev0 = input.float(defval = 0.3, title = "BB Stddev", step = 0.01)-length_ema = input(defval = 34, title = "ema Length")+length_ema = input.int(defval = 34, title = "ema Length")-st0 = input(defval = 'KRW', title = "Current Currency", group = "Select Currency to use for calculation")+st0 = input.string(defval = 'KRW', title = "Current Currency", group = "Select Currency to use for calculation")-st1 = input(defval = 'USDT', title = "Currency to compare", group = "Select Currency to use for calculation")+st1 = input.string(defval = 'USDT', title = "Currency to compare", group = "Select Currency to use for calculation")-st2 = input(defval = 'USD', title = "Currency to compare", group = "Select Currency to use for calculation")+st2 = input.string(defval = 'USD', title = "Currency to compare", group = "Select Currency to use for calculation")-Dealer_0 = input(defval = 'BITHUMB', title = "Current Dealer", group = "Select Currency to use for calculation")+Dealer_0 = input.string(defval = 'BITHUMB', title = "Current Dealer", group = "Select Currency to use for calculation")-Dealer_1 = input(defval = 'BINANCE', title = "Dealer to compare", group = "Select Currency to use for calculation")+Dealer_1 = input.string(defval = 'BINANCE', title = "Dealer to compare", group = "Select Currency to use for calculation")// id01 = input(defval = syminfo.ticker, title='Symbol 01',type=input.symbol)⋯if (inDateRange and tradeType!="NONE")- strategy.entry("long", strategy.long, when=chgPAL ==true and tradeType!="SHORT" and inDateRange, comment = "EL")+ if chgPAL ==true and tradeType!="SHORT" and inDateRange+ strategy.entry("long", strategy.long, comment = "EL")- strategy.entry("short", strategy.short, when=chgPAS ==true and tradeType!="LONG" and inDateRange, comment = "ES")+ if chgPAS ==true and tradeType!="LONG" and inDateRange+ strategy.entry("short", strategy.short, comment = "ES")- strategy.close("long", when=chgPAS ==true and tradeType=="LONG" and inDateRange, comment = "EL close")+ if chgPAS ==true and tradeType=="LONG" and inDateRange+ strategy.close("long", comment = "EL close")- strategy.close("short", when=chgPAL ==true and tradeType=="SHORT" and inDateRange, comment = "ES close")+ if chgPAL ==true and tradeType=="SHORT" and inDateRange+ strategy.close("short", comment = "ES close")// === /STRATEGY ===⋯Does it run in Pine Script v6?
Not tested
The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L78:C38: 'tonumber' was renamed to 'str.tonumber' in Pine Script v5.), so this step could not be checked. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © roses27-//@version=5+//@version=6// Ver. 1.4⋯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 |
|---|---|---|---|
| What trades should be taken : | LONG | string · options ["LONG", "SHORT", "BOTH"] | entry long entry short close long close short line 132 |
| use EMA? | false | bool | line 116 |
| MA Period | 10 | int · min 1 | basisLen kimp_ema kimp_ema_h kimp_ema_l |
| Offset for ALMA | 0.5 | float · min 0.0 · step 0.02 | kimp_alma kimp_alma_h kimp_alma_l |
| Sigma for ALMA | 20.0 | float · min 0.0 · step 1.0 | kimp_alma kimp_alma_h kimp_alma_l |
| High Low Period | 254 | int · min 1 | kimp_alma_high kimp_alma_low kimp_ema_high kimp_ema_low |
| Start Time | timestamp(" 1 Mar 2021 00:00 +0000") | time | inDateRange |
| End Time | timestamp(" 1 Dec 2022 00:00 +0000") | time | inDateRange |
| use BB? | false | bool | line 112 |
| BB Length | 70 | int | middle upper lower |
| BB Stddev | 0.3 | float · step 0.01 | middle upper lower |
| ema Length | 34 | int | close_ema |
| Show Plot | true | bool | band0 plot |
| Select data to use for calculation | |||
| Use INDEX:BTCUSD KIMP? | false | bool | line 64 line 98 line 101 |
| Absolute Percentage | |||
| Use Absolute Percentage? | false | bool | line 108 |
| Absolute bias_low % | 13.2 | float · step 0.1 | bottom_value |
| Absolute bias_high % | 16.7 | float · min 0 · step 0.1 | top_value |
| Relative Percentage | |||
| Relative bias_low % | 30.0 | float · min 0 · step 1.0 | bottom_value |
| Relative bias_high % | 95.0 | float · step 1.0 | top_value |
| Select Currency to use for calculation | |||
| Current Currency | KRW | string | id id0_0 line 69 line 94 line 98 |
| Currency to compare | USDT | string | id00 id0_1 line 92 line 101 |
| Currency to compare | USD | string | id0 line 92 line 101 |
| Current Dealer | BITHUMB | string | id0_0 |
| Dealer to compare | BINANCE | string | id0_1 |
What it calculates
- ALMA (
alma,ta.almain v5)kimp_, basisLen, Offset for ALMA (0.5), Sigma for ALMA (20.0)kimp_alma · line 79 - ALMA (
alma,ta.almain v5)kimp_high, basisLen, Offset for ALMA (0.5), Sigma for ALMA (20.0)kimp_alma_h · line 80 - ALMA (
alma,ta.almain v5)kimp_low, basisLen, Offset for ALMA (0.5), Sigma for ALMA (20.0)kimp_alma_l · line 81 - Highest (
highest,ta.highestin v5)kimp_alma_h, High Low Period (254)kimp_alma_high · line 84 - Lowest (
lowest,ta.lowestin v5)kimp_alma_l, High Low Period (254)kimp_alma_low · line 85 - EMA (
ema,ta.emain v5)kimp_, MA Period (10)kimp_ema · line 86 - EMA (
ema,ta.emain v5)kimp_high, MA Period (10)kimp_ema_h · line 87 - EMA (
ema,ta.emain v5)kimp_low, MA Period (10)kimp_ema_l · line 88 - Highest (
highest,ta.highestin v5)kimp_ema_h, High Low Period (254)kimp_ema_high · line 89 - Lowest (
lowest,ta.lowestin v5)kimp_ema_l, High Low Period (254)kimp_ema_low · line 90 - BB (
bb,ta.bbin v5)kimp_, BB Length (70), BB Stddev (0.3)middle · line 103 - BB (
bb,ta.bbin v5)kimp_, BB Length (70), BB Stddev (0.3)upper · line 103 - BB (
bb,ta.bbin v5)kimp_, BB Length (70), BB Stddev (0.3)lower · line 103 - EMA (
ema,ta.emain v5)kimp_, ema Length (34)close_ema · line 104
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 70 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 long long | chgPAL ==true and tradeType!="SHORT" and inDateRange | On | 133 |
| Open short short | chgPAS ==true and tradeType!="LONG" and inDateRange | On | 134 |
| Close long | chgPAS ==true and tradeType=="LONG" and inDateRange | On | 135 |
| Close short | chgPAL ==true and tradeType=="SHORT" and inDateRange | On | 136 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
No
No repainting patterns in the source.
The live replay needs a run, and this script does not run in Zeal Terminal yet; the answer comes from the checks on the source alone.
- ClearHigher-timeframe data13 security call(s), none with lookahead on.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingprocess_orders_on_close = true: orders fill at the signal bar's close.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Similar scripts
Indicators and strategies built from the same calculations.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Bollinger Bands Modified (Stormer) by AugustoErni | bb ema highest lowest | v5 strategy | −7.8% | 29 | 8.0% |
| CC Trend strategy 2- Downtrend Short by CheatCode1 | ema highest lowest | v5 strategy | No trades on this market | ||
| TrianglePoint strategy by mohanee | highest lowest ema | v4 strategy | +45.4% | 11 | 101.9% |
| Lagged Donchian Channel + EMA by Mysteriown | ema highest lowest | v4 strategy | −12.3% | 4 | 12.3% |
| Backtest Custom HiLo Strategy by luyikaibr | ema highest lowest | v4 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | No Pine Script v4 Error at @L78:C38: Undeclared identifier 'tonumber'. | Not measured | |
| PineTS | No v5 and v6 only | — | Not measured |
“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. PineTS runs Pine Script v5 and v6 only.
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/// © roses27//@version=4// Ver. 1.4strategy(title = "Korea premium(KIMP)", overlay=true, calc_on_every_tick=false, process_orders_on_close=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding = 0, commission_type=strategy.commission.percent, commission_value=0.25)tradeType = input("LONG", title="What trades should be taken : ", options=["LONG", "SHORT", "BOTH"])use_ema = input(defval = false, title = "use EMA?")basisLen0 = input(defval = 10, title = "MA Period", minval = 1)alma_offset = input(defval = 0.5, title = "Offset for ALMA", minval = 0.0, step = 0.02)alma_sigma = input(defval = 20.0, title = "Sigma for ALMA", minval = 0.0, step = 1.0)high_low_Len= input(defval = 254, title = "High Low Period", minval = 1)i_startTime = input(defval = timestamp(" 1 Mar 2021 00:00 +0000"), title ="Start Time", type = input.time)i_endTime = input(defval = timestamp(" 1 Dec 2022 00:00 +0000"), title ="End Time", type = input.time)use_index_btc= input(defval = false, title = "Use INDEX:BTCUSD KIMP?", group = "Select data to use for calculation")use_absolute= input(defval = false, title = "Use Absolute Percentage?", group = "Absolute Percentage")bias_low_A = input(defval = 13.2, title = "Absolute bias_low %", group = "Absolute Percentage", step=0.1)bias_high_A = input(defval = 16.7, title = "Absolute bias_high %", group = "Absolute Percentage", minval=0, step=0.1)bias_low = input(defval = 30.0 , title = "Relative bias_low %", group = "Relative Percentage", minval=0, step=1.0)/100.0bias_high = input(defval = 95.0 , title = "Relative bias_high %", group = "Relative Percentage", step=1.0)/100.0bb = input(defval = false, title = "use BB?")length0 = input(defval = 70, title = "BB Length")stddev0 = input(defval = 0.3, title = "BB Stddev", step = 0.01)length_ema = input(defval = 34, title = "ema Length")st0 = input(defval = 'KRW', title = "Current Currency", group = "Select Currency to use for calculation")st1 = input(defval = 'USDT', title = "Currency to compare", group = "Select Currency to use for calculation")st2 = input(defval = 'USD', title = "Currency to compare", group = "Select Currency to use for calculation")Dealer_0 = input(defval = 'BITHUMB', title = "Current Dealer", group = "Select Currency to use for calculation")Dealer_1 = input(defval = 'BINANCE', title = "Dealer to compare", group = "Select Currency to use for calculation")// id01 = input(defval = syminfo.ticker, title='Symbol 01',type=input.symbol)// id01 = input(defval = 'XRP', title='Symbol 01',type=input.symbol)f_grad_transp(_c_col, _transp) => _c_red = color.r(_c_col) _c_green = color.g(_c_col) _c_blue = color.b(_c_col) color.rgb(_c_red, _c_green, _c_blue, _transp)var string id00 = str.replace_all(syminfo.ticker,st1,'')var string id0 = str.replace_all(id00,st2,'')var string id = str.replace_all(id0, st0,'')var string id0_0 = Dealer_0 + ':' + id + st0var string id0_1 = Dealer_1 + ':' + id + st1showPlot = input(defval = true, title = "Show Plot", type = input.bool)inDateRange = time >= i_startTime and time <= i_endTimecoin_0 = security(id0_0, "", close)coin_0_high = security(id0_0, "", high)coin_0_low = security(id0_0, "", low)coin_1 = security(id0_1, "", close)coin_1_high = security(id0_1, "", high)coin_1_low = security(id0_1, "", low)btc_krw = security('BITHUMB:BTCKRW',"", close)btc_krw_high = security('BITHUMB:BTCKRW',"", high)btc_krw_low = security('BITHUMB:BTCKRW',"", low)// btc_usd = security('BINANCE:BTCUSDT',"", close)// btc_usd_high = security('BINANCE:BTCUSDT',"", high)// btc_usd_low = security('BINANCE:BTCUSDT',"", low)btc_usd = security('INDEX:BTCUSD',"", close)btc_usd_high = security('INDEX:BTCUSD',"", high)btc_usd_low = security('INDEX:BTCUSD',"", low)usd_krw = security('USDKRW',"",close)kimp_ = 0.0kimp_high = 0.0kimp_low = 0.0if use_index_btc kimp_ := 100.0 * (btc_krw - btc_usd * usd_krw) / (btc_usd * usd_krw) kimp_high := 100.0 * (btc_krw_high - btc_usd_high * usd_krw) / (btc_usd_high * usd_krw) kimp_low := 100.0 * (btc_krw_low - btc_usd_low * usd_krw) / (btc_usd_low * usd_krw)else if syminfo.ticker == id + st0 //krw // kimp_ := 100.0 * (coin_1 - close * usd_krw) / (close * usd_krw) kimp_ := 100.0 * (close - coin_1 * usd_krw) / close kimp_high := 100.0 * (high - coin_1 * usd_krw) / high kimp_low := 100.0 * (low - coin_1 * usd_krw) / low else //usd kimp_ := 100.0 * (coin_0 / usd_krw - close) / close kimp_high := 100.0 * (coin_0_high / usd_krw - high) / high kimp_low := 100.0 * (coin_0_low / usd_krw - low) / lowvar int basisLen = int(3 * basisLen0/tonumber(timeframe.period)) > 3 ? int(3 * basisLen0/tonumber(timeframe.period)) : 3kimp_alma = alma(kimp_, basisLen, alma_offset, alma_sigma)kimp_alma_h = alma(kimp_high, basisLen, alma_offset, alma_sigma)kimp_alma_l = alma(kimp_low, basisLen, alma_offset, alma_sigma)// kimp_alma_high = highest(kimp_alma, high_low_Len)// kimp_alma_low = lowest( kimp_alma, high_low_Len)kimp_alma_high = highest(kimp_alma_h, high_low_Len)kimp_alma_low = lowest( kimp_alma_l, high_low_Len)kimp_ema = ema(kimp_, basisLen0)kimp_ema_h = ema(kimp_high, basisLen0)kimp_ema_l = ema(kimp_low, basisLen0)kimp_ema_high = highest(kimp_ema_h, high_low_Len)kimp_ema_low = lowest( kimp_ema_l, high_low_Len)kimp_plot_ = 0.0 if syminfo.ticker == id + st1 or syminfo.ticker == id + st2 kimp_plot_ := coin_0 / usd_krwif syminfo.ticker == id + st0 kimp_plot_ := coin_1 * usd_krw// if use_index_btc and id == 'BTC'// kimp_plot_ := btc_usd * usd_krwif use_index_btc and id == 'BTC' and syminfo.ticker == id + st0 kimp_plot_ := btc_usd * usd_krw if use_index_btc and id == 'BTC' and (syminfo.ticker == id + st1 or syminfo.ticker == id + st2) kimp_plot_ := btc_krw / usd_krw[middle, upper, lower] = bb(kimp_, length0, stddev0)close_ema = ema(kimp_, length_ema)value = 0.0bottom_value= 0.0top_value = 0.0if use_absolute value := kimp_ bottom_value:= bias_low_A top_value := bias_high_Aelse if bb value := close_ema bottom_value:= lower top_value := upperelse if use_ema value := kimp_ bottom_value:= (kimp_ema_high - kimp_ema_low) * bias_low + kimp_ema_low top_value := (kimp_ema_high - kimp_ema_low) * bias_high + kimp_ema_lowelse value := kimp_ bottom_value:= (kimp_alma_high - kimp_alma_low) * bias_low + kimp_alma_low top_value := (kimp_alma_high - kimp_alma_low) * bias_high + kimp_alma_lowPAL = (value < bottom_value)PAS = (value > top_value )c_grad = color.from_gradient(value, bottom_value, top_value, color.lime, color.red) chgPAL = PAL and not PAL[1]chgPAS = PAS and not PAS[1]band0 = plot(series = showPlot and inDateRange ? kimp_plot_ : na, color = syminfo.ticker == id0 ? color.blue : color.red, linewidth = 2)band1 = plot(inDateRange ? close: na)fill(band0, band1, color=f_grad_transp(c_grad, 80), title="Background")if (inDateRange and tradeType!="NONE") strategy.entry("long", strategy.long, when=chgPAL ==true and tradeType!="SHORT" and inDateRange, comment = "EL") strategy.entry("short", strategy.short, when=chgPAS ==true and tradeType!="LONG" and inDateRange, comment = "ES") strategy.close("long", when=chgPAS ==true and tradeType=="LONG" and inDateRange, comment = "EL close") strategy.close("short", when=chgPAL ==true and tradeType=="SHORT" and inDateRange, comment = "ES close")// === /STRATEGY ===// eof