Pine Script v5 · Strategy
EDMA Scalping Strategy (Exponentially Deviating Moving Average)
A Pine Script v5 strategy built on SWMA (src_o), WMA (lexp, h_len) and EMA (src_f, 20). 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 5% of equity and pays 0.1% commission. 17 settings; defaults include → Different Sources Options SRC_Exi, Tradingview Source Setup close and MA Length: 20.
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 EDMA Scalping Strategy (Exponentially Deviating Moving Average) repaint?
- No
- No repainting patterns were found in the source.
- Does EDMA Scalping Strategy (Exponentially Deviating Moving Average) run in Pine Script v6?
- Not tested
- The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L5:C0: no source was supplied for the library 'MightyZinger/Chikou/3'. Libraries cannot be fetched from TradingView; supply the source in the 'libraries' option. No libraries were supplied.), so this step could not be checked. The v6 version is shown for reference and is not offered as a download.
- Does EDMA Scalping Strategy (Exponentially Deviating Moving Average) use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does EDMA Scalping Strategy (Exponentially Deviating Moving Average) run in Zeal Terminal?
- No
- Not yet: it imports the library MightyZinger/Chikou/3, whose source is not available here, so it does not run here
Review
What a careful reader of this script would point out, found by checking the source.
-
Check
1 setting does nothing
“Show Cross Alerts” is declared but never read.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
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 123, 124, 125, 126. The upgraded version below moves each call inside an if block.
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 |
|---|---|---|---|
| Source Parameters | |||
| → Different Sources Options | SRC_Exi | string · options [SRC_Tv, SRC_Wc, SRC_Wo, SRC_Wu, SRC_Wi, SRC_Exi, SRC_Exj] | src_o |
| Tradingview Source Setup | close | source | src_o |
| Apply Symmetrically Weighted Moving Average at the price source (May Result Repainting) | true | bool | src_f |
| MA Parameters | |||
| MA Length: | 20 | int | edma |
| EMA 1 Length: | 20 | int | ema1 |
| EMA 2 Length: | 40 | int | ema2 |
| Apply Symmetrically Weighted Moving Average at EDMA | true | bool | edma |
| Show EMA 1 | true | bool | EMA 1 |
| Show EMA 2 | false | bool | EMA 2 |
| Chikou Filter Parameters | |||
| Chikou Period (Displaced Source) | 25 | int | edma_col _trend |
| Bull Color | color.green | color | edma_col _trend |
| Bear Color | color.red | color | edma_col _trend |
| Consollidation/Reversal Color | color.yellow | color | edma_col _trend |
| EMA Color Settings | |||
| EMA 1 Color | #2962FF | color | EMA 1 |
| EMA 2 Color | #FF6D00 | color | EMA 2 |
| ETrade Parameters | |||
| Show Cross Alerts | true | bool | unused |
| Use Chikou Filter for Confirmation | false | bool | weak_up strong_up weak_dn strong_dn |
What it calculates
- SWMAsrc_o
src_f · line 39 - WMA2 * ta.wma(lexp, h_len / 2) - ta.wma(lexp, h_len), math.round(math.sqrt(h_len))
_hma · line 66 - SWMAf_edma(src_f, edma_Length)
edma · line 80 - EMAsrc_f, EMA 1 Length: (20)
ema1 · line 81 - EMAsrc_f, EMA 2 Length: (40)
ema2 · line 82
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Close sell | buy_strongarray.get(swing_a, 1) == 1 and array.get(swing_a, 1)[1] != 1 | On | 123 |
| Open buy long | buy_strongarray.get(swing_a, 1) == 1 and array.get(swing_a, 1)[1] != 1 | On | 124 |
| Close buy | sell_strongarray.get(swing_a, 1) == -1 and array.get(swing_a, 1)[1] != -1 | On | 125 |
| Open sell short | sell_strongarray.get(swing_a, 1) == -1 and array.get(swing_a, 1)[1] != -1 | On | 126 |
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 dataThe script requests no other symbol or timeframe.
- 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 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.
Similar scripts
Indicators and strategies built from the same calculations.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| SL1 Pips after TP2 (MA) by gpadihar | ema wma | v4 strategy | +0.4% | 33 | 0.1% |
| Escaping of Rate from Avarage By Mustafa OZVER Strategy by Mustafaozver | wma ema | v4 strategy | +122.0% | 96 | 79.1% |
| Forex SWING Trader by SoftKill21 | wma ema | v4 strategy | No trades on this market | ||
| No-lose trading targets (Based on EoRfA) By Mustafa ÖZVER by Mustafaozver | wma ema | v4 strategy | No trades on this market | ||
| tvbot Trend Following with Mean Reversion algo by tvbot- | ema wma | v5 strategy | No trades on this market | ||
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.
- 4 strategy calls use the when = argument (line 123, 124, 125, 126). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- 3 settings use the untyped input() (line 44, 46, 48). 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.
Clean v5
Not verifiedThe v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L5:C0: no source was supplied for the library 'MightyZinger/Chikou/3'. Libraries cannot be fetched from TradingView; supply the source in the 'libraries' option. No libraries were supplied.), so this step could not be checked.
- Line 44: input() → input.bool()
- Line 46: input() → input.bool()
- Line 48: input() → input.bool()
- Line 123: when = buy_strong → if block
- Line 124: when = buy_strong → if block
- Line 125: when = sell_strong → if block
- Line 126: when = sell_strong → if block
⋯edma_Length = input.int(20, title='MA Length:', group=grp1)-i_Symmetrical = input(true, ' Apply Symmetrically Weighted Moving Average at EDMA')+i_Symmetrical = input.bool(true, ' Apply Symmetrically Weighted Moving Average at EDMA')ema1_Length = input.int(20, title='EMA 1 Length:', group=grp1)-show_ema1 = input(true, ' Show EMA 1')+show_ema1 = input.bool(true, ' Show EMA 1')ema2_Length = input.int(40, title='EMA 2 Length:', group=grp1)-show_ema2 = input(false, ' Show EMA 2')+show_ema2 = input.bool(false, ' Show EMA 2')string grp2 = 'Chikou Filter Parameters'⋯//plotshape(showSignals and sell_strong ? (high + atrOver) : na, style=shape.triangledown, color=color.new(color.red, 30), location=location.absolute, text='Sell', size=size.small)-strategy.close('sell', when = buy_strong)+if buy_strong+ strategy.close('sell')-strategy.entry("buy", strategy.long, when = buy_strong)+if buy_strong+ strategy.entry("buy", strategy.long)-strategy.close('buy', when = sell_strong)+if sell_strong+ strategy.close('buy')-strategy.entry("sell", strategy.short, when = sell_strong)+if sell_strong+ strategy.entry("sell", strategy.short)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 @L5:C0: no source was supplied for the library 'MightyZinger/Chikou/3'. Libraries cannot be fetched from TradingView; supply the source in the 'libraries' option. No libraries were supplied.), 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.
⋯// © MightyZinger-//@version=5+//@version=6strategy('EDMA Scalping Strategy (Exponentially Deviating Moving Average)', shorttitle='MZ EDMA Strategy', overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=5, calc_on_every_tick=false, commission_type=strategy.commission.percent, commission_value=0.1)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | No It imports the library MightyZinger/Chikou/3, whose source is not available here, so it does not run here | Not measured | |
| PineTS | Not tested | Not tested | 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.
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/// © MightyZinger//@version=5strategy('EDMA Scalping Strategy (Exponentially Deviating Moving Average)', shorttitle='MZ EDMA Strategy', overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=5, calc_on_every_tick=false, commission_type=strategy.commission.percent, commission_value=0.1)import MightyZinger/Chikou/3 as filter/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Source Options ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ─── Different Sources Options List ───► [string SRC_Tv = 'Use traditional TradingView Sources 'string SRC_Wc = '(open+close+3(high+low))/8'string SRC_Wo = 'close+high+low-2*open'string SRC_Wu = '(close+5(high+low)-7(open))/4'string SRC_Wi = '(open+close+5(high+low))/12'string SRC_Exi = 'close>open ? high : low'string SRC_Exj = 'Heiken-ashi(close>open) ? high : low'string src_grp = 'Source Parameters'// ●───────── Inputs ─────────● {diff_src = input.string(SRC_Exi, '→ Different Sources Options', options=[SRC_Tv, SRC_Wc, SRC_Wo, SRC_Wu, SRC_Wi, SRC_Exi, SRC_Exj], group=src_grp)i_sourceSetup = input.source(close, 'Tradingview Source Setup', group=src_grp)i_Sym = input.bool(true, 'Apply Symmetrically Weighted Moving Average at the price source (May Result Repainting)', group=src_grp)// Heikinashi Candles for calculationsf_ha_open() => haopen = float(na) haopen := na(haopen[1]) ? (open + close) / 2 : (nz(haopen[1]) + nz(ohlc4[1])) / 2 haopenh_open = f_ha_open()// Get Source src_o = diff_src == SRC_Wc ? (open+close+3*(high+low))/8 : diff_src == SRC_Wo ? close+high+low-2*open : diff_src == SRC_Wu ? (close+5*(high+low)-7*(open))/4 : diff_src == SRC_Wi ? (open+close+5*(high+low))/12 : diff_src == SRC_Exi ? (close > open ? high : low) : diff_src == SRC_Exj ? (ohlc4 > h_open ? high : low) : i_sourceSetup src_f = i_Sym ? ta.swma(src_o) : src_o // Symmetrically Weighted Moving Average?//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////string grp1 = 'MA Parameters'edma_Length = input.int(20, title='MA Length:', group=grp1)i_Symmetrical = input(true, ' Apply Symmetrically Weighted Moving Average at EDMA')ema1_Length = input.int(20, title='EMA 1 Length:', group=grp1)show_ema1 = input(true, ' Show EMA 1')ema2_Length = input.int(40, title='EMA 2 Length:', group=grp1)show_ema2 = input(false, ' Show EMA 2')string grp2 = 'Chikou Filter Parameters'c_len = input.int(25, title='Chikou Period (Displaced Source)', group=grp2)c_bull_col = input.color(color.green, 'Bull Color ', group = grp2, inline='c_col')c_bear_col = input.color(color.red, 'Bear Color ', group = grp2, inline='c_col')c_rvsl_col = input.color(color.yellow, 'Consollidation/Reversal Color ', group = grp2, inline='c_col')string grp3 = 'EMA Color Settings'ema1_col = input.color(#2962FF, 'EMA 1 Color ', group = grp3, inline='e_col')ema2_col = input.color(#FF6D00, 'EMA 2 Color ', group = grp3, inline='e_col')string grp4 = 'ETrade Parameters'showSignals = input.bool(true, title='Show Cross Alerts', group=grp4)conf_chk = input.bool(false, title='Use Chikou Filter for Confirmation', group=grp4)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// EDMA Functionf_edma(src, len)=> var hexp = float(na) // Initiallizing Variables var lexp = float(na) var _hma = float(na) var _edma = float(na) float smoothness = 1.0 // Increasing smoothness will result in MA same as EMA h_len = int(len/1.5) // Length to be used in final calculation of Hull Moving Average // Defining Exponentially Expanding Moving Line hexp := na(hexp[1]) ? src : src >= hexp[1] ? src : hexp[1] + (src - hexp[1]) * (smoothness / (len + 1)) // Defining Exponentially Contracting Moving Line lexp := na(lexp[1]) ? hexp : src <= lexp[1] ? hexp : lexp[1] + (src - lexp[1]) * (smoothness / (len + 1)) // Calculating Hull Moving Average of resulted Exponential Moving Line with 3/2 of total length _hma := ta.wma(2 * ta.wma(lexp, h_len / 2) - ta.wma(lexp, h_len), math.round(math.sqrt(h_len))) _edma := _hma // EDMA will be equal to resulted smoothened Hull Moving Average _edma//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////edma = i_Symmetrical ? ta.swma(f_edma(src_f, edma_Length)) : f_edma(src_f, edma_Length)ema1 = ta.ema(src_f, ema1_Length)ema2 = ta.ema(src_f, ema2_Length)// Calling Chikou filter function from library to obtaing dynamic color of EDMA Band and also Chikou Trend [edma_col, _trend] = filter.chikou(src_f, c_len, high, low, c_bull_col, c_bear_col, c_rvsl_col) edma_plot = plot(edma, title='EDMA', color= edma_col , linewidth=4) // Plotting EDMA with dynamic color from Chikou Filter Functionema1_plot = plot(show_ema1 ? ema1 : na, title='EMA 1', color= ema1_col , linewidth=3)ema2_plot = plot(show_ema2 ? ema2 : na, title='EMA 2', color= ema2_col , linewidth=3)fill(ema1_plot , edma_plot, title = "Background", color = color.new(edma_col,70)) // Filling the bands inbetween EMA and EDMA//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Trade Signals and AlertsL1 = ema2 > edma // Weak Uptrend ConditionL2 = ema1 > edma // Strong Uptrend ConditionL3 = _trend == 1 // Chikou Filter Uptrend ConditionS1 = ema2 < edma // Weak Downtrend ConditionS2 = ema1 < edma // Strong Downtrend ConditionS3 = _trend == -1 // Chikou Filter Downtrend Condition// Setting confirmation conditional operator for Chikou Filterweak_up = conf_chk ? L1 and L3 : L1strong_up = conf_chk ? L2 and L3 : L2weak_dn = conf_chk ? S1 and S3 : S1strong_dn = conf_chk ? S2 and S3 : S2// Defining condition equivalent to Crossover & Crossunderbool[] signal_a = array.from(weak_up, strong_up, weak_dn, strong_dn)var swing_a = array.new_int(2)f_signal()=> for i = 0 to 1 var sig = 0 if array.get(signal_a, i) and sig <= 0 sig := 1 if array.get(signal_a, i+2) and sig >= 0 sig := -1 array.set(swing_a, i, sig) f_signal()buy_weak = array.get(swing_a, 0) == 1 and array.get(swing_a, 0)[1] != 1 buy_strong = array.get(swing_a, 1) == 1 and array.get(swing_a, 1)[1] != 1 sell_weak = array.get(swing_a, 0) == -1 and array.get(swing_a, 0)[1] != -1 sell_strong = array.get(swing_a, 1) == -1 and array.get(swing_a, 1)[1] != -1 // Plotting Signals on Chart//atrOver = 0.7 * ta.atr(5) // Atr to place alert shape on chart//plotshape(showSignals and buy_strong ? (low - atrOver) : na, style=shape.triangleup, color=color.new(color.green, 30), location=location.absolute, text='Buy', size=size.small)//plotshape(showSignals and sell_strong ? (high + atrOver) : na, style=shape.triangledown, color=color.new(color.red, 30), location=location.absolute, text='Sell', size=size.small)strategy.close('sell', when = buy_strong)strategy.entry("buy", strategy.long, when = buy_strong)strategy.close('buy', when = sell_strong)strategy.entry("sell", strategy.short, when = sell_strong)