Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

MAPM-V1

A Pine Script v5 strategy built on EMA (close, 8). It has 8 order rules, 4 entries among them, and trades long and short with the default settings. Exits use a profit target and no stop loss. Each trade commits 10% of equity and pays 0.1 commission. 17 settings; defaults include Signal Fast 300, Signal Slow 600 and Step Add Purchases 2.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 MAPM-V1 repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did MAPM-V1 do on BTCUSDT 1D with default settings?
+0.08%
From 26 Jan 2024 to 21 Oct 2026, over 1 closed trade, against +102.5% for buy and hold. A backtest, not investment advice.
Does MAPM-V1 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: 1 before, 1 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 MAPM-V1 use a stop loss?
No
Its exits set a profit target but no stop.
Does MAPM-V1 run in Zeal Terminal?
Yes
It compiles in 31 ms and runs 1,000 bars in 63 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (17)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$100$203Equity from $100
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
+0.08%
$0.08
Buy and hold
+102.5%
same period
Closed trades
1
1 won · 0 lost
Profitable
100.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.23%
−$0.23

One run with the author's default settings, $100 starting capital, commission as the script sets it. 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.

  • Likely bug

    ta.ema(close, 8) ignores the settings line 20

    Line 20 hard-codes 8 where line 23 uses “Signal Fast”. Changing those settings moves one band but not this one.

    ta.ema(close, 8)ta.ema(close, SignalFast)
  • Likely bug

    ta.ema(close, 49) ignores the settings line 21

    Line 21 hard-codes 49 where line 23 uses “Signal Fast”. Changing those settings moves one band but not this one.

    ta.ema(close, 49)ta.ema(close, SignalFast)
  • Check

    No stop loss

    strategy.exit is used without a stop, loss or trailing stop.

  • Note

    9 settings have no label

    In the settings dialog SignalFast (line 6), SignalSlow (line 7), StepAddPurchases (line 8), VolumePurchases (line 9), Buy (line 10), Sell (line 11), Martingale (line 14), VolumeDepo (line 15), PercentOfDepo (line 16) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Signal Fast (no label in the script)300int · step 10macdSignalF
Signal Slow (no label in the script)600int · step 10macdSignalS
Step Add Purchases (no label in the script)2.5float · step 0.1SteplimitLong SteplimitShort PickInLong PickInShort
Volume Purchases (no label in the script)6int · step 1PurchasesLong PurchasesShort
Buy (no label in the script)trueboolEntryLong PurchasesLong
Sell (no label in the script)trueboolEntryShort PurchasesShort
Long Take Profit (%)1float · min 0.0 · step 0.1limitLong
Short Take Profit (%)1float · min 0.0 · step 0.1limitShort
Martingale (no label in the script)1.6float · min 1 · step 0.1entry PurchasesLong entry PurchasesShort
Volume Depo (no label in the script)100int · step 1EnterVolume
Percent Of Depo (no label in the script)10float · step 1EnterVolume
Test Start Year2005intstartTest
Test Start Month1intstartTest
Test Start Day1intstartTest
Test End Year2050intendTest
Test End Month12intendTest
Test End Day30intendTest

What it calculates

  • EMAclose, 8fastAverage · line 20
  • EMAclose, 49slowAverage · line 21
  • EMAmacd, Signal Fast (300)macdSignalF · line 23
  • EMAmacd, Signal Slow (600)macdSignalS · line 24

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.

closecloseprice dataSignalFastSignal Fastsetting · 300SignalSlowSignal Slowsetting · 600VolumeDepoVolume Deposetting · 100PercentOfDepoPercent Of Deposetting · 10startYearTest Start Yearsetting · 2005startMonthTest Start Monthsetting · 1startDayTest Start Daysetting · 1endYearTest End Yearsetting · 2050endMonthTest End Monthsetting · 12endDayTest End Daysetting · 30timetimeprice datalongProfitPercLong Take Profit (%)setting · 1shortProfitPercShort Take Profit (%)setting · 1StepAddPurchasesStep Add Purchasessetting · 2.5VolumePurchasesVolume Purchasessetting · 6fastAverageEMA→ fastAverageslowAverageEMA→ slowAveragemacdSignalFEMA→ macdSignalFmacdSignalSEMA→ macdSignalSCloseClosevalueEnterVolumeEnterVolumevaluemacdmacdvaluestartTeststartTestvalueendTestendTestvaluetimeRangetimeRangevaluex, yx · y2 valuesentryPriceentryPricevaluelimitLonglimitLongvaluelimitShortlimitShortvalueSteplimitLong, SteplimitShortSteplimitLong · Steplim…2 valuesPickInLong, PickInShortPickInLong · PickInShort2 valuesEntryLong, EntryShortEntryLong · EntryShort2 conditionsPurchasesLong, PurchasesShortPurchasesLong · Purchas…2 conditionsCancelPurchasesLong, TPLong, CancelPurchasesShort, TPShort, InTradeLong, InTradeShortCancelPurchasesLong · T…6 conditionsentry:Entry LongOpen Entry Longstrategy.entryentry:PurchasesLongOpen PurchasesLongstrategy.entrycancel:PurchasesLongcancel PurchasesLongstrategy.cancelexit:TPLongexit TPLongstrategy.exitentry:Entry ShortOpen Entry Shortstrategy.entryentry:PurchasesShortOpen PurchasesShortstrategy.entrycancel:PurchasesShortcancel PurchasesShortstrategy.cancelexit:TPShortexit TPShortstrategy.exitplot:86plotplotplot:87plotplotplot:89plotplotplot:90plotplot

Order rules

OrderFires whenBy defaultLine
Open Entry Long longevery barOn62
Open PurchasesLong longevery barOn63
cancel PurchasesLongevery barOn64
Exit TPLong limitevery barOn66
Open Entry Short shortevery barOn74
Open PurchasesShort shortevery barOn75
cancel PurchasesShortevery barOn76
Exit TPShort limitevery barOn78

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, and the live replay matched history.

1/1trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+0.1%+102.5%1100%—0.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.4%+9.8%367%2.261.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.2%+8.4%1100%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+3.1%+16.7%4100%—0.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.1%+21.5%1100%—0.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.3%+148.3%2100%—0.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%1100%—0.2%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 barsTradesWonP&L
Rising market1100%$0.08
Sideways market0—$0.00
Falling market0—$0.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

0.0%

The 95th percentile of the worst drawdown when the same 1 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.0% to 0.0%; the tick is what actually happened, 0.0%. Order luck alone moves it this much.

0%1%
All 1 trades
SideEntryExitBarsP&L
long27 Sep 2026 84,433.1030 Sep 2026 85,277.403$0.08

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
MAPM-V1 this page—v5 strategy+0.1%10.2%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

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 10, 11, 26, 27, 28, 31, 32, 33). 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

VerifiedDownload the v5 script

Same 1 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 10: input() → input.bool()
  • Line 11: input() → input.bool()
  • Line 26: input() → input.int()
  • Line 27: input() → input.int()
  • Line 28: input() → input.int()
  • Line 31: input() → input.int()
  • Line 32: input() → input.int()
  • Line 33: input() → input.int()
⋯VolumePurchases = input.int(6,step=1)-Buy = input(true)+Buy = input.bool(true)-Sell = input(true)+Sell = input.bool(true)longProfitPerc = input.float(title="Long Take Profit (%)", minval=0.0, step=0.1, defval=1) * 0.01⋯// Test Start-startYear = input(2005, "Test Start Year")+startYear = input.int(2005, "Test Start Year")-startMonth = input(1, "Test Start Month")+startMonth = input.int(1, "Test Start Month")-startDay = input(1, "Test Start Day")+startDay = input.int(1, "Test Start Day")startTest = timestamp(startYear,startMonth,startDay,0,0)//Test End-endYear = input(2050, "Test End Year")+endYear = input.int(2050, "Test End Year")-endMonth = input(12, "Test End Month")+endMonth = input.int(12, "Test End Month")-endDay = input(30, "Test End Day")+endDay = input.int(30, "Test End Day")endTest = timestamp(endYear,endMonth,endDay,23,59)⋯

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: 1 before, 1 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.

⋯// © TradingSoft_tech-//@version=5+//@version=6strategy("MAPM-V1", overlay=true, default_qty_value=10, max_bars_back=5000,default_qty_type = strategy.percent_of_equity, commission_value=0.1, initial_capital = 100, pyramiding=6, currency=currency.USD)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 31 msYes 1,000 bars in 63 msNot 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/// © TradingSoft_tech//@version=5strategy("MAPM-V1", overlay=true, default_qty_value=10, max_bars_back=5000,default_qty_type = strategy.percent_of_equity, commission_value=0.1, initial_capital = 100, pyramiding=6, currency=currency.USD)///////// OptionsSignalFast = input.int(300, step=10)SignalSlow = input.int(600, step=10)StepAddPurchases = input.float(2.5, step=0.1)VolumePurchases = input.int(6,step=1)Buy = input(true)Sell = input(true)longProfitPerc = input.float(title="Long Take Profit (%)", minval=0.0, step=0.1, defval=1) * 0.01shortProfitPerc = input.float(title="Short Take Profit (%)", minval=0.0, step=0.1, defval=1) * 0.01Martingale = input.float(1.6, minval = 1, step = 0.1)VolumeDepo = input.int(100, step=1)PercentOfDepo = input.float(10, step=1)Close = (close)EnterVolume = VolumeDepo*PercentOfDepo*0.01/Close///////// Calculation indicatorfastAverage = ta.ema(close, 8)slowAverage = ta.ema(close, 49)macd = fastAverage - slowAveragemacdSignalF = ta.ema(macd,SignalFast)macdSignalS = ta.ema(macd,SignalSlow)// Test StartstartYear = input(2005, "Test Start Year")startMonth = input(1, "Test Start Month")startDay = input(1, "Test Start Day")startTest = timestamp(startYear,startMonth,startDay,0,0)//Test EndendYear = input(2050, "Test End Year")endMonth = input(12, "Test End Month")endDay = input(30, "Test End Day")endTest = timestamp(endYear,endMonth,endDay,23,59)timeRange = time > startTest and time < endTest ? true : false///////// Plot Data//plot(macd, style = plot.style_histogram)//plot(macdSignalF*10000, style = plot.style_line, color=color.red)//plot(macdSignalS*10000, style = plot.style_line, color=color.blue)//plot(fastAverage, style = plot.style_line, color=color.red)//plot(slowAverage, style = plot.style_line, color=color.blue)///////// Calculation of the updated valuevar x = 0.0if strategy.opentrades>strategy.opentrades[1]    x := x + 1else if strategy.opentrades==0    x := 0y = x+1///////// Calculation of reference price dataentryPrice = strategy.opentrades==0? 0 : strategy.opentrades.entry_price(0)limitLong = strategy.position_avg_price * (1 + longProfitPerc)limitShort = strategy.position_avg_price * (1 - shortProfitPerc)SteplimitLong = entryPrice[0]*(1-StepAddPurchases*y/100)SteplimitShort = entryPrice[0]*(1+StepAddPurchases*y/100)///////// Conditions for a longbool EntryLong = ta.crossover(macdSignalF, macdSignalS) and Buy and strategy.opentrades==0 and strategy.position_size==0bool PurchasesLong = Buy and strategy.opentrades==x and strategy.position_size>0 and x<=VolumePurchasesbool CancelPurchasesLong = strategy.position_size==0 and strategy.opentrades==0bool TPLong = strategy.position_size>0 and strategy.opentrades!=0///////// Entry Long + add.purchases + cancel purchases + Take profit Longswitch     EntryLong => strategy.entry("Entry Long", strategy.long, qty = EnterVolume)    PurchasesLong => strategy.entry("PurchasesLong", strategy.long, qty = EnterVolume*math.pow(Martingale,y), limit = SteplimitLong)    CancelPurchasesLong => strategy.cancel("PurchasesLong")switch    TPLong => strategy.exit("TPLong", qty_percent = 100, limit = limitLong)///////// Conditions for a Shortbool EntryShort = ta.crossunder(macdSignalF, macdSignalS) and Sell and strategy.opentrades==0 and strategy.position_size==0bool PurchasesShort = Sell and strategy.opentrades==x and strategy.position_size<0 and x<=VolumePurchasesbool CancelPurchasesShort = strategy.position_size==0 and strategy.opentrades==0bool TPShort = strategy.position_size<0 and strategy.opentrades!=0///////// Entry Short + add.purchases + cancel purchases + Take profit Shortswitch    EntryShort => strategy.entry("Entry Short", strategy.short, qty = EnterVolume)    PurchasesShort => strategy.entry("PurchasesShort", strategy.short, qty = EnterVolume*math.pow(Martingale,y), limit = SteplimitShort)    CancelPurchasesShort => strategy.cancel("PurchasesShort")switch    TPShort => strategy.exit("TPShort", qty_percent = 100, limit = limitShort)    /////////Calculation of conditions and reference data for level drawingInTradeLong = strategy.position_size<0InTradeShort = strategy.position_size>0PickInLong = strategy.opentrades.entry_price(0)*(1-StepAddPurchases*y/100)PickInShort = strategy.opentrades.entry_price(0)*(1+StepAddPurchases*y/100)/////////Displaying the level of Take Profitplot(InTradeLong ? na : limitLong, color=color.new(#00d146, 0), style=plot.style_linebr, linewidth=1)plot(InTradeShort ? na : limitShort, color=color.new(#00d146, 0), style=plot.style_linebr, linewidth=1)/////////Displaying the level of add.purchasesplot(InTradeLong ? na : PickInLong, color=color.white, style=plot.style_linebr, linewidth=1)plot(InTradeShort ? na : PickInShort, color=color.white, style=plot.style_linebr, linewidth=1)