Zeal Terminal Open Zeal Terminal

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
Does not run in Zeal Terminal yetIt imports the library MightyZinger/Chikou/3, whose source is not available here, so it does not run here. The settings, logic and review below are read from the source, which does not need a run.

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.

SettingDefaultType and rangeFeeds
Source Parameters
→ Different Sources OptionsSRC_Existring · options [SRC_Tv, SRC_Wc, SRC_Wo, SRC_Wu, SRC_Wi, SRC_Exi, SRC_Exj]src_o
Tradingview Source Setupclosesourcesrc_o
Apply Symmetrically Weighted Moving Average at the price source (May Result Repainting)trueboolsrc_f
MA Parameters
MA Length:20intedma
EMA 1 Length:20intema1
EMA 2 Length:40intema2
‍ Apply Symmetrically Weighted Moving Average at EDMAtruebooledma
‍ Show EMA 1trueboolEMA 1
‍ Show EMA 2falseboolEMA 2
Chikou Filter Parameters
Chikou Period (Displaced Source)25intedma_col _trend
Bull Color color.greencoloredma_col _trend
Bear Color color.redcoloredma_col _trend
Consollidation/Reversal Color color.yellowcoloredma_col _trend
EMA Color Settings
EMA 1 Color #2962FFcolorEMA 1
EMA 2 Color #FF6D00colorEMA 2
ETrade Parameters
Show Cross Alertstrueboolunused
Use Chikou Filter for Confirmationfalseboolweak_up strong_up weak_dn strong_dn

What it calculates

  • SWMAsrc_osrc_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.

edma_LengthMA Length:setting · 20ema1_LengthEMA 1 Length:setting · 20ema2_LengthEMA 2 Length:setting · 40ohlc4ohlc4price dataclosecloseprice dataopenopenprice datalowlowprice datahighhighprice datadiff_src→ Different Sources Opt…setting · SRC_Exic_lenChikou Period (Displace…setting · 25src_fSWMA→ src_f_hmaWMA→ _hmaedmaSWMA→ edmaema1EMA→ ema1ema2EMA→ ema2haopenhaopenvaluesrc_osrc_ovaluehexphexpvaluelexplexpvalue_edma_edmavalueh_lenh_lenvalueweak_upweak_upvaluestrong_upstrong_upvalueweak_dnweak_dnvaluestrong_dnstrong_dnvaluesignal_asignal_avaluebuy_strongbuy_strongconditionsell_strongsell_strongconditionL1, S1L1 · S12 conditionsL2, S2L2 · S22 conditionsL3, S3L3 · S32 conditionsbuy_weak, sell_weakbuy_weak · sell_weak2 conditionsedma_col, _trendColouredma_col · _trendclose:sellClose sellstrategy.closeentry:buyOpen buystrategy.entryclose:buyClose buystrategy.closeentry:sellOpen sellstrategy.entryplot:85EDMAplotplot:86EMA 1plotplot:87EMA 2plotfill:BackgroundBackgroundfill

Order rules

OrderFires whenBy defaultLine
Close sellbuy_strongarray.get(swing_a, 1) == 1 and array.get(swing_a, 1)[1] != 1On123
Open buy longbuy_strongarray.get(swing_a, 1) == 1 and array.get(swing_a, 1)[1] != 1On124
Close buysell_strongarray.get(swing_a, 1) == -1 and array.get(swing_a, 1)[1] != -1On125
Open sell shortsell_strongarray.get(swing_a, 1) == -1 and array.get(swing_a, 1)[1] != -1On126

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.

ScriptSharesTypeNetTradesMax drawdown
SL1 Pips after TP2 (MA) by gpadiharema wmav4 strategy+0.4%330.1%
Escaping of Rate from Avarage By Mustafa OZVER Strategy by Mustafaozverwma emav4 strategy+122.0%9679.1%
Forex SWING Trader by SoftKill21wma emav4 strategyNo trades on this market
No-lose trading targets (Based on EoRfA) By Mustafa ÖZVER by Mustafaozverwma emav4 strategyNo trades on this market
tvbot Trend Following with Mean Reversion algo by tvbot-ema wmav5 strategyNo 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 verified

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.

  • 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

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2No It imports the library MightyZinger/Chikou/3, whose source is not available here, so it does not run hereNot measured
PineTSNot testedNot testedNot 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)