Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Phoenix085-Strategies==-MTF - Average True Range + MovAvg

A Pine Script v4 strategy built on TR (true). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 13 settings; defaults include Take Profit % 50, Stop Loss % 5 and Shorter MA Length 8.

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 Phoenix085-Strategies==-MTF - Average True Range + MovAvg repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Phoenix085-Strategies==-MTF - Average True Range + MovAvg do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Can Phoenix085-Strategies==-MTF - Average True Range + MovAvg be converted to Pine Script v5?
Not tested
The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
Does Phoenix085-Strategies==-MTF - Average True Range + MovAvg use a stop loss?
Yes
strategy.exit sets a stop on line 93, 99.
Does Phoenix085-Strategies==-MTF - Average True Range + MovAvg run in Zeal Terminal?
Yes
It compiles in 24 ms and runs 1,000 bars in 51 ms, in the browser.

BTCUSDT · 1D · default settings

  • TR
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$100,000$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 91, 98) so the engine trades the way the script says. The live re-run is not offered here: the script requests BINANCE:BTCUSDT 1, which this page cannot load in your browser.

Needs BINANCE:BTCUSDT 1 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Values that depend on it are empty on this chart.

Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $100,000 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.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • 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 91, 98. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 70

    transp = on line 70. v5 folds the transparency into the colour with color.new(c, transp).

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, rma → ta.rma, sma → ta.sma, ema → ta.ema, wma → ta.wma, tr → ta.tr, crossover → ta.crossover, crossunder → ta.crossunder.
  • 2 strategy calls use the when = argument (line 91, 98). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 3: //@version=4 → //@version=5
  • Line 7: input(type = input.float) → input.float()
  • Line 8: input(type = input.float) → input.float()
  • Line 13: input(type = input.session) → input.session()
  • Line 47: security → request.security
  • Line 48: security → request.security
21 more edits
  • Line 56: rma → ta.rma
  • Line 59: sma → ta.sma
  • Line 62: ema → ta.ema
  • Line 64: wma → ta.wma
  • Line 65: tr → ta.tr
  • Line 68: crossover → ta.crossover
  • Line 68: sma → ta.sma
  • Line 68: sma → ta.sma
  • Line 68: sma → ta.sma
  • Line 68: sma → ta.sma
  • Line 68: sma → ta.sma
  • Line 69: crossunder → ta.crossunder
  • Line 69: sma → ta.sma
  • Line 69: sma → ta.sma
  • Line 69: sma → ta.sma
  • Line 69: sma → ta.sma
  • Line 70: sma → ta.sma
  • Line 70: transp = 90 → color.new(color.lime, 90)
  • Line 72: sma → ta.sma
  • Line 91: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 98: strategy.entry(…, false) → strategy.entry(…, strategy.short)
⋯// © Phoenix085-//@version=4+//@version=5strategy("Phoenix085-Strategy_ATR+MovAvg", shorttitle="Strategy_ATR+MovAvg", overlay=true)⋯// // ######################>>>>>>>>>>>>Strategy Inputs<<<<<<<<<<<#########################-TakeProfitPercent = input(50, title="Take Profit %", type=input.float, step=.25)+TakeProfitPercent = input.float(50, title="Take Profit %", step=.25)-StopLossPercent = input(5, title="Stop Loss %", type=input.float, step=.25)+StopLossPercent = input.float(5, title="Stop Loss %", step=.25)ProfitTarget = (close * (TakeProfitPercent / 100)) / syminfo.mintick⋯len_L = input(title="Longer MA Length", defval=38, minval=1)-TF = input(defval="", title="Session TF for calc only", type=input.session,options=[""])+TF = input.session(defval="", title="Session TF for calc only",options=[""])TF_ = "1"⋯                                            TF_ == "2H"-Src = security(syminfo.tickerid, TF, close[1], barmerge.lookahead_on)+Src = request.security(syminfo.tickerid, TF, close[1], barmerge.lookahead_on)-Src_ = security(syminfo.tickerid, TF_, close, barmerge.lookahead_off)+Src_ = request.security(syminfo.tickerid, TF_, close, barmerge.lookahead_off)// ######################>>>>>>>>>>>>ATR Inputs<<<<<<<<<<<#########################⋯    if smoothing == "RMA"-        rma(Src, length)+        ta.rma(Src, length)    else        if smoothing == "SMA"-            sma(Src, length)+            ta.sma(Src, length)        else            if smoothing == "EMA"-                ema(Src, length)+                ta.ema(Src, length)            else-                wma(Src, length)+                ta.wma(Src, length)-ATR=ma_function(tr(true), length)+ATR=ma_function(ta.tr(true), length)// //######################>>>>>>>>>>>>Conditions<<<<<<<<<<<#########################ATR_Rise = ATR>ATR[1] and ATR[1]<ATR[2] and ATR[2]<ATR[3]-longCondition = crossover(sma(Src_, len_S), sma(Src_, len_L)) and sma(Src_, len_L) < sma(Src_, len_S) and (sma(Src_, len_S) < Src_[1])+longCondition = ta.crossover(ta.sma(Src_, len_S), ta.sma(Src_, len_L)) and ta.sma(Src_, len_L) < ta.sma(Src_, len_S) and (ta.sma(Src_, len_S) < Src_[1])-shortCondition = crossunder(sma(Src_, len_S), sma(Src_, len_L)) and sma(Src_, len_L) > sma(Src_, len_S) +shortCondition = ta.crossunder(ta.sma(Src_, len_S), ta.sma(Src_, len_L)) and ta.sma(Src_, len_L) > ta.sma(Src_, len_S) -plot(sma(Src_, len_S), color=color.lime, transp=90)+plot(ta.sma(Src_, len_S), color=color.new(color.lime, 90))col = longCondition ? color.lime : shortCondition ? color.red : color.gray-plot(sma(Src_, len_L),color=col,linewidth=2)+plot(ta.sma(Src_, len_L),color=col,linewidth=2)bool IsABuy = longCondition ⋯if inDateRange and ATR_Rise and IsABuy -    strategy.entry("longCondition",true,when = longCondition)+    strategy.entry("longCondition",strategy.long,when = longCondition)    strategy.close("shortCondition")⋯if inDateRange and ATR_Rise and IsASell  -    strategy.entry("shortCondition",false,when = shortCondition)+    strategy.entry("shortCondition",strategy.short,when = shortCondition)    strategy.exit("Take Profit or Stop Loss", "shortCondition",trail_points = close * 0.05 / syminfo.mintick ,trail_offset = close * 0.05 / syminfo.mintick, loss = LossTarget)⋯

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
  • Line 50: input() → input.int()
  • Line 51: input() → input.string()
  • Line 76: input() → input.int()
  • Line 77: input() → input.int()
6 more edits
  • Line 78: input() → input.int()
  • Line 80: input() → input.int()
  • Line 81: input() → input.int()
  • Line 82: input() → input.int()
  • Line 91: when = longCondition → if block
  • Line 98: when = shortCondition → if block
⋯LossTarget = (close * (StopLossPercent / 100)) / syminfo.mintick-len_S = input(title="Shorter MA Length", defval=8, minval=1)+len_S = input.int(title="Shorter MA Length", defval=8, minval=1)-len_L = input(title="Longer MA Length", defval=38, minval=1)+len_L = input.int(title="Longer MA Length", defval=38, minval=1)TF = input.session(defval="", title="Session TF for calc only",options=[""])⋯// ######################>>>>>>>>>>>>ATR Inputs<<<<<<<<<<<#########################-length = input(title="ATR Length", defval=4, minval=1)+length = input.int(title="ATR Length", defval=4, minval=1)-smoothing = input(title="ATR Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])+smoothing = input.string(title="ATR Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])// //######################>>>>>>>>>>>>Custom Functions Declarations<<<<<<<<<<<#########################⋯// // ######################>>>>>>>>>>>>Strategy<<<<<<<<<<<#########################-testStartYear = input(2015, "Backtest Start Year", minval=1980)+testStartYear = input.int(2015, "Backtest Start Year", minval=1980)-testStartMonth = input(1, "Backtest Start Month", minval=1, maxval=12)+testStartMonth = input.int(1, "Backtest Start Month", minval=1, maxval=12)-testStartDay = input(1, "Backtest Start Day", minval=1, maxval=31)+testStartDay = input.int(1, "Backtest Start Day", minval=1, maxval=31)testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)-testStopYear = input(9999, "Backtest Stop Year", minval=1980)+testStopYear = input.int(9999, "Backtest Stop Year", minval=1980)-testStopMonth = input(12, "Backtest Stop Month", minval=1, maxval=12)+testStopMonth = input.int(12, "Backtest Stop Month", minval=1, maxval=12)-testStopDay = input(31, "Backtest Stop Day", minval=1, maxval=31)+testStopDay = input.int(31, "Backtest Stop Day", minval=1, maxval=31)testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)⋯if inDateRange and ATR_Rise and IsABuy -    strategy.entry("longCondition",strategy.long,when = longCondition)+    if longCondition+        strategy.entry("longCondition",strategy.long)    strategy.close("shortCondition")⋯if inDateRange and ATR_Rise and IsASell  -    strategy.entry("shortCondition",strategy.short,when = shortCondition)+    if shortCondition+        strategy.entry("shortCondition",strategy.short)    strategy.exit("Take Profit or Stop Loss", "shortCondition",trail_points = close * 0.05 / syminfo.mintick ,trail_offset = close * 0.05 / syminfo.mintick, loss = LossTarget)⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Phoenix085-//@version=5+//@version=6strategy("Phoenix085-Strategy_ATR+MovAvg", shorttitle="Strategy_ATR+MovAvg", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Take Profit %50float · step .25ProfitTarget
Stop Loss %5float · step .25LossTarget
Shorter MA Length8int · min 1longCondition shortCondition plot
Longer MA Length38int · min 1longCondition shortCondition plot
Session TF for calc onlysession · options [""]Src line 15 line 18 line 21 line 24 line 27 line 30 line 33 line 36 line 39 line 42 line 45
ATR Length4int · min 1ATR line 56 line 59 line 62 line 64
ATR SmoothingRMAstring · options ["RMA", "SMA", "EMA", "WMA"]line 55 line 58 line 61
Backtest Start Year2015int · min 1980testPeriodStart
Backtest Start Month1int · min 1 · max 12testPeriodStart
Backtest Start Day1int · min 1 · max 31testPeriodStart
Backtest Stop Year9999int · min 1980testPeriodStop
Backtest Stop Month12int · min 1 · max 12testPeriodStop
Backtest Stop Day31int · min 1 · max 31testPeriodStop

What it calculates

  • TR (tr, ta.tr in v5)trueATR · line 65

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.

high · low · closehigh · low · closeprice datalengthATR Lengthsetting · 4closecloseprice dataTakeProfitPercentTake Profit %setting · 50StopLossPercentStop Loss %setting · 5TFSession TF for calc onlysetting · testStartYearBacktest Start Yearsetting · 2015testStartMonthBacktest Start Monthsetting · 1testStartDayBacktest Start Daysetting · 1testStopYearBacktest Stop Yearsetting · 9999testStopMonthBacktest Stop Monthsetting · 12testStopDayBacktest Stop Daysetting · 31len_SShorter MA Lengthsetting · 8len_LLonger MA Lengthsetting · 38timetimeprice dataATRTR→ ATRProfitTargetProfitTargetvalueLossTargetLossTargetvalueSrcSrcvalueSrc_Src_valueIsABuyIsABuyvalueIsASellIsASellvaluetestPeriodStarttestPeriodStartvaluetestPeriodStoptestPeriodStopvalueATR_RiseATR_RiseconditionlongConditionlongConditionconditionshortConditionshortConditionconditioninDateRangeinDateRangeconditioncolColourcolentry:longConditionOpen longConditionstrategy.entryclose:shortConditionClose shortConditionstrategy.closeexit:Take Profit or Stop Lossexit Take Profit or Sto…strategy.exitentry:shortConditionOpen shortConditionstrategy.entryclose:longConditionClose longConditionstrategy.closeplot:70plotplotplot:72plotplotbgcolor:87bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Open longCondition longlongConditioncrossover(sma(Src_, len_S), sma(Src_, len_L)) and sma(Src_, len_L) < sma(Src_, len_S) and (sma(Src_, len_S) < Src_[1])On91
Close shortConditioninDateRange and ATR_Rise and IsABuyOn92
Exit Take Profit or Stop Loss stopinDateRange and ATR_Rise and IsABuyOn93
Open shortCondition shortshortConditioncrossunder(sma(Src_, len_S), sma(Src_, len_L)) and sma(Src_, len_L) > sma(Src_, len_S)On98
Exit Take Profit or Stop Loss stopinDateRange and ATR_Rise and IsASellOn99
Close longConditioninDateRange and ATR_Rise and IsASellOn100

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe data2 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 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

Not run on other markets: the script requests BINANCE:BTCUSDT 1, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data). Its results would rest on empty values.

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
Phoenix085-Strategies==-MTF - Average True Range + MovAvg this page—v4 strategy0.0%00.0%
ATR_Trade_strategy by arameshrajutrv4 strategy+521.3%3657.8%
Vortex Indicator by Zeal Terminaltrv5 indicatorindicator
Ultimate Oscillator by Zeal Terminaltrv5 indicatorindicator
[MACLEN] TRUE RANGE by MaclenMtztrv5 strategy+2.5%273.5%
FXFUNDINGMATE TREND INDICATOR by FXFUNDINGMATEtrv4 strategy−6.4%1013.3%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 24 msWith a workaround 1,000 bars in 51 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 91, 98) so the engine trades the way the script says.

“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/// © Phoenix085//@version=4strategy("Phoenix085-Strategy_ATR+MovAvg", shorttitle="Strategy_ATR+MovAvg", overlay=true)// // ######################>>>>>>>>>>>>Inputs<<<<<<<<<<<#########################// // ######################>>>>>>>>>>>>Strategy Inputs<<<<<<<<<<<#########################TakeProfitPercent = input(50, title="Take Profit %", type=input.float, step=.25)StopLossPercent = input(5, title="Stop Loss %", type=input.float, step=.25)ProfitTarget = (close * (TakeProfitPercent / 100)) / syminfo.mintickLossTarget = (close * (StopLossPercent / 100)) / syminfo.minticklen_S = input(title="Shorter MA Length", defval=8, minval=1)len_L = input(title="Longer MA Length", defval=38, minval=1)TF = input(defval="", title="Session TF for calc only", type=input.session,options=[""])TF_ = "1"if TF == "3"    TF_ == "1"else     if TF == "5"         TF_ == "3"    else         if TF == "15"            TF_ == "5"        else             if TF == "30"                TF_ == "15"            else                 if TF == "1H"                    TF_ == "30"                else                     if TF == "2H"                        TF_ == "1H"                    else                         if TF == "4H"                            TF_ == "3H"                        else                             if TF == "1D"                                TF_ == "4H"                            else                                if TF == "1W"                                    TF_ == "1H"                                else                                     if TF == "1M"                                        TF_ == "1W"                                    else                                        if TF =="3H"                                            TF_ == "2H"Src = security(syminfo.tickerid, TF, close[1], barmerge.lookahead_on)Src_ = security(syminfo.tickerid, TF_, close, barmerge.lookahead_off)// ######################>>>>>>>>>>>>ATR Inputs<<<<<<<<<<<#########################length = input(title="ATR Length", defval=4, minval=1)smoothing = input(title="ATR Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])// //######################>>>>>>>>>>>>Custom Functions Declarations<<<<<<<<<<<#########################// ######################>>>>>>>>>>>>ATR<<<<<<<<<<<#########################ma_function(source, length) =>    if smoothing == "RMA"        rma(Src, length)    else        if smoothing == "SMA"            sma(Src, length)        else            if smoothing == "EMA"                ema(Src, length)            else                wma(Src, length)ATR=ma_function(tr(true), length)// //######################>>>>>>>>>>>>Conditions<<<<<<<<<<<#########################ATR_Rise = ATR>ATR[1] and ATR[1]<ATR[2] and ATR[2]<ATR[3]longCondition = crossover(sma(Src_, len_S), sma(Src_, len_L)) and sma(Src_, len_L) < sma(Src_, len_S) and (sma(Src_, len_S) < Src_[1])shortCondition = crossunder(sma(Src_, len_S), sma(Src_, len_L)) and sma(Src_, len_L) > sma(Src_, len_S) plot(sma(Src_, len_S), color=color.lime, transp=90)col = longCondition ? color.lime : shortCondition ? color.red : color.grayplot(sma(Src_, len_L),color=col,linewidth=2)bool IsABuy = longCondition bool IsASell = shortCondition// // ######################>>>>>>>>>>>>Strategy<<<<<<<<<<<#########################testStartYear = input(2015, "Backtest Start Year", minval=1980)testStartMonth = input(1, "Backtest Start Month", minval=1, maxval=12)testStartDay = input(1, "Backtest Start Day", minval=1, maxval=31)testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)testStopYear = input(9999, "Backtest Stop Year", minval=1980)testStopMonth = input(12, "Backtest Stop Month", minval=1, maxval=12)testStopDay = input(31, "Backtest Stop Day", minval=1, maxval=31)testPeriodStop = timestamp(testStopYear, testStopMonth, testStopDay, 0, 0)testPeriod() =>    time >= testPeriodStart and time <= testPeriodStop ? true : falseinDateRange = time >= testPeriodStart and time <= testPeriodStopbgcolor(inDateRange ? color.green : na, 90)// //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<//// // ######################>>>>>>LongEntries<<<<<<<#########################if inDateRange and ATR_Rise and IsABuy     strategy.entry("longCondition",true,when = longCondition)    strategy.close("shortCondition")    strategy.exit("Take Profit or Stop Loss", "longCondition",trail_points = close * 0.05 / syminfo.mintick ,trail_offset = close * 0.05 / syminfo.mintick, loss = LossTarget)// strategy.risk.max_drawdown(10, strategy.percent_of_equity)    // // ######################>>>>>>ShortEntries<<<<<<<#########################if inDateRange and ATR_Rise and IsASell      strategy.entry("shortCondition",false,when = shortCondition)    strategy.exit("Take Profit or Stop Loss", "shortCondition",trail_points = close * 0.05 / syminfo.mintick ,trail_offset = close * 0.05 / syminfo.mintick, loss = LossTarget)    strategy.close("longCondition")