Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

TradingView Alerts to MT4 MT5 - Forex, indices, commodities

A Pine Script v4 strategy built on SMA or Stoch (4), SMA (k, 3) and Pivothigh (high, 1). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is 20000 contracts and pays 0.00003 commission. 5 settings; defaults include Take Profit Level 400, Take Partial Profit Level 150 and K 13.

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 TradingView Alerts to MT4 MT5 - Forex, indices, commodities repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 124 of 124 trades.
How did TradingView Alerts to MT4 MT5 - Forex, indices, commodities do on BTCUSDT 1D with default settings?
−699,283.00%
From 26 Jan 2024 to 21 Oct 2026, over 382 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can TradingView Alerts to MT4 MT5 - Forex, indices, commodities be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
What alerts does TradingView Alerts to MT4 MT5 - Forex, indices, commodities have?
4
alertsyntax_golong; alertsyntax_goshort; closepart tradeid=' + tostring(trade_id) + ' part=0.5; closepart tradeid=' + tostring(trade_id) + ' part=0.5.
Does TradingView Alerts to MT4 MT5 - Forex, indices, commodities use a stop loss?
Yes
strategy.exit sets a stop on line 52, 55.

BTCUSDT · 1D · default settings

  • %K
  • %D
  • HLine
  • HLine
  • 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 (5)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct%K$-6,993,450$2,025Equity from $1,000
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
−699,283.00%
−$6,992,830.00
Buy and hold
+102.5%
same period
Closed trades
382
380 won · 2 lost
Profitable
99.5%
of closed trades
Profit factor
0.60
gross profit ÷ gross loss
Max drawdown
3,138.68%
−$20,746,200.00

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

  • Note

    2 settings have no label

    In the settings dialog TakeProfitLevel (line 14), TakePartialProfitLevel (line 15) 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.

  • Note

    Uses an argument v6 removed

    when = on line 50, 53. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 26

    transp = on line 26. 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 sma → ta.sma, stoch → ta.stoch, crossover → ta.crossover, crossunder → ta.crossunder, pivothigh → ta.pivothigh, pivotlow → ta.pivotlow, valuewhen → ta.valuewhen, barssince → ta.barssince, tostring → str.tostring.
  • 2 strategy calls use the when = argument (line 50, 53). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 20: sma → ta.sma
  • Line 20: stoch → ta.stoch
  • Line 21: sma → ta.sma
  • Line 26: transp = 75 → color.new(color.purple, 75)
  • Line 27: crossover → ta.crossover
21 more edits
  • Line 28: crossunder → ta.crossunder
  • Line 32: pivothigh → ta.pivothigh
  • Line 33: pivotlow → ta.pivotlow
  • Line 36: valuewhen → ta.valuewhen
  • Line 37: valuewhen → ta.valuewhen
  • Line 47: barssince → ta.barssince
  • Line 47: barssince → ta.barssince
  • Line 47: crossover → ta.crossover
  • Line 47: valuewhen → ta.valuewhen
  • Line 48: barssince → ta.barssince
  • Line 48: barssince → ta.barssince
  • Line 48: crossunder → ta.crossunder
  • Line 48: valuewhen → ta.valuewhen
  • Line 57: tostring → str.tostring
  • Line 57: tostring → str.tostring
  • Line 57: tostring → str.tostring
  • Line 60: tostring → str.tostring
  • Line 60: tostring → str.tostring
  • Line 60: tostring → str.tostring
  • Line 63: tostring → str.tostring
  • Line 66: tostring → str.tostring
⋯// © Peter_O-//@version=4+//@version=5strategy(title="TradingView Alerts to MT4 MT5 - Forex, indices, commodities, stocks, crypto", commission_type=strategy.commission.cash_per_contract, commission_value=0.00003, overlay=false, default_qty_value=20000, initial_capital=1000)⋯smoothK = input(4, title="Smooth", minval=1)-k = sma(stoch(close, high, low, periodK), smoothK)+k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)-d = sma(k, periodD)+d = ta.sma(k, periodD)plot(k, title="%K", color=color.blue)⋯h1 = hline(20)-fill(h0, h1, color=color.purple, transp=75)+fill(h0, h1, color=color.new(color.purple, 75))-GoLong=crossover(k,d) and k<80 and year>2009+GoLong=ta.crossover(k,d) and k<80 and year>2009-GoShort=crossunder(k,d) and k>20 and year>2009+GoShort=ta.crossunder(k,d) and k>20 and year>2009AlertTest=open>close or open<close or open==close⋯// **** Pivot-points and stop-loss logic **** {-piv_high = pivothigh(high,1,1)+piv_high = ta.pivothigh(high,1,1)-piv_low = pivotlow(low,1,1)+piv_low = ta.pivotlow(low,1,1)var float stoploss_long=lowvar float stoploss_short=high-pl=valuewhen(piv_low,piv_low,0)+pl=ta.valuewhen(piv_low,piv_low,0)-ph=valuewhen(piv_high,piv_high,0)+ph=ta.valuewhen(piv_high,piv_high,0)if GoLong ⋯    trade_id:=trade_id+1-TakePartialProfitLong = barssince(GoLong)<barssince(GoShort) and crossover(high,(valuewhen(GoLong,close,0)+TakePartialProfitLevel*syminfo.mintick))+TakePartialProfitLong = ta.barssince(GoLong)<ta.barssince(GoShort) and ta.crossover(high,(ta.valuewhen(GoLong,close,0)+TakePartialProfitLevel*syminfo.mintick))-TakePartialProfitShort = barssince(GoLong)>barssince(GoShort) and crossunder(low,(valuewhen(GoShort,close,0)-TakePartialProfitLevel*syminfo.mintick))+TakePartialProfitShort = ta.barssince(GoLong)>ta.barssince(GoShort) and ta.crossunder(low,(ta.valuewhen(GoShort,close,0)-TakePartialProfitLevel*syminfo.mintick))// } End of Trade counter and partial closing mechanism⋯if GoLong-    alertsyntax_golong='long slprice=' + tostring(stoploss_long) + ' tradeid=' + tostring(trade_id) + ' tp=' + tostring(TakeProfitLevel)+    alertsyntax_golong='long slprice=' + str.tostring(stoploss_long) + ' tradeid=' + str.tostring(trade_id) + ' tp=' + str.tostring(TakeProfitLevel)    alert(message=alertsyntax_golong, freq=alert.freq_once_per_bar_close)if GoShort-    alertsyntax_goshort='short slprice=' + tostring(stoploss_short) + ' tradeid=' + tostring(trade_id) + ' tp=' + tostring(TakeProfitLevel)+    alertsyntax_goshort='short slprice=' + str.tostring(stoploss_short) + ' tradeid=' + str.tostring(trade_id) + ' tp=' + str.tostring(TakeProfitLevel)    alert(message=alertsyntax_goshort, freq=alert.freq_once_per_bar_close)if TakePartialProfitLong-    alertsyntax_closepartlong='closepart tradeid=' + tostring(trade_id) + ' part=0.5'+    alertsyntax_closepartlong='closepart tradeid=' + str.tostring(trade_id) + ' part=0.5'    alert(message=alertsyntax_closepartlong, freq=alert.freq_once_per_bar_close)if TakePartialProfitShort-    alertsyntax_closepartshort='closepart tradeid=' + tostring(trade_id) + ' part=0.5'+    alertsyntax_closepartshort='closepart tradeid=' + str.tostring(trade_id) + ' part=0.5'    alert(message=alertsyntax_closepartshort, freq=alert.freq_once_per_bar_close)

Clean v5

VerifiedDownload the v5 script

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

  • Line 14: input() → input.int()
  • Line 15: input() → input.int()
  • Line 17: input() → input.int()
  • Line 18: input() → input.int()
  • Line 19: input() → input.int()
  • Line 50: when = GoLong → if block
  • Line 53: when = GoShort → if block
⋯ -TakeProfitLevel=input(400)+TakeProfitLevel=input.int(400)-TakePartialProfitLevel=input(150)+TakePartialProfitLevel=input.int(150)// **** Entries logic **** {-periodK = input(13, title="K", minval=1)+periodK = input.int(13, title="K", minval=1)-periodD = input(3, title="D", minval=1)+periodD = input.int(3, title="D", minval=1)-smoothK = input(4, title="Smooth", minval=1)+smoothK = input.int(4, title="Smooth", minval=1)k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)⋯// } End of Trade counter and partial closing mechanism-strategy.entry("Long", strategy.long, when=GoLong)+if GoLong+    strategy.entry("Long", strategy.long)strategy.exit("XPartLong", from_entry="Long", qty_percent=50, profit=TakePartialProfitLevel)strategy.exit("XLong", from_entry="Long", stop=stoploss_long, profit=TakeProfitLevel)-strategy.entry("Short", strategy.short, when=GoShort)+if GoShort+    strategy.entry("Short", strategy.short)strategy.exit("XPartShort", from_entry="Short", qty_percent=50, profit=TakePartialProfitLevel)⋯

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

⋯// © Peter_O-//@version=5+//@version=6strategy(title="TradingView Alerts to MT4 MT5 - Forex, indices, commodities, stocks, crypto", commission_type=strategy.commission.cash_per_contract, commission_value=0.00003, overlay=false, default_qty_value=20000, initial_capital=1000)⋯

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 Level (no label in the script)400intalertsyntax_golong alertsyntax_goshort exit XLong exit XShort
Take Partial Profit Level (no label in the script)150intTakePartialProfitLong TakePartialProfitShort exit XPartLong exit XPartShort
K13int · min 1k
D3int · min 1d
Smooth4int · min 1k

What it calculates

  • SMA / Stoch (sma, ta.sma in v5)stoch(close, high, low, periodK), Smooth (4)k · line 20
  • SMA (sma, ta.sma in v5)k, D (3)d · line 21
  • Pivothigh (pivothigh, ta.pivothigh in v5)high, 1, 1piv_high · line 32
  • Pivotlow (pivotlow, ta.pivotlow in v5)low, 1, 1piv_low · line 33
  • Valuewhen (valuewhen, ta.valuewhen in v5)piv_low, piv_low, 0pl · line 36
  • Valuewhen (valuewhen, ta.valuewhen in v5)piv_high, piv_high, 0ph · line 37

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 datahighhighprice datalowlowprice dataperiodKKsetting · 13smoothKSmoothsetting · 4periodDDsetting · 3TakeProfitLevelTake Profit Levelsetting · 400openopenprice dataTakePartialProfitLevelTake Partial Profit Lev…setting · 150kSMA / Stoch→ kdSMA→ dpiv_highPivothigh→ piv_highpiv_lowPivotlow→ piv_lowplValuewhen→ plphValuewhen→ phstoploss_longstoploss_longvaluestoploss_shortstoploss_shortvaluetrade_idtrade_idvaluealertsyntax_golongalertsyntax_golongvaluealertsyntax_goshortalertsyntax_goshortvalueGoLongGoLongconditionGoShortGoShortconditionAlertTestAlertTestconditionTakePartialProfitLongTakePartialProfitLongconditionTakePartialProfitShortTakePartialProfitShortconditionentry:LongOpen Longstrategy.entryexit:XPartLongexit XPartLongstrategy.exitexit:XLongexit XLongstrategy.exitentry:ShortOpen Shortstrategy.entryexit:XPartShortexit XPartShortstrategy.exitexit:XShortexit XShortstrategy.exitplot:22%Kplotplot:23%Dplothline:24hlinehlinehline:25hlinehlinefill:26Fillfillalert:58alertalertalert:61alertalertalert:64alertalertalert:67alertalert

Order rules

OrderFires whenBy defaultLine
Open Long longGoLongcrossover(k,d) and k<80 and year>2009On50
Exit XPartLong limitevery barOn51
Exit XLong stop and limitevery barOn52
Open Short shortGoShortcrossunder(k,d) and k>20 and year>2009On53
Exit XPartShort limitevery barOn54
Exit XShort stop and limitevery barOn55

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
(no title)alertalertsyntax_golong58
(no title)alertalertsyntax_goshort61
(no title)alertclosepart tradeid=' + tostring(trade_id) + ' part=0.564
(no title)alertclosepart tradeid=' + tostring(trade_id) + ' part=0.567

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

124/124trades 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−699,283.0%+102.5%38299%0.603,138.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−6,442,630.0%+5.5%33798%0.124,057.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+14,097.4%+9.8%37697%1.013,769.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−328,183.0%+8.4%37092%0.7480,750.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+117,858.0%+16.7%34879%1.2191.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+46,851.3%+21.5%26156%1.2211,490.3%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+436,287.0%+148.3%38593%1.8412,800.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−58,089.5%+17.1%31572%0.91673.8%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (K 7, D 2) made +1,000,980.0% before 26 Dec 2025 and +478,490.0% after it, against +340,993.0% for the defaults. 72% of the 32 combinations made money in-sample and 88% out-of-sample.

Before 26 Dec 2025 · in-sample
D ↓ · K →7891113161822
2+1,000,980%+945,979%+890,981%+890,981%+448,979%+918,480%−23,589%+753,484%
3+309,153%+758,983%+709,485%−543,275%−1,040,280%+208,955%+203,455%+153,957%
4−548,775%−570,775%−631,273%+615,987%+137,457%+555,488%+343,179%+527,988%
5+659,986%+593,987%+566,488%−931,753%+63,988%+516,989%−19,690%−590,720%
From 26 Dec 2025 · out-of-sample
D ↓ · K →7891113161822
2+478,490%+467,490%+450,990%+461,990%+384,992%+373,992%+384,992%+373,992%
3+406,991%+384,992%+401,491%+362,992%+340,993%+318,993%+313,493%−600,956%
4+340,993%+340,993%+329,993%−511,277%+285,994%+263,994%−9,706,390%−8,920,120%
5+318,993%+285,994%+313,493%+296,994%+263,994%+247,495%+258,494%+225,495%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market14099%−$1,230,080.00
Sideways market136100%$3,739,920.00
Falling market10699%−$9,502,660.00

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

How bad could the drawdown be?

11,938,100.0%

The 95th percentile of the worst drawdown when the same 382 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 687.1% to 11,938,100.0%; the tick is what actually happened, 2,167.5%. Order luck alone moves it this much.

0%13,728,815%
The first 150 of 382 trades
SideEntryExitBarsP&L
short16 Feb 2024 51,880.0016 Feb 2024 51,878.500$14,999.40
short16 Feb 2024 51,880.0016 Feb 2024 51,876.000$39,999.40
long27 Feb 2024 54,476.5027 Feb 2024 54,478.000$14,999.40
long27 Feb 2024 54,476.5027 Feb 2024 54,480.500$39,999.40
short2 Mar 2024 62,387.902 Mar 2024 62,386.400$14,999.40
short2 Mar 2024 62,387.902 Mar 2024 62,383.900$39,999.40
short6 Mar 2024 63,724.006 Mar 2024 63,722.500$14,999.40
short6 Mar 2024 63,724.006 Mar 2024 63,720.000$39,999.40
short15 Mar 2024 71,388.9015 Mar 2024 71,387.400$14,999.40
short15 Mar 2024 71,388.9015 Mar 2024 71,384.900$39,999.40
long24 Mar 2024 63,990.0024 Mar 2024 63,991.500$14,999.40
long24 Mar 2024 63,990.0024 Mar 2024 63,994.000$39,999.40
short3 Apr 2024 65,464.003 Apr 2024 65,462.500$14,999.40
short3 Apr 2024 65,464.003 Apr 2024 65,460.000$39,999.40
long7 Apr 2024 68,896.007 Apr 2024 68,897.500$14,999.40
long7 Apr 2024 68,896.007 Apr 2024 68,900.000$39,999.40
short13 Apr 2024 67,116.5013 Apr 2024 67,115.000$14,999.40
short13 Apr 2024 67,116.5013 Apr 2024 67,112.500$39,999.40
long20 Apr 2024 63,818.0020 Apr 2024 63,819.500$14,999.40
long20 Apr 2024 63,818.0020 Apr 2024 63,822.000$39,999.40
short28 Apr 2024 63,462.0028 Apr 2024 63,460.500$14,999.40
short28 Apr 2024 63,462.0028 Apr 2024 63,458.000$39,999.40
long29 Apr 2024 63,118.6029 Apr 2024 63,120.100$14,999.40
long29 Apr 2024 63,118.6029 Apr 2024 63,122.600$39,999.40
short30 Apr 2024 63,866.0030 Apr 2024 64,370.000−$5,040,000.00
short30 Apr 2024 63,866.0030 Apr 2024 63,864.500$14,999.40
long5 May 2024 63,892.005 May 2024 63,893.500$14,999.40
long5 May 2024 63,892.005 May 2024 63,896.000$39,999.40
short9 May 2024 61,193.009 May 2024 61,191.500$14,999.40
short9 May 2024 61,193.009 May 2024 61,189.000$39,999.40
long14 May 2024 62,940.1014 May 2024 62,941.600$14,999.40
long14 May 2024 62,940.1014 May 2024 62,944.100$39,999.40
short23 May 2024 69,166.6023 May 2024 69,165.100$14,999.40
short23 May 2024 69,166.6023 May 2024 69,162.600$39,999.40
long28 May 2024 69,436.4028 May 2024 69,437.900$14,999.40
long28 May 2024 69,436.4028 May 2024 69,440.400$39,999.40
short29 May 2024 68,398.4029 May 2024 68,396.900$14,999.40
short29 May 2024 68,398.4029 May 2024 68,394.400$39,999.40
long4 Jun 2024 68,809.904 Jun 2024 68,811.400$14,999.40
long4 Jun 2024 68,809.904 Jun 2024 68,813.900$39,999.40
short9 Jun 2024 69,310.509 Jun 2024 69,309.000$14,999.40
short9 Jun 2024 69,310.509 Jun 2024 69,306.500$39,999.40
long18 Jun 2024 66,504.3018 Jun 2024 66,505.800$14,999.40
long18 Jun 2024 66,504.3018 Jun 2024 66,508.300$39,999.40
long26 Jun 2024 61,806.0026 Jun 2024 61,807.500$14,999.40
long26 Jun 2024 61,806.0026 Jun 2024 61,810.000$39,999.40
short30 Jun 2024 60,986.7030 Jun 2024 60,985.200$14,999.40
short30 Jun 2024 60,986.7030 Jun 2024 60,982.700$39,999.40
long1 Jul 2024 62,772.001 Jul 2024 62,773.500$14,999.40
long1 Jul 2024 62,772.001 Jul 2024 62,776.000$39,999.40
short5 Jul 2024 57,050.005 Jul 2024 57,048.500$14,999.40
short5 Jul 2024 57,050.005 Jul 2024 57,046.000$39,999.40
long9 Jul 2024 56,714.609 Jul 2024 56,716.100$14,999.40
long9 Jul 2024 56,714.609 Jul 2024 56,718.600$39,999.40
short20 Jul 2024 66,660.0020 Jul 2024 66,658.500$14,999.40
short20 Jul 2024 66,660.0020 Jul 2024 66,656.000$39,999.40
short24 Jul 2024 65,936.0024 Jul 2024 65,934.500$14,999.40
short24 Jul 2024 65,936.0024 Jul 2024 65,932.000$39,999.40
short30 Jul 2024 66,784.7030 Jul 2024 66,783.200$14,999.40
short30 Jul 2024 66,784.7030 Jul 2024 66,780.700$39,999.40
long7 Aug 2024 56,022.007 Aug 2024 56,023.500$14,999.40
long7 Aug 2024 56,022.007 Aug 2024 56,026.000$39,999.40
short19 Aug 2024 58,427.3019 Aug 2024 58,425.800$14,999.40
short19 Aug 2024 58,427.3019 Aug 2024 58,423.300$39,999.40
long22 Aug 2024 61,156.0022 Aug 2024 61,157.500$14,999.40
long22 Aug 2024 61,156.0022 Aug 2024 61,160.000$39,999.40
short28 Aug 2024 59,415.0028 Aug 2024 59,413.500$14,999.40
short28 Aug 2024 59,415.0028 Aug 2024 59,411.000$39,999.40
long5 Sep 2024 57,970.905 Sep 2024 57,972.400$14,999.40
long5 Sep 2024 57,970.905 Sep 2024 57,974.900$39,999.40
long8 Sep 2024 54,160.908 Sep 2024 54,162.400$14,999.40
long8 Sep 2024 54,160.908 Sep 2024 54,164.900$39,999.40
short18 Sep 2024 60,314.0018 Sep 2024 60,312.500$14,999.40
short18 Sep 2024 60,314.0018 Sep 2024 60,310.000$39,999.40
short23 Sep 2024 63,578.8023 Sep 2024 63,577.300$14,999.40
short23 Sep 2024 63,578.8023 Sep 2024 63,574.800$39,999.40
short1 Oct 2024 63,327.601 Oct 2024 63,326.100$14,999.40
short1 Oct 2024 63,327.601 Oct 2024 63,323.600$39,999.40
long6 Oct 2024 62,058.006 Oct 2024 62,059.500$14,999.40
long6 Oct 2024 62,058.006 Oct 2024 62,062.000$39,999.40
short10 Oct 2024 60,636.0010 Oct 2024 60,634.500$14,999.40
short10 Oct 2024 60,636.0010 Oct 2024 60,632.000$39,999.40
long12 Oct 2024 62,540.0012 Oct 2024 62,541.500$14,999.40
long12 Oct 2024 62,540.0012 Oct 2024 62,544.000$39,999.40
short22 Oct 2024 67,377.5022 Oct 2024 67,376.000$14,999.40
short22 Oct 2024 67,377.5022 Oct 2024 67,373.500$39,999.40
long29 Oct 2024 69,962.2029 Oct 2024 69,963.700$14,999.40
long29 Oct 2024 69,962.2029 Oct 2024 69,966.200$39,999.40
short2 Nov 2024 69,496.002 Nov 2024 69,494.500$14,999.40
short2 Nov 2024 69,496.002 Nov 2024 69,492.000$39,999.40
long7 Nov 2024 75,572.007 Nov 2024 75,573.500$14,999.40
long7 Nov 2024 75,572.007 Nov 2024 75,576.000$39,999.40
short14 Nov 2024 90,375.2014 Nov 2024 90,373.700$14,999.40
short14 Nov 2024 90,375.2014 Nov 2024 90,371.200$39,999.40
short25 Nov 2024 97,900.1025 Nov 2024 97,898.600$14,999.40
short25 Nov 2024 97,900.1025 Nov 2024 97,896.100$39,999.40
long30 Nov 2024 97,460.0030 Nov 2024 97,461.500$14,999.40
long30 Nov 2024 97,460.001 Dec 2024 97,464.001$39,999.40
short3 Dec 2024 95,840.603 Dec 2024 95,839.100$14,999.40
short3 Dec 2024 95,840.603 Dec 2024 95,836.600$39,999.40
long5 Dec 2024 98,587.305 Dec 2024 98,588.800$14,999.40
long5 Dec 2024 98,587.305 Dec 2024 98,591.300$39,999.40
short6 Dec 2024 96,945.606 Dec 2024 96,944.100$14,999.40
short6 Dec 2024 96,945.606 Dec 2024 96,941.600$39,999.40
long8 Dec 2024 99,832.008 Dec 2024 99,833.500$14,999.40
long8 Dec 2024 99,832.008 Dec 2024 99,836.000$39,999.40
short9 Dec 2024 101,110.009 Dec 2024 101,108.000$14,999.40
short9 Dec 2024 101,110.009 Dec 2024 101,106.000$39,999.40
long14 Dec 2024 101,424.0014 Dec 2024 101,426.000$14,999.40
long14 Dec 2024 101,424.0014 Dec 2024 101,428.000$39,999.40
short19 Dec 2024 100,204.0019 Dec 2024 100,203.000$14,999.40
short19 Dec 2024 100,204.0019 Dec 2024 100,200.000$39,999.40
long25 Dec 2024 98,663.6025 Dec 2024 98,665.100$14,999.40
long25 Dec 2024 98,663.6025 Dec 2024 98,667.600$39,999.40
short28 Dec 2024 94,299.0028 Dec 2024 94,297.500$14,999.40
short28 Dec 2024 94,299.0028 Dec 2024 94,295.000$39,999.40
long2 Jan 2025 94,591.802 Jan 2025 94,593.300$14,999.40
long2 Jan 2025 94,591.802 Jan 2025 94,595.800$39,999.40
short8 Jan 2025 96,954.608 Jan 2025 96,953.100$14,999.40
short8 Jan 2025 96,954.608 Jan 2025 96,950.600$39,999.40
long14 Jan 2025 94,536.1014 Jan 2025 94,537.600$14,999.40
long14 Jan 2025 94,536.1014 Jan 2025 94,540.100$39,999.40
short21 Jan 2025 102,260.0021 Jan 2025 102,259.000$14,999.40
short21 Jan 2025 102,260.0021 Jan 2025 102,256.000$39,999.40
long25 Jan 2025 104,871.0025 Jan 2025 104,872.000$14,999.40
long25 Jan 2025 104,871.0025 Jan 2025 104,875.000$39,999.40
short26 Jan 2025 104,747.0026 Jan 2025 104,745.000$14,999.40
short26 Jan 2025 104,747.0026 Jan 2025 104,743.000$39,999.40
long5 Feb 2025 97,763.105 Feb 2025 97,764.600$14,999.40
long5 Feb 2025 97,763.105 Feb 2025 97,767.100$39,999.40
short8 Feb 2025 96,506.808 Feb 2025 96,505.300$14,999.40
short8 Feb 2025 96,506.808 Feb 2025 96,502.800$39,999.40
long11 Feb 2025 97,430.8011 Feb 2025 97,432.300$14,999.40
long11 Feb 2025 97,430.8011 Feb 2025 97,434.800$39,999.40
short12 Feb 2025 95,778.2012 Feb 2025 95,776.700$14,999.40
short12 Feb 2025 95,778.2012 Feb 2025 95,774.200$39,999.40
long13 Feb 2025 97,870.0013 Feb 2025 97,871.500$14,999.40
long13 Feb 2025 97,870.0013 Feb 2025 97,874.000$39,999.40
short17 Feb 2025 96,118.1017 Feb 2025 96,116.600$14,999.40
short17 Feb 2025 96,118.1017 Feb 2025 96,114.100$39,999.40
long21 Feb 2025 98,305.0021 Feb 2025 98,306.500$14,999.40
long21 Feb 2025 98,305.0021 Feb 2025 98,309.000$39,999.40
short25 Feb 2025 91,552.9025 Feb 2025 91,551.400$14,999.40
short25 Feb 2025 91,552.9025 Feb 2025 91,548.900$39,999.40
long1 Mar 2025 84,349.901 Mar 2025 84,351.400$14,999.40
long1 Mar 2025 84,349.901 Mar 2025 84,353.900$39,999.40
short7 Mar 2025 89,931.907 Mar 2025 89,930.400$14,999.40
short7 Mar 2025 89,931.907 Mar 2025 89,927.900$39,999.40
long8 Mar 2025 86,801.708 Mar 2025 86,803.200$14,999.40
long8 Mar 2025 86,801.708 Mar 2025 86,805.700$39,999.40

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
TradingView Alerts to MT4 MT5 - Forex, indices, commodities this page—v4 strategy−699,283.0%3823,138.7%
Alert(), alertcondition() or strategy alerts- by Peter_Osma pivothigh pivotlow valuewhenv4 strategy+7,640,000.0%191919.9%
Quantitative Trend Strategy- Uptrend long by CheatCode1sma pivothigh pivotlow valuewhenv5 strategy+5.9%2832.8%
Moving Stop-Loss mechanism + alerts to MT4-MT5 by Peter_Osma pivothigh pivotlow valuewhenv5 strategy−9,857,600.0%1914,436.8%
Qullamaggie Breakout V2 by millerrhsma pivothigh pivotlow valuewhenv5 strategy+35.4%3316.9%
TradePro's 2 EMA + Stoch RSI + ATR Strategy by PtGamblersma pivothigh pivotlow valuewhenv5 strategy−2.7%1822.0%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 43 msYes 1,000 bars in 49 msNot measured
PineTSNo 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/// © Peter_O//@version=4strategy(title="TradingView Alerts to MT4 MT5 - Forex, indices, commodities, stocks, crypto", commission_type=strategy.commission.cash_per_contract, commission_value=0.00003, overlay=false, default_qty_value=20000, initial_capital=1000)//// This script was created for educational purposes only.// It is showing how to use Alerts-Straight-From-Strategies and// dynamic variables in TradingView alerts.// And how to auto-execute them in Forex, indices, commodities markets// // (This method will also work with stocks and crypto - anything your // broker is offering via their MT4/MT5 platform). TakeProfitLevel=input(400)TakePartialProfitLevel=input(150)// **** Entries logic **** {periodK = input(13, title="K", minval=1)periodD = input(3, title="D", minval=1)smoothK = input(4, title="Smooth", minval=1)k = sma(stoch(close, high, low, periodK), smoothK)d = sma(k, periodD)plot(k, title="%K", color=color.blue)plot(d, title="%D", color=color.orange)h0 = hline(80)h1 = hline(20)fill(h0, h1, color=color.purple, transp=75)GoLong=crossover(k,d) and k<80 and year>2009GoShort=crossunder(k,d) and k>20 and year>2009AlertTest=open>close or open<close or open==close// } End of entries logic// **** Pivot-points and stop-loss logic **** {piv_high = pivothigh(high,1,1)piv_low = pivotlow(low,1,1)var float stoploss_long=lowvar float stoploss_short=highpl=valuewhen(piv_low,piv_low,0)ph=valuewhen(piv_high,piv_high,0)if GoLong     stoploss_long := low<pl ? low : plif GoShort     stoploss_short := high>ph ? high : ph// } End of Pivot-points and stop-loss logic// **** Trade counter and partial closing mechanism **** {var int trade_id=0if GoLong or GoShort    trade_id:=trade_id+1TakePartialProfitLong = barssince(GoLong)<barssince(GoShort) and crossover(high,(valuewhen(GoLong,close,0)+TakePartialProfitLevel*syminfo.mintick))TakePartialProfitShort = barssince(GoLong)>barssince(GoShort) and crossunder(low,(valuewhen(GoShort,close,0)-TakePartialProfitLevel*syminfo.mintick))// } End of Trade counter and partial closing mechanismstrategy.entry("Long", strategy.long, when=GoLong)strategy.exit("XPartLong", from_entry="Long", qty_percent=50, profit=TakePartialProfitLevel)strategy.exit("XLong", from_entry="Long", stop=stoploss_long, profit=TakeProfitLevel)strategy.entry("Short", strategy.short, when=GoShort)strategy.exit("XPartShort", from_entry="Short", qty_percent=50, profit=TakePartialProfitLevel)strategy.exit("XShort", from_entry="Short", stop=stoploss_short, profit=TakeProfitLevel)if GoLong    alertsyntax_golong='long slprice=' + tostring(stoploss_long) + ' tradeid=' + tostring(trade_id) + ' tp=' + tostring(TakeProfitLevel)    alert(message=alertsyntax_golong, freq=alert.freq_once_per_bar_close)if GoShort    alertsyntax_goshort='short slprice=' + tostring(stoploss_short) + ' tradeid=' + tostring(trade_id) + ' tp=' + tostring(TakeProfitLevel)    alert(message=alertsyntax_goshort, freq=alert.freq_once_per_bar_close)if TakePartialProfitLong    alertsyntax_closepartlong='closepart tradeid=' + tostring(trade_id) + ' part=0.5'    alert(message=alertsyntax_closepartlong, freq=alert.freq_once_per_bar_close)if TakePartialProfitShort    alertsyntax_closepartshort='closepart tradeid=' + tostring(trade_id) + ' part=0.5'    alert(message=alertsyntax_closepartshort, freq=alert.freq_once_per_bar_close)